aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2019-05-17 01:28:18 +0800
committerGitHub <noreply@github.com>2019-05-17 01:28:18 +0800
commita246195412e2864993f00e32aade193234d0aa68 (patch)
tree59dc88b25ec09429238529c5e69ab7ddd2ff4fd7 /test
parent8939a36bc73953920b175da51d65a27f016a5538 (diff)
downloadtracifyjs-a246195412e2864993f00e32aade193234d0aa68.tar.gz
tracifyjs-a246195412e2864993f00e32aade193234d0aa68.zip
enhance `unsafe` `comparisons` (#3419)
Diffstat (limited to 'test')
-rw-r--r--test/compress/comparisons.js51
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: {