From 0622181d1f883e787222bdbbbbd5f7ebf58c7a5a Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 3 Apr 2020 12:14:28 +0200 Subject: LibJS: Implement ConditionalExpression (ternary "?:" operator) --- Libraries/LibJS/Tests/ternary-basic.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Libraries/LibJS/Tests/ternary-basic.js (limited to 'Libraries/LibJS/Tests/ternary-basic.js') 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); +} -- cgit v1.2.3