Skip to content

Commit

Permalink
Test that errors aren't added when parse errors are ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
jasmith-hs committed Sep 3, 2024
1 parent 72d938f commit 09cbfba
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/test/java/com/hubspot/jinjava/tree/TreeParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.hubspot.jinjava.Jinjava;
import com.hubspot.jinjava.JinjavaConfig;
import com.hubspot.jinjava.LegacyOverrides;
import com.hubspot.jinjava.interpret.Context.TemporaryValueClosable;
import com.hubspot.jinjava.interpret.TemplateError.ErrorType;
import java.nio.charset.StandardCharsets;
import org.junit.Test;
Expand Down Expand Up @@ -361,6 +362,20 @@ public void itDoesNotMergeAdjacentTextNodesWhenLegacyOverrideIsApplied() {
assertThat(interpreter.render(overriddenTree)).isEqualTo("A\nB");
}

@Test
public void itDoesNotAddErrorWhenParseErrorsAreIgnored() {
try (
TemporaryValueClosable<Boolean> c = interpreter.getContext().withIgnoreParseErrors()
) {
String expression = "{% if ";
final Node tree = new TreeParser(interpreter, expression).buildTree();
assertThat(tree.getChildren()).hasSize(1);
assertThat(tree.getChildren().get(0).toTreeString())
.isEqualToIgnoringWhitespace(" {~ {% if ~}");
}
assertThat(interpreter.getErrors()).isEmpty();
}

Node parse(String fixture) {
try {
return new TreeParser(
Expand Down

0 comments on commit 09cbfba

Please sign in to comment.