diff --git a/src/test/java/com/hubspot/jinjava/tree/TreeParserTest.java b/src/test/java/com/hubspot/jinjava/tree/TreeParserTest.java index b4279523a..27e995e22 100644 --- a/src/test/java/com/hubspot/jinjava/tree/TreeParserTest.java +++ b/src/test/java/com/hubspot/jinjava/tree/TreeParserTest.java @@ -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; @@ -361,6 +362,20 @@ public void itDoesNotMergeAdjacentTextNodesWhenLegacyOverrideIsApplied() { assertThat(interpreter.render(overriddenTree)).isEqualTo("A\nB"); } + @Test + public void itDoesNotAddErrorWhenParseErrorsAreIgnored() { + try ( + TemporaryValueClosable 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(