A patch from Charlie to provide line numbers when reporting variable related

errors during execution.
This commit is contained in:
Michael Bayne
2010-10-23 16:35:38 +00:00
parent 4f5b3d772d
commit 7ec57412fa
3 changed files with 55 additions and 41 deletions
@@ -193,6 +193,16 @@ public class MustacheTest
context("things", Arrays.asList("foo", "bar", "baz")));
}
@Test public void testLineReporting () {
String tmpl = "first line\n{{nonexistent}}\nsecond line";
try {
Mustache.compiler().compile(tmpl).execute(new Object());
fail("Referencing a nonexistent variable should throw MustacheException");
} catch (MustacheException e) {
assertTrue(e.getMessage().contains("line 2"));
}
}
protected void test (String expected, String template, Object ctx)
{
assertEquals(expected, Mustache.compiler().compile(template).execute(ctx));