aboutsummaryrefslogtreecommitdiff
path: root/test/compress/sequences.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-04-08 14:25:28 +0800
committerGitHub <noreply@github.com>2017-04-08 14:25:28 +0800
commitcf72fe552f5a51ccfe40c32e0fb86d549e0ca848 (patch)
treec8fae2eef25cb24475a37d06cbd502dbf5599671 /test/compress/sequences.js
parenta1532eb076d506fbf87a04c0ec4f26e1929aa902 (diff)
downloadtracifyjs-cf72fe552f5a51ccfe40c32e0fb86d549e0ca848.tar.gz
tracifyjs-cf72fe552f5a51ccfe40c32e0fb86d549e0ca848.zip
fix `delete` corner cases (#1799)
- assignment - boolean - conditional - sequence
Diffstat (limited to 'test/compress/sequences.js')
-rw-r--r--test/compress/sequences.js144
1 files changed, 144 insertions, 0 deletions
diff --git a/test/compress/sequences.js b/test/compress/sequences.js
index b3c54635..699341c0 100644
--- a/test/compress/sequences.js
+++ b/test/compress/sequences.js
@@ -466,3 +466,147 @@ issue_1758: {
}
expect_stdout: "undefined"
}
+
+delete_seq_1: {
+ options = {
+ booleans: true,
+ side_effects: true,
+ }
+ input: {
+ console.log(delete (1, undefined));
+ console.log(delete (1, void 0));
+ console.log(delete (1, Infinity));
+ console.log(delete (1, 1 / 0));
+ console.log(delete (1, NaN));
+ console.log(delete (1, 0 / 0));
+ }
+ expect: {
+ console.log((void 0, !0));
+ console.log((void 0, !0));
+ console.log((1 / 0, !0));
+ console.log((1 / 0, !0));
+ console.log((NaN, !0));
+ console.log((0 / 0, !0));
+ }
+ expect_stdout: true
+}
+
+delete_seq_2: {
+ options = {
+ booleans: true,
+ side_effects: true,
+ }
+ input: {
+ console.log(delete (1, 2, undefined));
+ console.log(delete (1, 2, void 0));
+ console.log(delete (1, 2, Infinity));
+ console.log(delete (1, 2, 1 / 0));
+ console.log(delete (1, 2, NaN));
+ console.log(delete (1, 2, 0 / 0));
+ }
+ expect: {
+ console.log((void 0, !0));
+ console.log((void 0, !0));
+ console.log((1 / 0, !0));
+ console.log((1 / 0, !0));
+ console.log((NaN, !0));
+ console.log((0 / 0, !0));
+ }
+ expect_stdout: true
+}
+
+delete_seq_3: {
+ options = {
+ booleans: true,
+ keep_infinity: true,
+ side_effects: true,
+ }
+ input: {
+ console.log(delete (1, 2, undefined));
+ console.log(delete (1, 2, void 0));
+ console.log(delete (1, 2, Infinity));
+ console.log(delete (1, 2, 1 / 0));
+ console.log(delete (1, 2, NaN));
+ console.log(delete (1, 2, 0 / 0));
+ }
+ expect: {
+ console.log((void 0, !0));
+ console.log((void 0, !0));
+ console.log((Infinity, !0));
+ console.log((1 / 0, !0));
+ console.log((NaN, !0));
+ console.log((0 / 0, !0));
+ }
+ expect_stdout: true
+}
+
+delete_seq_4: {
+ options = {
+ booleans: true,
+ sequences: true,
+ side_effects: true,
+ }
+ input: {
+ function f() {}
+ console.log(delete (f(), undefined));
+ console.log(delete (f(), void 0));
+ console.log(delete (f(), Infinity));
+ console.log(delete (f(), 1 / 0));
+ console.log(delete (f(), NaN));
+ console.log(delete (f(), 0 / 0));
+ }
+ expect: {
+ function f() {}
+ console.log((f(), !0)),
+ console.log((f(), !0)),
+ console.log((f(), !0)),
+ console.log((f(), !0)),
+ console.log((f(), !0)),
+ console.log((f(), !0));
+ }
+ expect_stdout: true
+}
+
+delete_seq_5: {
+ options = {
+ booleans: true,
+ keep_infinity: true,
+ sequences: true,
+ side_effects: true,
+ }
+ input: {
+ function f() {}
+ console.log(delete (f(), undefined));
+ console.log(delete (f(), void 0));
+ console.log(delete (f(), Infinity));
+ console.log(delete (f(), 1 / 0));
+ console.log(delete (f(), NaN));
+ console.log(delete (f(), 0 / 0));
+ }
+ expect: {
+ function f() {}
+ console.log((f(), !0)),
+ console.log((f(), !0)),
+ console.log((f(), !0)),
+ console.log((f(), !0)),
+ console.log((f(), !0)),
+ console.log((f(), !0));
+ }
+ expect_stdout: true
+}
+
+delete_seq_6: {
+ options = {
+ booleans: true,
+ side_effects: true,
+ }
+ input: {
+ var a;
+ console.log(delete (1, a));
+ }
+ expect: {
+ var a;
+ console.log((a, !0));
+ }
+ expect_stdout: true
+}