diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2019-05-17 01:28:18 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-17 01:28:18 +0800 |
commit | a246195412e2864993f00e32aade193234d0aa68 (patch) | |
tree | 59dc88b25ec09429238529c5e69ab7ddd2ff4fd7 /test | |
parent | 8939a36bc73953920b175da51d65a27f016a5538 (diff) | |
download | tracifyjs-a246195412e2864993f00e32aade193234d0aa68.tar.gz tracifyjs-a246195412e2864993f00e32aade193234d0aa68.zip |
enhance `unsafe` `comparisons` (#3419)
Diffstat (limited to 'test')
-rw-r--r-- | test/compress/comparisons.js | 51 |
1 files changed, 47 insertions, 4 deletions
diff --git a/test/compress/comparisons.js b/test/compress/comparisons.js index 461f415c..bb140fd8 100644 --- a/test/compress/comparisons.js +++ b/test/compress/comparisons.js @@ -373,12 +373,55 @@ unsafe_indexOf: { unsafe: true, } input: { - if (Object.keys({ foo: 42 }).indexOf("foo") >= 0) console.log("PASS"); + var a = Object.keys({ foo: 42 }); + if (a.indexOf("bar") < 0) console.log("PASS"); + if (0 > a.indexOf("bar")) console.log("PASS"); + if (a.indexOf("foo") >= 0) console.log("PASS"); + if (0 <= a.indexOf("foo")) console.log("PASS"); + if (a.indexOf("foo") > -1) console.log("PASS"); + if (-1 < a.indexOf("foo")) console.log("PASS"); + if (a.indexOf("bar") == -1) console.log("PASS"); + if (-1 == a.indexOf("bar")) console.log("PASS"); + if (a.indexOf("bar") === -1) console.log("PASS"); + if (-1 === a.indexOf("bar")) console.log("PASS"); + if (a.indexOf("foo") != -1) console.log("PASS"); + if (-1 != a.indexOf("foo")) console.log("PASS"); + if (a.indexOf("foo") !== -1) console.log("PASS"); + if (-1 !== a.indexOf("foo")) console.log("PASS"); } expect: { - if (~Object.keys({ foo: 42 }).indexOf("foo")) console.log("PASS"); - } - expect_stdout: "PASS" + var a = Object.keys({ foo: 42 }); + if (!~a.indexOf("bar")) console.log("PASS"); + if (!~a.indexOf("bar")) console.log("PASS"); + if (~a.indexOf("foo")) console.log("PASS"); + if (~a.indexOf("foo")) console.log("PASS"); + if (~a.indexOf("foo")) console.log("PASS"); + if (~a.indexOf("foo")) console.log("PASS"); + if (!~a.indexOf("bar")) console.log("PASS"); + if (!~a.indexOf("bar")) console.log("PASS"); + if (!~a.indexOf("bar")) console.log("PASS"); + if (!~a.indexOf("bar")) console.log("PASS"); + if (~a.indexOf("foo")) console.log("PASS"); + if (~a.indexOf("foo")) console.log("PASS"); + if (~a.indexOf("foo")) console.log("PASS"); + if (~a.indexOf("foo")) console.log("PASS"); + } + expect_stdout: [ + "PASS", + "PASS", + "PASS", + "PASS", + "PASS", + "PASS", + "PASS", + "PASS", + "PASS", + "PASS", + "PASS", + "PASS", + "PASS", + "PASS", + ] } issue_3413: { |