diff options
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); +} |