diff options
| author | EuAndreh <eu@euandre.org> | 2025-07-15 14:25:45 -0300 |
|---|---|---|
| committer | EuAndreh <eu@euandre.org> | 2025-07-15 14:25:45 -0300 |
| commit | 73ae38539fdd5ae6e1f353300c2448f9b95bfe2a (patch) | |
| tree | 2900cc5214d9e453d0acbf05c686d6a99c9717d7 /tests/paca.mjs | |
| parent | Use `shouldConcat()` in decision of `escapingStateSte()` (diff) | |
| download | paca-73ae38539fdd5ae6e1f353300c2448f9b95bfe2a.tar.gz paca-73ae38539fdd5ae6e1f353300c2448f9b95bfe2a.tar.xz | |
tests/paca.mjs (test_escapingStateStep): Add tests for `escapingStateStep()`
Diffstat (limited to 'tests/paca.mjs')
| -rw-r--r-- | tests/paca.mjs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/paca.mjs b/tests/paca.mjs index 2c44f9e..539abf6 100644 --- a/tests/paca.mjs +++ b/tests/paca.mjs @@ -5,6 +5,7 @@ import { ValueError, ConcatStep, numFromDigits, + escapingStateStep, rangeStateStep, classStateStep, TRANSITION_FNS, @@ -62,6 +63,40 @@ const test_numFromDigits = t => { }); }; +const test_escapingStateStep = t => { + t.start("escapingStateStep()"); + + t.testing("add a concat when applicable", () => { + const given = escapingStateStep( + { out: [ 1, 2, 3 ] }, + "a", + null, + "b", + ); + const expected = { + out: [ 1, 2, 3, "a", { operator: "concat" } ], + state: "accepting", + context: undefined, + }; + t.assertEq(given, expected); + }); + + t.testing("without a concat when not applicable", () => { + const given = escapingStateStep( + { out: [ 1, 2, 3 ] }, + "a", + null, + ")", + ); + const expected = { + out: [ 1, 2, 3, "a" ], + state: "accepting", + context: undefined, + }; + t.assertEq(given, expected); + }); +}; + const test_rangeStateStep = t => { t.start("rangeStateStep()"); @@ -2782,6 +2817,7 @@ const test_compile = t => { runTests([ test_numFromDigits, + test_escapingStateStep, test_rangeStateStep, test_classStateStep, test_TRANSITION_FNS, |
