summaryrefslogtreecommitdiff
path: root/tests/paca.mjs
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2025-07-11 13:08:04 -0300
committerEuAndreh <eu@euandre.org>2025-07-11 13:08:04 -0300
commit2a027c9bb4523f99344a87fca0ca60cc49a05f3c (patch)
treea34dbf75db4d051a3e7e174524be40b37f0f2ab6 /tests/paca.mjs
parentsrc/paca.mjs: Remove unused repeat(3) import (diff)
downloadpaca-2a027c9bb4523f99344a87fca0ca60cc49a05f3c.tar.gz
paca-2a027c9bb4523f99344a87fca0ca60cc49a05f3c.tar.xz
tests/paca.mjs (test_tokenizeRegexStep): Compute `char` and `index`
Diffstat (limited to '')
-rw-r--r--tests/paca.mjs27
1 files changed, 7 insertions, 20 deletions
diff --git a/tests/paca.mjs b/tests/paca.mjs
index 7c807fe..0724bf2 100644
--- a/tests/paca.mjs
+++ b/tests/paca.mjs
@@ -93,10 +93,9 @@ const test_tokenizeRegexStep = t => {
t.start("tokenizeRegexStep()");
t.testing("when escaping we get whatever the char is", () => {
- const stepFn = tokenizeRegexStep("ab|(cd)*");
+ const regex = "ab|(cd)*"
+ const stepFn = tokenizeRegexStep(regex);
const steps = [{
- char: "a",
- index: 0,
in: {
out: [],
state: ConcatStep.ESCAPING,
@@ -106,8 +105,6 @@ const test_tokenizeRegexStep = t => {
state: ConcatStep.ACCEPTING,
},
}, {
- char: "b",
- index: 1,
in: {
out: [],
state: ConcatStep.ESCAPING,
@@ -117,8 +114,6 @@ const test_tokenizeRegexStep = t => {
state: ConcatStep.ACCEPTING,
},
}, {
- char: "|",
- index: 2,
in: {
out: [],
state: ConcatStep.ESCAPING,
@@ -128,8 +123,6 @@ const test_tokenizeRegexStep = t => {
state: ConcatStep.ACCEPTING,
},
}, {
- char: "(",
- index: 3,
in: {
out: [],
state: ConcatStep.ESCAPING,
@@ -139,19 +132,15 @@ const test_tokenizeRegexStep = t => {
state: ConcatStep.ACCEPTING,
},
}, {
- char: "c",
- index: 4,
in: {
out: [],
state: ConcatStep.ESCAPING,
},
out: {
- out: ["c", {operator: "concat"}],
+ out: ["c", { operator: "concat" }],
state: ConcatStep.ACCEPTING,
},
}, {
- char: "d",
- index: 5,
in: {
out: [],
state: ConcatStep.ESCAPING,
@@ -161,8 +150,6 @@ const test_tokenizeRegexStep = t => {
state: ConcatStep.ACCEPTING,
},
}, {
- char: ")",
- index: 6,
in: {
out: [],
state: ConcatStep.ESCAPING,
@@ -172,8 +159,6 @@ const test_tokenizeRegexStep = t => {
state: ConcatStep.ACCEPTING,
},
}, {
- char: "*",
- index: 7,
in: {
out: [],
state: ConcatStep.ESCAPING,
@@ -183,9 +168,11 @@ const test_tokenizeRegexStep = t => {
state: ConcatStep.ACCEPTING,
},
}];
- for (const step of steps) {
+ for (const i in regex) {
+ const step = steps[i];
+ const char = regex[i];
t.assertEq(
- stepFn(step.in, step.char, step.index),
+ stepFn(step.in, char, Number(i)),
step.out,
);
}