diff --git a/src/nodes/BinaryExpression.ts b/src/nodes/BinaryExpression.ts index ace467a..7cc3464 100644 --- a/src/nodes/BinaryExpression.ts +++ b/src/nodes/BinaryExpression.ts @@ -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; diff --git a/test/main.test.ts b/test/main.test.ts index 2bd0c03..2783b29 100644 --- a/test/main.test.ts +++ b/test/main.test.ts @@ -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', () => {