use of com.google.template.soy.error.ErrorReporter in project closure-templates by google.
the class TemplateNodeTest method testInvalidStrictTemplates.
@Test
public void testInvalidStrictTemplates() {
ErrorReporter errorReporter = ErrorReporter.createForTest();
parse("{namespace ns}\n" + "{template .boo autoescape=\"deprecated-noncontextual\" kind=\"text\"}{/template}", errorReporter);
assertThat(Iterables.getOnlyElement(errorReporter.getErrors()).message()).isEqualTo("kind=\"...\" attribute is only valid with autoescape=\"strict\".");
}
use of com.google.template.soy.error.ErrorReporter in project closure-templates by google.
the class TemplateNodeTest method testCommandTextErrors.
@Test
public void testCommandTextErrors() {
ErrorReporter errorReporter = ErrorReporter.createForTest();
parse("{namespace ns}\n{template requirecss=\"strict\"}{/template}", errorReporter);
assertThat(errorReporter.getErrors()).hasSize(2);
assertThat(errorReporter.getErrors().get(0).message()).isEqualTo("Template name 'requirecss' must be relative to the file namespace, i.e. a dot " + "followed by an identifier.");
assertThat(errorReporter.getErrors().get(1).message()).isEqualTo("parse error at '=': expected attribute name, }, identifier, or .");
errorReporter = ErrorReporter.createForTest();
parse("{namespace ns}\n{template .foo autoescape=\"}{/template}", errorReporter);
assertThat(Iterables.getOnlyElement(errorReporter.getErrors()).message()).isEqualTo("Unexpected end of file. Did you forget to close an attribute value or a comment?");
errorReporter = ErrorReporter.createForTest();
parse("{namespace ns}\n{template .foo autoescape=\"false\"}{/template}", errorReporter);
assertThat(Iterables.getOnlyElement(errorReporter.getErrors()).message()).isEqualTo("Invalid value for attribute 'autoescape', expected one of " + "[deprecated-contextual, deprecated-noncontextual].");
// assertion inside no-arg templateBasicNode() is that there is no exception.
parse("{namespace ns}\n{template .foo autoescape=\n\t\r \"deprecated-contextual\"}{/template}");
}
use of com.google.template.soy.error.ErrorReporter in project closure-templates by google.
the class TemplateRegistryTest method testDuplicateDefaultDeltemplates.
@Test
public void testDuplicateDefaultDeltemplates() {
String file = "{namespace ns}\n" + "/** Foo. */\n" + "{deltemplate foo.bar}\n" + "{/deltemplate}\n" + "/** Foo. */\n" + "{deltemplate foo.bar}\n" + "{/deltemplate}\n";
ErrorReporter errorReporter = ErrorReporter.createForTest();
SoyFileSetParserBuilder.forFileContents(file).errorReporter(errorReporter).parse();
assertThat(errorReporter.getErrors()).hasSize(1);
assertThat(Iterables.getOnlyElement(errorReporter.getErrors()).message()).isEqualTo("Delegate template 'foo.bar' already has a default defined at no-path:3:1.");
}
use of com.google.template.soy.error.ErrorReporter in project closure-templates by google.
the class TemplateRegistryTest method testDuplicateBasicTemplates.
@Test
public void testDuplicateBasicTemplates() {
String file = "{namespace ns}\n" + "/** Foo. */\n" + "{template .foo}\n" + "{/template}\n" + "/** Foo. */\n" + "{template .foo}\n" + "{/template}\n";
ErrorReporter errorReporter = ErrorReporter.createForTest();
SoyFileSetParserBuilder.forFileContents(file).errorReporter(errorReporter).parse();
assertThat(errorReporter.getErrors()).hasSize(1);
assertThat(Iterables.getOnlyElement(errorReporter.getErrors()).message()).isEqualTo("Template 'ns.foo' already defined at no-path:3:1.");
}
use of com.google.template.soy.error.ErrorReporter in project closure-templates by google.
the class TemplateRegistryTest method testDuplicateDeltemplatesInSameDelpackage.
@Test
public void testDuplicateDeltemplatesInSameDelpackage() {
String file = "{delpackage foo}\n" + "{namespace ns}\n" + "/** Foo. */\n" + "{deltemplate foo.bar}\n" + "{/deltemplate}\n" + "/** Foo. */\n" + "{deltemplate foo.bar}\n" + "{/deltemplate}\n";
ErrorReporter errorReporter = ErrorReporter.createForTest();
SoyFileSetParserBuilder.forFileContents(file).errorReporter(errorReporter).parse();
assertThat(errorReporter.getErrors()).hasSize(1);
assertThat(Iterables.getOnlyElement(errorReporter.getErrors()).message()).isEqualTo("Delegate template 'foo.bar' already defined in delpackage foo: no-path:4:1");
}
Aggregations