summaryrefslogtreecommitdiff
path: root/tests/typ/compiler/backtracking.typ
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2024-02-21 09:38:47 +0100
committerGitHub <noreply@github.com>2024-02-21 08:38:47 +0000
commitbe49935753f0e37ae8e04fb53111e6f116c63f47 (patch)
tree0fbc875af61bdedb0d0de42b8809bdb4aae8586f /tests/typ/compiler/backtracking.typ
parentb2e509d472634fd5dd43514dbde24eedab566abd (diff)
Destructuring improvements (#3463)
Diffstat (limited to 'tests/typ/compiler/backtracking.typ')
-rw-r--r--tests/typ/compiler/backtracking.typ33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/typ/compiler/backtracking.typ b/tests/typ/compiler/backtracking.typ
new file mode 100644
index 00000000..9c3ab8ec
--- /dev/null
+++ b/tests/typ/compiler/backtracking.typ
@@ -0,0 +1,33 @@
+// Ensure that parser backtracking doesn't lead to exponential time consumption.
+// If this regresses, the test suite will not terminate, which is a bit
+// unfortunate compared to a good error, but at least we know something is up.
+//
+// Ref: false
+
+---
+#{
+ let s = "(x: 1) => x"
+ let pat = "(x: {}) => 1 + x()"
+ for _ in range(50) {
+ s = pat.replace("{}", s)
+ }
+ test(eval(s)(), 51)
+}
+
+---
+#{
+ let s = "(x) = 1"
+ let pat = "(x: {_}) = 1"
+ for _ in range(100) {
+ s = pat.replace("_", s)
+ }
+ // Error: 8-9 cannot destructure integer
+ eval(s)
+}
+
+---
+// Test whitespace after memoized part.
+#( (x: () => 1 ) => 1 )
+// -------
+// This is memoized and we want to ensure that whitespace after this
+// is handled correctly.