mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-28 15:28:55 +00:00
The same expression is not allowed to contain both the logical && and || operators, and the coalescing ?? operator. This patch changes how "forbidden" tokens are handled, using a finite set instead of an Vector. This supports much more efficient merging of the forbidden tokens when propagating forward, and allowing the return of forbidden tokens to parent contexts.
28 lines
1.2 KiB
JavaScript
28 lines
1.2 KiB
JavaScript
test("mixing coalescing and logical operators isn't allowed", () => {
|
|
expect("if (0) a ?? b || c").not.toEval();
|
|
expect("if (0) a ?? b && c").not.toEval();
|
|
expect("if (0) a ?? b * c || d").not.toEval();
|
|
expect("if (0) a ?? b * c && d").not.toEval();
|
|
expect("if (0) a && b ?? c").not.toEval();
|
|
expect("if (0) a || b ?? c").not.toEval();
|
|
expect("if (0) a && b * c ?? d").not.toEval();
|
|
expect("if (0) a || b * c ?? d").not.toEval();
|
|
});
|
|
|
|
test("mixing coalescing and logical operators with parens", () => {
|
|
expect("if (0) a ?? (b || c)").toEval();
|
|
expect("if (0) (a ?? b) && c").toEval();
|
|
expect("if (0) a ?? (b * c || d)").toEval();
|
|
expect("if (0) (a ?? b * c) && d").toEval();
|
|
expect("if (0) a && (b ?? c)").toEval();
|
|
expect("if (0) (a || b) ?? c").toEval();
|
|
expect("if (0) a && (b * c) ?? d").not.toEval();
|
|
expect("if (0) a || (b * c) ?? d").not.toEval();
|
|
});
|
|
|
|
test("mixing coalescing and logical operators when 'in' isn't allowed", () => {
|
|
expect("for (a ?? b || c in a; false;);").not.toEval();
|
|
expect("for (a ?? b && c in a; false;);").not.toEval();
|
|
expect("for (a || b ?? c in a; false;);").not.toEval();
|
|
expect("for (a && b ?? c in a; false;);").not.toEval();
|
|
});
|