use of com.google.devtools.build.lib.packages.SkylarkClassObject in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method declaredProviders.
@Test
public void declaredProviders() throws Exception {
evalAndExport("data = provider()", "d = data(x = 1, y ='abc')", "d_x = d.x", "d_y = d.y");
assertThat(lookup("d_x")).isEqualTo(1);
assertThat(lookup("d_y")).isEqualTo("abc");
SkylarkClassObjectConstructor dataConstructor = (SkylarkClassObjectConstructor) lookup("data");
SkylarkClassObject data = (SkylarkClassObject) lookup("d");
assertThat(data.getConstructor()).isEqualTo(dataConstructor);
assertThat(dataConstructor.isExported()).isTrue();
assertThat(dataConstructor.getPrintableName()).isEqualTo("data");
assertThat(dataConstructor.getKey()).isEqualTo(new SkylarkClassObjectConstructor.SkylarkKey(FAKE_LABEL, "data"));
}
use of com.google.devtools.build.lib.packages.SkylarkClassObject in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method testStructConcatenationFieldNames.
@Test
public void testStructConcatenationFieldNames() throws Exception {
// TODO(fwe): cannot be handled by current testing suite
eval("x = struct(a = 1, b = 2)", "y = struct(c = 1, d = 2)", "z = x + y\n");
SkylarkClassObject z = (SkylarkClassObject) lookup("z");
assertEquals(ImmutableSet.of("a", "b", "c", "d"), z.getKeys());
}
Aggregations