diff options
| author | EuAndreh <eu@euandre.org> | 2025-07-15 14:44:18 -0300 |
|---|---|---|
| committer | EuAndreh <eu@euandre.org> | 2025-07-15 14:44:18 -0300 |
| commit | 91d910ac27dee0acfb4ae919aaffbdfe0ff2eed6 (patch) | |
| tree | 2b89eac5d4ad12f9c2c36191fb46de9b13bed5c2 /tests/paca.mjs | |
| parent | tests/paca.mjs (test_compileNFA): Add test case for empty regex (diff) | |
| download | paca-91d910ac27dee0acfb4ae919aaffbdfe0ff2eed6.tar.gz paca-91d910ac27dee0acfb4ae919aaffbdfe0ff2eed6.tar.xz | |
tests/paca.mjs (test_shouldConcat): Also hoist import, definition and position in runTests
Diffstat (limited to '')
| -rw-r--r-- | tests/paca.mjs | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/tests/paca.mjs b/tests/paca.mjs index 6fcae53..14a6cf2 100644 --- a/tests/paca.mjs +++ b/tests/paca.mjs @@ -4,12 +4,12 @@ import { SyntaxError, ValueError, ConcatStep, + shouldConcat, numFromDigits, escapingStateStep, rangeStateStep, classStateStep, TRANSITION_FNS, - shouldConcat, isOperator, tokenizeRegexStep, tokenizeRegexFn, @@ -48,6 +48,39 @@ import { +const test_shouldConcat = t => { + t.start("shouldConcat()"); + + t.testing("do concat literal chars", () => { + t.assertEq(shouldConcat("a", "b"), true); + }); + + t.testing("but not when they're the last one", () => { + t.assertEq(shouldConcat("a", undefined), false); + t.assertEq(shouldConcat("b", undefined), false); + }); + + t.testing("do not concat when starting a parens group", () => { + t.assertEq(shouldConcat("(", "a"), false); + t.assertEq(shouldConcat("(", "b"), false); + }); + + t.testing("do not concat when starting a union", () => { + t.assertEq(shouldConcat("|", "a"), false); + t.assertEq(shouldConcat("|", "b"), false); + }); + + t.testing("do not concat when next is special", () => { + t.assertEq(shouldConcat("a", "*"), false); + t.assertEq(shouldConcat("a", "|"), false); + t.assertEq(shouldConcat("a", ")"), false); + }); + + t.testing("only consider the `next` char", () => { + t.assertEq(shouldConcat(null, "\\"), true); + }); +}; + const test_numFromDigits = t => { t.start("numFromDigits()"); @@ -519,39 +552,6 @@ const test_TRANSITION_FNS = t => { }); }; -const test_shouldConcat = t => { - t.start("shouldConcat()"); - - t.testing("do concat literal chars", () => { - t.assertEq(shouldConcat("a", "b"), true); - }); - - t.testing("but not when they're the last one", () => { - t.assertEq(shouldConcat("a", undefined), false); - t.assertEq(shouldConcat("b", undefined), false); - }); - - t.testing("do not concat when starting a parens group", () => { - t.assertEq(shouldConcat("(", "a"), false); - t.assertEq(shouldConcat("(", "b"), false); - }); - - t.testing("do not concat when starting a union", () => { - t.assertEq(shouldConcat("|", "a"), false); - t.assertEq(shouldConcat("|", "b"), false); - }); - - t.testing("do not concat when next is special", () => { - t.assertEq(shouldConcat("a", "*"), false); - t.assertEq(shouldConcat("a", "|"), false); - t.assertEq(shouldConcat("a", ")"), false); - }); - - t.testing("only consider the `next` char", () => { - t.assertEq(shouldConcat(null, "\\"), true); - }); -}; - const test_isOperator = t => { t.start("isOperator()"); @@ -2830,12 +2830,12 @@ const test_compile = t => { runTests([ + test_shouldConcat, test_numFromDigits, test_escapingStateStep, test_rangeStateStep, test_classStateStep, test_TRANSITION_FNS, - test_shouldConcat, test_isOperator, test_tokenizeRegexStep, test_tokenizeRegexFn, |
