Skip to content

Commit

Permalink
test(evaluator): ensure return an error when no suporte operator in s…
Browse files Browse the repository at this point in the history
…tring
  • Loading branch information
yazaldefilimone committed Aug 24, 2023
1 parent e76b34d commit ef8efba
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/evaluator/tests/string.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,52 @@ describe("Evaluator", () => {
expect(evaluated?.inspect()).toMatch(tt.expected);
});
});

it("should return error when no suporte operator with string", () => {
const tests = [
{
input: `"Hello" - "World" `,
expected: unknownOperatorError("STRING - STRING"),
},
{
input: `"Hello" * "World"`,
expected: unknownOperatorError("STRING * STRING"),
},
{
input: `"Hello" / "World"`,
expected: unknownOperatorError("STRING / STRING"),
},
{
input: `"Hello" > "World"`,
expected: unknownOperatorError("STRING > STRING"),
},
{
input: `"Hello" < "World"`,
expected: unknownOperatorError("STRING < STRING"),
},
{
input: `"Hello" == "World"`,
expected: unknownOperatorError("STRING == STRING"),
},
{
input: `"Hello" != "World"`,
expected: unknownOperatorError("STRING != STRING"),
},
// TODO:
// {
// input: `"Hello" >= "World"`,
// expected: unknownOperatorError("STRING >= STRING"),
// },
// {
// input: `"Hello" <= "World"`,
// expected: unknownOperatorError("STRING <= STRING"),
// },
];
tests.forEach((tt) => {
const evaluated = makeSut(tt.input);
expect(evaluated).toBeDefined();
expect(evaluated?.inspect()).toMatch(tt.expected.inspect());
});
});
});
});

0 comments on commit ef8efba

Please sign in to comment.