aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-06-07 22:23:23 +0100
committerGitHub <noreply@github.com>2020-06-08 05:23:23 +0800
commitdf3bb8028a7cd8a69a3c76090d12f808ca7abc3b (patch)
tree210770477d209324562885e6777d3d150ce27035 /test/compress
parent28b7b15da19a2a081ab768f8315ce39db7c52b63 (diff)
downloadtracifyjs-df3bb8028a7cd8a69a3c76090d12f808ca7abc3b.tar.gz
tracifyjs-df3bb8028a7cd8a69a3c76090d12f808ca7abc3b.zip
fix corner cases related to `in` (#3964)
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/collapse_vars.js31
-rw-r--r--test/compress/pure_funcs.js2
-rw-r--r--test/compress/side_effects.js23
3 files changed, 55 insertions, 1 deletions
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js
index 0c232aa0..f99e0124 100644
--- a/test/compress/collapse_vars.js
+++ b/test/compress/collapse_vars.js
@@ -8164,3 +8164,34 @@ issue_3927: {
}
expect_stdout: "PASS"
}
+
+operator_in: {
+ options = {
+ collapse_vars: true,
+ }
+ input: {
+ function log(msg) {
+ console.log(msg);
+ }
+ var a = "FAIL";
+ try {
+ a = "PASS";
+ 0 in null;
+ log("FAIL", a);
+ } catch (e) {}
+ log(a);
+ }
+ expect: {
+ function log(msg) {
+ console.log(msg);
+ }
+ var a = "FAIL";
+ try {
+ a = "PASS";
+ 0 in null;
+ log("FAIL", a);
+ } catch (e) {}
+ log(a);
+ }
+ expect_stdout: "PASS"
+}
diff --git a/test/compress/pure_funcs.js b/test/compress/pure_funcs.js
index d65399f1..09f0bd45 100644
--- a/test/compress/pure_funcs.js
+++ b/test/compress/pure_funcs.js
@@ -136,7 +136,7 @@ relational: {
side_effects :true,
}
input: {
- foo() in foo();
+ foo() in new foo();
foo() instanceof bar();
foo() < "bar";
bar() > foo();
diff --git a/test/compress/side_effects.js b/test/compress/side_effects.js
index 63282660..b7ffe47a 100644
--- a/test/compress/side_effects.js
+++ b/test/compress/side_effects.js
@@ -274,3 +274,26 @@ drop_value: {
foo(), bar();
}
}
+
+operator_in: {
+ options = {
+ side_effects: true,
+ }
+ input: {
+ try {
+ "foo" in true;
+ console.log("FAIL");
+ } catch (e) {
+ console.log("PASS");
+ }
+ }
+ expect: {
+ try {
+ 0 in true;
+ console.log("FAIL");
+ } catch (e) {
+ console.log("PASS");
+ }
+ }
+ expect_stdout: "PASS"
+}