use of com.google.devtools.build.lib.packages.SkylarkClassObjectConstructor in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method declaredProvidersConcatSuccess.
@Test
public void declaredProvidersConcatSuccess() throws Exception {
evalAndExport("data = provider()", "dx = data(x = 1)", "dy = data(y = 'abc')", "dxy = dx + dy", "x = dxy.x", "y = dxy.y");
assertThat(lookup("x")).isEqualTo(1);
assertThat(lookup("y")).isEqualTo("abc");
SkylarkClassObjectConstructor dataConstructor = (SkylarkClassObjectConstructor) lookup("data");
SkylarkClassObject dx = (SkylarkClassObject) lookup("dx");
assertThat(dx.getConstructor()).isEqualTo(dataConstructor);
SkylarkClassObject dy = (SkylarkClassObject) lookup("dy");
assertThat(dy.getConstructor()).isEqualTo(dataConstructor);
}
use of com.google.devtools.build.lib.packages.SkylarkClassObjectConstructor in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method multipleTopLevels.
@Test
public void multipleTopLevels() throws Exception {
evalAndExport("p = provider()", "p1 = p");
SkylarkClassObjectConstructor p = (SkylarkClassObjectConstructor) lookup("p");
SkylarkClassObjectConstructor p1 = (SkylarkClassObjectConstructor) lookup("p1");
assertThat(p).isEqualTo(p1);
assertThat(p.getKey()).isEqualTo(new SkylarkClassObjectConstructor.SkylarkKey(FAKE_LABEL, "p"));
assertThat(p1.getKey()).isEqualTo(new SkylarkClassObjectConstructor.SkylarkKey(FAKE_LABEL, "p"));
}
use of com.google.devtools.build.lib.packages.SkylarkClassObjectConstructor 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.SkylarkClassObjectConstructor in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method fancyExports.
@Test
public void fancyExports() throws Exception {
evalAndExport("def _impla(target, ctx): pass", "p, (a, p1) = [", " provider(),", " [ aspect(_impla),", " provider() ]", "]");
SkylarkClassObjectConstructor p = (SkylarkClassObjectConstructor) lookup("p");
SkylarkAspect a = (SkylarkAspect) lookup("a");
SkylarkClassObjectConstructor p1 = (SkylarkClassObjectConstructor) lookup("p1");
assertThat(p.getPrintableName()).isEqualTo("p");
assertThat(p.getKey()).isEqualTo(new SkylarkClassObjectConstructor.SkylarkKey(FAKE_LABEL, "p"));
assertThat(p1.getPrintableName()).isEqualTo("p1");
assertThat(p1.getKey()).isEqualTo(new SkylarkClassObjectConstructor.SkylarkKey(FAKE_LABEL, "p1"));
assertThat(a.getAspectClass()).isEqualTo(new SkylarkAspectClass(FAKE_LABEL, "a"));
}
Aggregations