diff options
| -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, |
