diff options
| author | EuAndreh <eu@euandre.org> | 2025-07-13 19:58:06 -0300 |
|---|---|---|
| committer | EuAndreh <eu@euandre.org> | 2025-07-13 19:58:10 -0300 |
| commit | a4873cddb17d24d9a2d10b1aa704cedc021350f9 (patch) | |
| tree | 4d0409b0281656a595d858fb82fbebe547d65ca6 /tests/paca.mjs | |
| parent | Revert "src/paca.mjs: Temporarily export internal functions" (diff) | |
| download | paca-a4873cddb17d24d9a2d10b1aa704cedc021350f9.tar.gz paca-a4873cddb17d24d9a2d10b1aa704cedc021350f9.tar.xz | |
Add simple test for TRANSITION_FNS
* src/paca.mjs (TRANSITION_FNS): Add trailing underscore to ignored
arguments, even though it breaks the name of the `_state` and
`context` destructuring arguments.
* tests/paca.mjs (test_TRANSITION_FNS): Add new test function with a
single case for each transition character. Since these transitions
are unconditional and contain no logic, this single sample test is
enough to cover for all of its behaviour.
Diffstat (limited to 'tests/paca.mjs')
| -rw-r--r-- | tests/paca.mjs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/paca.mjs b/tests/paca.mjs index 0ba2d61..b259968 100644 --- a/tests/paca.mjs +++ b/tests/paca.mjs @@ -3,6 +3,7 @@ import { explode, reduced, reductions, runTests } from "sjs"; import { SyntaxError, ConcatStep, + TRANSITION_FNS, shouldConcat, isOperator, numFromDigits, @@ -43,6 +44,37 @@ import { +const test_TRANSITION_FNS = t => { + t.start("TRANSITION_FNS"); + + t.testing("\"\\\\\" depends on `out` and `context`", () => { + t.assertEq( + TRANSITION_FNS["\\"]( + { out: 1, context: 2 }, + null, + null, + null, + ), + { out: 1, context: 2, state: "escaping" }, + ); + }); + + t.testing("\"{\" only depends on `out`", () => { + t.assertEq( + TRANSITION_FNS["{"]({ out: "" }, null, null, null), + { + out: "", + state: "range", + context: { + from: [], + to: [], + where: "from", + }, + }, + ); + }); +}; + const test_shouldConcat = t => { t.start("shouldConcat()"); @@ -2351,6 +2383,7 @@ const test_compile = t => { runTests([ + test_TRANSITION_FNS, test_shouldConcat, test_isOperator, test_numFromDigits, |
