Skip to content

Commit 420513a

Browse files
committed
Allow platform-specific parser depth guard
1 parent ebb0c63 commit 420513a

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

src/Scriban.Tests/TestParser.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -938,15 +938,10 @@ public void ExpressionDepthLimitStopsDeepNestedExpressionsBeforeStackOverflow(st
938938
var template = Template.Parse($"{{{{ {expression} }}}}");
939939

940940
Assert.True(template.HasErrors);
941-
if (expressionKind == "objects")
942-
{
943-
StringAssert.Contains("The parser recursive depth limit was reached near a stack overflow", template.Messages[0].ToString());
944-
}
945-
else
946-
{
947-
StringAssert.Contains("The statement depth limit `250` was reached when parsing this statement", template.Messages[0].ToString());
948-
949-
}
941+
// Available stack space varies by platform and test runner, so either safety guard may stop parsing first.
942+
Assert.That(template.Messages[0].ToString(),
943+
Does.Contain("The statement depth limit `250` was reached when parsing this statement")
944+
.Or.Contain("The parser recursive depth limit was reached near a stack overflow"));
950945
}
951946

952947
[Test]

0 commit comments

Comments
 (0)