Skip to content

Commit

Permalink
fix: detect some more tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
arlac77 committed Jun 22, 2023
1 parent b39a820 commit 0f705b3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/attribute.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ export function* tokens(string) {
break;
}

case ".":
case "+":
case "-":
case ".":
case "*":
case "/":
case "(":
case ")":
case "[":
Expand Down
13 changes: 12 additions & 1 deletion tests/attribute-ava.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ import {
optionJSON,
MultiGroupProvider
} from "repository-provider";
import { tokens } from "../src/attribute.mjs";

function tt(t, source, expected) {
t.deepEqual(expected, [...tokens(source)]);
}

tt.title = (providedTitle = "", source, expected) =>
`tokenize ${providedTitle}${source} -> ${expected.join(" ")}`.trim();

test(tt, "a1 .b.c[3 + 4 ]", ["a1", ".", "b", ".", "c", "[", "3", "+", "4", "]"]);
test(tt, "=<=>=!=+-*/", ["=", "<=", ">=", "!=", "+", "-", "*", "/"]);

function gat(t, object, key, expected) {
const value = getAttribute(object, key);
Expand Down Expand Up @@ -198,6 +209,6 @@ test(
{
id: 1,
isAdmin: false,
name: "a",
name: "a"
}
);

0 comments on commit 0f705b3

Please sign in to comment.