mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[IMP] compiler: add support for binary operators
This commit is contained in:
@@ -86,9 +86,8 @@ const STATIC_TOKEN_MAP: { [key: string]: TKind } = Object.assign(Object.create(n
|
||||
|
||||
// note that the space after typeof is relevant. It makes sure that the formatted
|
||||
// expression has a space after typeof. Currently we don't support delete and void
|
||||
const OPERATORS = "...,.,===,==,+,!==,!=,!,||,&&,>=,>,<=,<,?,-,*,/,%,typeof ,=>,=,;,in ,new ".split(
|
||||
","
|
||||
);
|
||||
const OPERATORS =
|
||||
"...,.,===,==,+,!==,!=,!,||,&&,>=,>,<=,<,?,-,*,/,%,typeof ,=>,=,;,in ,new ,|,&,^,~".split(",");
|
||||
|
||||
type Tokenizer = (expr: string) => Token | false;
|
||||
|
||||
|
||||
@@ -221,4 +221,11 @@ describe("expression evaluation", () => {
|
||||
expect(compileExpr("a.c in b")).toBe("ctx['a'].c in ctx['b']");
|
||||
expect(compileExpr("typeof val")).toBe("typeof ctx['val']");
|
||||
});
|
||||
|
||||
test("binary operators", () => {
|
||||
expect(compileExpr("1 | 1")).toBe("1|1");
|
||||
expect(compileExpr("1 & 1")).toBe("1&1");
|
||||
expect(compileExpr("1 ^ 1")).toBe("1^1");
|
||||
expect(compileExpr("~1")).toBe("~1");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user