use of com.google.template.soy.soytree.SoyFileSetNode in project closure-templates by google.
the class ResolveExpressionTypesVisitorTest method testRecordTypes.
@Test
public void testRecordTypes() {
SoyFileSetNode soyTree = SoyFileSetParserBuilder.forFileContents(constructTemplateSource("{@param pa: [a:int, b:string]}", "{assertType('int', $pa.a)}", "{assertType('string', $pa.b)}")).addSoyFunction(ASSERT_TYPE_FUNCTION).parse().fileSet();
assertTypes(soyTree);
}
use of com.google.template.soy.soytree.SoyFileSetNode in project closure-templates by google.
the class ResolveExpressionTypesVisitorTest method testListLiteral.
@Test
public void testListLiteral() {
SoyFileSetNode soyTree = SoyFileSetParserBuilder.forFileContents(constructTemplateSource("{@param pi: int}", "{@param pf: float}", "{let $list: [$pi, $pf]/}", "{assertType('list<float|int>', $list)}", "{assertType('int', length($list))}")).declaredSyntaxVersion(SyntaxVersion.V2_4).typeRegistry(TYPE_REGISTRY).addSoyFunction(ASSERT_TYPE_FUNCTION).parse().fileSet();
assertTypes(soyTree);
}
use of com.google.template.soy.soytree.SoyFileSetNode in project closure-templates by google.
the class ResolveExpressionTypesVisitorTest method testOptionalParamTypes.
@Test
public void testOptionalParamTypes() {
SoyFileSetNode soyTree = SoyFileSetParserBuilder.forFileContents(constructTemplateSource("{@param? pa: bool}", "{@param? pb: list<int>}", "{assertType('bool|null', $pa)}", "{assertType('list<int>|null', $pb)}")).addSoyFunction(ASSERT_TYPE_FUNCTION).parse().fileSet();
assertTypes(soyTree);
}
use of com.google.template.soy.soytree.SoyFileSetNode in project closure-templates by google.
the class ResolveExpressionTypesVisitorTest method testNullCoalescingAndConditionalOps.
@Test
public void testNullCoalescingAndConditionalOps() {
SoyFileSetNode soyTree = SoyFileSetParserBuilder.forFileContents(constructTemplateSource("{@param pa: ?}", "{@param pi: int}", "{@param pf: float}", "{@param? ni: int}", "{assertType('?', $pa ?: $pi)}", "{assertType('float|int', $pi ?: $pf)}", "{assertType('float|int', $pa ? $pi : $pf)}", "{assertType('int', $ni ?: 0)}")).declaredSyntaxVersion(SyntaxVersion.V2_0).typeRegistry(TYPE_REGISTRY).addSoyFunction(ASSERT_TYPE_FUNCTION).parse().fileSet();
assertTypes(soyTree);
}
use of com.google.template.soy.soytree.SoyFileSetNode in project closure-templates by google.
the class ResolveExpressionTypesVisitorTest method testProtoInitTyping.
@Test
public void testProtoInitTyping() {
SoyTypeRegistry typeRegistry = new SoyTypeRegistry.Builder().addDescriptors(ImmutableList.of(ExampleExtendable.getDescriptor())).build();
SoyFileSetNode soyTree = SoyFileSetParserBuilder.forFileContents(constructTemplateSource("{let $proto: example.ExampleExtendable() /}", "{assertType('example.ExampleExtendable', $proto)}")).addSoyFunction(ASSERT_TYPE_FUNCTION).typeRegistry(typeRegistry).parse().fileSet();
assertTypes(soyTree);
}
Aggregations