summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/paca.mjs4
-rw-r--r--tests/paca.mjs33
2 files changed, 35 insertions, 2 deletions
diff --git a/src/paca.mjs b/src/paca.mjs
index e8ec542..c1bead1 100644
--- a/src/paca.mjs
+++ b/src/paca.mjs
@@ -107,12 +107,12 @@ const STATE_FNS = {
};
const TRANSITION_FNS = {
- "\\": ({ out, state, context }, char, index, next) => ({
+ "\\": ({ out, _state, context }, _char, _index, _next) => ({
out,
state: ConcatStep.ESCAPING,
context,
}),
- "{": ({ out, state, context }, char, index, next) => ({
+ "{": ({ out, _state, _context }, _char, _index, _next) => ({
out,
state: ConcatStep.RANGE,
context: {
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,