diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-09-12 09:29:13 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-09-12 09:29:13 +0100 |
| commit | dc49225425c2c07de0a6dc3529f2386c82a032b4 (patch) | |
| tree | 916a12e9c4fbfe7a40fd79ec6ef516b2f3e16d95 /test | |
| parent | 870603494b464c737b0a2200742370332142d516 (diff) | |
Avoid excessive backtracking when parsing unterminated strings
Diffstat (limited to 'test')
| -rw-r--r-- | test/styles/parser/tokeniser.tests.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/styles/parser/tokeniser.tests.js b/test/styles/parser/tokeniser.tests.js index 16f3847..04c25e0 100644 --- a/test/styles/parser/tokeniser.tests.js +++ b/test/styles/parser/tokeniser.tests.js @@ -31,10 +31,30 @@ test("strings are tokenised", function() { assertTokens("'Tristan'", [isToken("string", "Tristan")]); }); +test("escaped string terminators in strings are tokenised", function() { + assertTokens("'Tristan\\''", [isToken("string", "Tristan\\'")]); +}); + +test("escape sequences in strings are tokenised", function() { + assertTokens("'Tristan\\\\'", [isToken("string", "Tristan\\\\")]); +}); + test("unterminated strings are tokenised", function() { assertTokens("'Tristan", [isToken("unterminated-string", "Tristan")]); }); +test("unterminated strings ending with escaped string terminator are tokenised", function() { + assertTokens("'Tristan\\'", [isToken("unterminated-string", "Tristan\\'")]); +}); + +test("unterminated strings with unterminated escape are tokenised", function() { + assertTokens("'Tristan\\", [isToken("unterminated-string", "Tristan\\")]); +}); + +test("unterminated strings with many escape sequences do not cause excessive backtracking", function() { + assertTokens("'" + "\\a".repeat(50), [isToken("unterminated-string", "\\a".repeat(50))]); +}); + test("arrows are tokenised", function() { assertTokens("=>", [isToken("arrow")]); }); |
