diff options
| author | EuAndreh <eu@euandre.org> | 2025-07-11 16:13:37 -0300 |
|---|---|---|
| committer | EuAndreh <eu@euandre.org> | 2025-07-11 16:13:37 -0300 |
| commit | f45e9041a777f0dbf2a2c6e130f198c0d36682c8 (patch) | |
| tree | f25dec6f6bcd05544b72967d7610ef9de3629778 /tests | |
| parent | src/paca.mjs: Remove calls to arr.concat([]) with unneeded wrapping singleton... (diff) | |
| download | paca-f45e9041a777f0dbf2a2c6e130f198c0d36682c8.tar.gz paca-f45e9041a777f0dbf2a2c6e130f198c0d36682c8.tar.xz | |
tests/paca.mjs: Add tests for numFromDigits()
Diffstat (limited to '')
| -rw-r--r-- | tests/paca.mjs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/paca.mjs b/tests/paca.mjs index 4f085e4..0c69547 100644 --- a/tests/paca.mjs +++ b/tests/paca.mjs @@ -5,6 +5,7 @@ import { ConcatStep, shouldConcat, isOperator, + numFromDigits, tokenizeRegexStep, tokenizeRegexFn, tokenizeRegex, @@ -89,6 +90,21 @@ const test_isOperator = t => { }); }; +const test_numFromDigits = t => { + t.start("numFromDigits()"); + + t.testing("-1 on empty array", () => { + t.assertEq(numFromDigits([]), -1); + }); + + t.testing("the number from the digits", () => { + t.assertEq(numFromDigits([ "0" ]), 0); + t.assertEq(numFromDigits([ "1" ]), 1); + t.assertEq(numFromDigits([ "0", "1" ]), 1); + t.assertEq(numFromDigits([ "1", "2", "3" ]), 123); + }); +}; + const test_tokenizeRegexStep = t => { t.start("tokenizeRegexStep()"); @@ -2719,6 +2735,7 @@ const test_compile = t => { runTests([ test_shouldConcat, test_isOperator, + test_numFromDigits, test_tokenizeRegexStep, test_tokenizeRegexFn, test_tokenizeRegex, |
