Skip to content

Commit 43fd04a

Browse files
committed
add a test for null breaking execute
1 parent 64e6e3f commit 43fd04a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

compiler/src/test/java/com/github/mustachejava/InterpreterTest.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,6 +1308,27 @@ public void testEmptyDot() {
13081308
System.out.println(sw);
13091309
}
13101310

1311+
@Test
1312+
public void testCase() {
1313+
String template = "Hello {{user.name}}";
1314+
1315+
DefaultMustacheFactory factory = new DefaultMustacheFactory();
1316+
Mustache m = factory.compile(new StringReader(template), "test");
1317+
1318+
Map<String, Object> scopes = new HashMap<>();
1319+
Map<String, String> value = new HashMap<>();
1320+
value.put("name", "Test");
1321+
scopes.put("user", value);
1322+
1323+
//Expected this to output 'Hello'
1324+
String result = m.execute(new StringWriter(), (Map<String, Object>) null).toString();
1325+
System.out.println(result); //prints 'Hello'
1326+
1327+
//Expected this to output 'Hello Test' instead prints 'Hello'
1328+
result = m.execute(new StringWriter(), scopes).toString();
1329+
System.out.println(result); //prints 'Hello'
1330+
}
1331+
13111332
public void testTemplateFunction() throws IOException {
13121333
MustacheFactory mf = createMustacheFactory();
13131334
Mustache m = mf.compile(new StringReader("{{#i}}{{{test}}}{{f}}{{/i}}" +

0 commit comments

Comments
 (0)