Skip to content

Commit

Permalink
add a test for null breaking execute
Browse files Browse the repository at this point in the history
  • Loading branch information
spullara committed Aug 25, 2023
1 parent 64e6e3f commit 43fd04a
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1308,6 +1308,27 @@ public void testEmptyDot() {
System.out.println(sw);
}

@Test
public void testCase() {
String template = "Hello {{user.name}}";

DefaultMustacheFactory factory = new DefaultMustacheFactory();
Mustache m = factory.compile(new StringReader(template), "test");

Map<String, Object> scopes = new HashMap<>();
Map<String, String> value = new HashMap<>();
value.put("name", "Test");
scopes.put("user", value);

//Expected this to output 'Hello'
String result = m.execute(new StringWriter(), (Map<String, Object>) null).toString();
System.out.println(result); //prints 'Hello'

//Expected this to output 'Hello Test' instead prints 'Hello'
result = m.execute(new StringWriter(), scopes).toString();
System.out.println(result); //prints 'Hello'
}

public void testTemplateFunction() throws IOException {
MustacheFactory mf = createMustacheFactory();
Mustache m = mf.compile(new StringReader("{{#i}}{{{test}}}{{f}}{{/i}}" +
Expand Down

0 comments on commit 43fd04a

Please sign in to comment.