diff options
author | Andreas Kling <kling@serenityos.org> | 2020-04-03 12:14:28 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-03 12:15:14 +0200 |
commit | 0622181d1f883e787222bdbbbbd5f7ebf58c7a5a (patch) | |
tree | e23f767f8593954e03759e726d3205c1caec2f6a /Libraries/LibJS/Tests/ternary-basic.js | |
parent | 522d8c5d7190bb97916c04dd1bcf0a1d71403191 (diff) | |
download | serenity-0622181d1f883e787222bdbbbbd5f7ebf58c7a5a.zip |
LibJS: Implement ConditionalExpression (ternary "?:" operator)
Diffstat (limited to 'Libraries/LibJS/Tests/ternary-basic.js')
-rw-r--r-- | Libraries/LibJS/Tests/ternary-basic.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Libraries/LibJS/Tests/ternary-basic.js b/Libraries/LibJS/Tests/ternary-basic.js new file mode 100644 index 0000000000..62de660275 --- /dev/null +++ b/Libraries/LibJS/Tests/ternary-basic.js @@ -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); +} |