1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-18 17:05:06 +00:00
serenity/Libraries/LibJS/Tests/parser-unary-associativity.js
Andreas Kling 14de45296e LibJS: Fix broken parsing of !o.a
Unary expressions parsing now respects precedence and associativity of
operators. This patch also makes `typeof` left-associative which was
an oversight.

Thanks to Conrad for helping me work this out. :^)
2020-03-28 11:51:44 +01:00

18 lines
358 B
JavaScript

function assert(x) { if (!x) throw 1; }
try {
var o = {};
o.a = 1;
assert(o.a === 1);
assert(!o.a === false);
assert(!o.a === !(o.a));
assert(~o.a === ~(o.a));
assert((typeof "x" === "string") === true);
assert(!(typeof "x" === "string") === false);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}