Skip to content

Commit

Permalink
feat: add ^ op
Browse files Browse the repository at this point in the history
  • Loading branch information
LuanRT committed Sep 22, 2022
1 parent 7c39017 commit faa1904
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/nodes/BinaryExpression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export default class BinaryExpression {
return left_node | right_node;
case '&':
return left_node & right_node;
case '^':
return left_node ^ right_node;
// Rational operators
case 'in':
return left_node in right_node;
Expand Down
15 changes: 14 additions & 1 deletion test/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,20 @@ describe('Jinter Tests', () => {
const jinter = new Jinter(code);
jinter.interpret();

expect(jinter.scope.get('result')).toBeUndefined();
const result = jinter.scope.get('result');
expect(result).toBeUndefined();
});

it('should support the "^" operator', () => {
const code = `
const result = 2 ^ 3;
`;

const jinter = new Jinter(code);
jinter.interpret();

const result = jinter.scope.get('result');
expect(result).toBe(1);
});

it('should define variables', () => {
Expand Down

0 comments on commit faa1904

Please sign in to comment.