summaryrefslogtreecommitdiff
path: root/tests/paca.mjs
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2025-07-15 14:25:45 -0300
committerEuAndreh <eu@euandre.org>2025-07-15 14:25:45 -0300
commit73ae38539fdd5ae6e1f353300c2448f9b95bfe2a (patch)
tree2900cc5214d9e453d0acbf05c686d6a99c9717d7 /tests/paca.mjs
parentUse `shouldConcat()` in decision of `escapingStateSte()` (diff)
downloadpaca-73ae38539fdd5ae6e1f353300c2448f9b95bfe2a.tar.gz
paca-73ae38539fdd5ae6e1f353300c2448f9b95bfe2a.tar.xz
tests/paca.mjs (test_escapingStateStep): Add tests for `escapingStateStep()`
Diffstat (limited to '')
-rw-r--r--tests/paca.mjs36
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,