Skip to content

Commit

Permalink
test: additional test cases for operator precedence parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
yazaldefilimone committed Feb 25, 2024
1 parent b34d90a commit be95031
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/parser/tests/operactor-precedence-parsing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,20 @@ describe("Parser", () => {
input: "3 + 4 * 5 == 3 * 1 + 4 * 5",
expected: "((3 + (4 * 5)) == ((3 * 1) + (4 * 5)))",
},
{
input: "a * [1, 2, 3, 4][b * c] * d",
expected: "((a * ([1, 2, 3, 4][(b * c)])) * d)",
},
{
input: "add(a * b[2], b[1], 2 * [1, 2][1]);",
expected: "add((a * (b[2])),(b[1]),(2 * ([1, 2][1])))",
},
];
tests.forEach((tt) => {
const { program } = makeSut(tt.input);
const { program } = makeSut(tt.input, {
isLogError: true,
toString: false,
});
expect(program.toString()).toBe(tt.expected);
});
});
Expand Down

0 comments on commit be95031

Please sign in to comment.