summaryrefslogtreecommitdiff
path: root/tests/paca.mjs
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2025-07-20 09:54:38 -0300
committerEuAndreh <eu@euandre.org>2025-07-20 09:54:38 -0300
commitd16864711631747538c156a90eda9878588c1cd2 (patch)
tree9bee02b0c9f1d2d668d9cfeb210509555f179389 /tests/paca.mjs
parentsrc/paca.mjs: Support returning multiple options from `performTransition()` (diff)
downloadpaca-d16864711631747538c156a90eda9878588c1cd2.tar.gz
paca-d16864711631747538c156a90eda9878588c1cd2.tar.xz
src/paca.mjs: Rename buildDFA -> toDFA
Diffstat (limited to '')
-rw-r--r--tests/paca.mjs30
1 files changed, 15 insertions, 15 deletions
diff --git a/tests/paca.mjs b/tests/paca.mjs
index 6913b9e..3469129 100644
--- a/tests/paca.mjs
+++ b/tests/paca.mjs
@@ -50,8 +50,8 @@ import {
unNodeID,
collectTransitions,
computePending,
- buildDFANodes,
- buildDFA,
+ toDFANodes,
+ toDFA,
searchDFAStep,
searchDFAFn,
searchDFA,
@@ -3121,11 +3121,11 @@ const test_computePending = t => {
});
};
-const test_buildDFANodes = t => {
- t.start("buildDFANodes()");
+const test_toDFANodes = t => {
+ t.start("toDFANodes()");
t.testing("empty values", () => {
- t.assertEq(buildDFANodes(null, null, [], "RET"), "RET");
+ t.assertEq(toDFANodes(null, null, [], "RET"), "RET");
});
t.testing("ignore states that were already built", () => {
@@ -3133,7 +3133,7 @@ const test_buildDFANodes = t => {
"1-2-3": true,
};
const states = [[1, 2, 3], [3, 2, 1]];
- t.assertEq(buildDFANodes(null, null, states, nodes), nodes);
+ t.assertEq(toDFANodes(null, null, states, nodes), nodes);
});
t.testing("recursively build the DFA", () => {
@@ -3181,14 +3181,14 @@ const test_buildDFANodes = t => {
},
};
t.assertEq(
- buildDFANodes(end, nfaNodes, pending, dfaNodes),
+ toDFANodes(end, nfaNodes, pending, dfaNodes),
expected,
);
});
};
-const test_buildDFA = t => {
- t.start("buildDFA()");
+const test_toDFA = t => {
+ t.start("toDFA()");
t.testing("minimal NFA", () => {
const nfa = {
@@ -3214,7 +3214,7 @@ const test_buildDFA = t => {
},
},
};
- t.assertEq(buildDFA(nfa), expected);
+ t.assertEq(toDFA(nfa), expected);
});
t.testing("sample regex NFA", () => {
@@ -3282,7 +3282,7 @@ const test_buildDFA = t => {
},
};
t.assertEq(nfa, compileNFA("(a|b)*c"));
- t.assertEq(buildDFA(nfa), expected);
+ t.assertEq(toDFA(nfa), expected);
});
};
@@ -3335,7 +3335,7 @@ const test_searchDFAFn = t => {
t.testing("on composed sample regex", () => {
const regex = "(a|b)*c";
- const dfa = buildDFA(
+ const dfa = toDFA(
buildNFA(toPostfix(tokenizeRegex(explode(regex)))),
);
t.assertEq(searchDFAFn(dfa, "a"), "1-3-9");
@@ -3354,7 +3354,7 @@ const test_searchDFA = t => {
t.testing("on composed sample regex", () => {
const regex = "(a|b)*c";
- const dfa = buildDFA(
+ const dfa = toDFA(
buildNFA(toPostfix(tokenizeRegex(explode(regex)))),
);
t.assertEq(searchDFA(dfa, "a"), false);
@@ -3663,8 +3663,8 @@ runTests([
test_unNodeID,
test_collectTransitions,
test_computePending,
- test_buildDFANodes,
- test_buildDFA,
+ test_toDFANodes,
+ test_toDFA,
test_searchDFAStep,
test_searchDFAFn,
test_searchDFA,