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:
parent
522d8c5d71
commit
0622181d1f
5 changed files with 83 additions and 1 deletions
19
Libraries/LibJS/Tests/ternary-basic.js
Normal file
19
Libraries/LibJS/Tests/ternary-basic.js
Normal 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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue