Let's add a test illustrating that default values are used for variables which

resolve to null.
This commit is contained in:
Michael Bayne
2011-04-15 12:39:16 -07:00
parent 15ff48eabb
commit 1be9c52589
@@ -299,6 +299,14 @@ public class MustacheTest
"foobar", "{{missing}}{{notmissing}}", context("notmissing", "bar"));
}
@Test public void testNullValueGetsDefault () {
test(Mustache.compiler().defaultValue("foo"),
"foobar", "{{nullvar}}{{nonnullvar}}", new Object() {
String nonnullvar = "bar";
String nullvar = null;
});
}
protected void test (Mustache.Compiler compiler, String expected, String template, Object ctx)
{
assertEquals(expected, compiler.compile(template).execute(ctx));