mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 14:58:46 +00:00
41 lines
1.8 KiB
JavaScript
41 lines
1.8 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 in ternary expressions", () => {
|
|
expect("0 || 0 ? 0 : 0 ?? 0").toEval();
|
|
expect("0 ?? 0 ? 0 : 0 || 0").toEval();
|
|
expect("0 ? 0 || 0 : 0 ?? 0").toEval();
|
|
expect("0 ? 0 ?? 0 : 0 || 0").toEval();
|
|
expect("0 && 0 ? 0 ?? 0 : 0 || 0").toEval();
|
|
expect("0 ?? 0 ? 0 && 0 : 0 || 0").toEval();
|
|
expect("0 ?? 0 ? 0 || 0 : 0 && 0").toEval();
|
|
expect("0 || 0 ? 0 ?? 0 : 0 && 0").toEval();
|
|
expect("0 && 0 ? 0 || 0 : 0 ?? 0").toEval();
|
|
expect("0 || 0 ? 0 && 0 : 0 ?? 0").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();
|
|
});
|