Support index access on primitive arrays

This commit is contained in:
Masaki Mori
2015-09-14 13:45:08 +09:00
parent 2efcfb69ed
commit 4b713862c8
2 changed files with 33 additions and 1 deletions
@@ -89,6 +89,19 @@ public class MustacheTest
});
}
@Test public void testPrimitiveArrayIndexVariable () {
test("1", "{{foo.0}}", new Object() {
int[] getFoo () { return new int[] { 1, 2, 3, 4 }; }
});
}
@Test public void testPrimitiveArrayIndexOutOfBoundsVariable () {
Mustache.Compiler comp = Mustache.compiler().defaultValue("?");
test(comp, "?", "{{foo.4}}", new Object() {
int[] getFoo () { return new int[] { 1, 2, 3, 4 }; }
});
}
@Test public void testCallSiteReuse () {
Template tmpl = Mustache.compiler().compile("{{foo}}");
Object ctx = new Object() {