Skip to content

Commit

Permalink
Explicit test and result.
Browse files Browse the repository at this point in the history
  • Loading branch information
hs-lsong committed Dec 27, 2023
1 parent 12f3d60 commit f5c3682
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/main/java/com/hubspot/jinjava/interpret/NullValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
public final class NullValue {
public static final NullValue INSTANCE = new NullValue();

static NullValue instance() {
private NullValue() {}

public static NullValue instance() {
return INSTANCE;
}

Expand Down
13 changes: 7 additions & 6 deletions src/test/java/com/hubspot/jinjava/lib/tag/ForTagTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -381,12 +381,13 @@ public void itAllowsCheckingOfWithinForLoop() throws NoSuchMethodException {
public void forLoopWithNullValues() {
context.put("number", -1);
context.put("the_list", Lists.newArrayList(1L, 2L, null, null, null));
TagNode tagNode = (TagNode) fixture("loop-last-var");
Document dom = Jsoup.parseBodyFragment(tag.interpret(tagNode, interpreter));

assertThat(dom.select("h3")).hasSize(4);
dom.outputSettings().prettyPrint(true).indentAmount(4);
assertThat(dom.html()).contains("seven: null");
String template = "{% for number in the_list %} {{ number }} {% endfor %}";
TagNode tagNode = (TagNode) new TreeParser(interpreter, template)
.buildTree()
.getChildren()
.getFirst();
String result = tag.interpret(tagNode, interpreter);
assertThat(result).isEqualTo(" 1 2 null null null ");
}

public static boolean inForLoop() {
Expand Down

0 comments on commit f5c3682

Please sign in to comment.