1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:18:11 +00:00

LibJS: Implement ConditionalExpression (ternary "?:" operator)

This commit is contained in:
Andreas Kling 2020-04-03 12:14:28 +02:00
parent 522d8c5d71
commit 0622181d1f
5 changed files with 83 additions and 1 deletions

View file

@ -0,0 +1,19 @@
function assert(x) { if (!x) throw 1; }
try {
var x = 1;
assert(x === 1 ? true : false);
assert(x ? x : 0);
assert(1 < 2 ? (true) : (false));
var o = {};
o.f = true;
assert(o.f ? true : false);
assert(1 ? o.f : null);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}