diff options
Diffstat (limited to 'test/compress')
-rw-r--r-- | test/compress/collapse_vars.js | 6 | ||||
-rw-r--r-- | test/compress/dead-code.js | 2 | ||||
-rw-r--r-- | test/compress/evaluate.js | 114 |
3 files changed, 116 insertions, 6 deletions
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js index 82fb057e..6244e03f 100644 --- a/test/compress/collapse_vars.js +++ b/test/compress/collapse_vars.js @@ -917,7 +917,7 @@ collapse_vars_lvalues_drop_assign: { } } -collapse_vars_misc1: { +collapse_vars_misc: { options = { booleans: true, collapse_vars: true, @@ -971,8 +971,8 @@ collapse_vars_misc1: { function f7() { var b = window.a * window.z; return b + b } function f8() { var b = window.a * window.z; return b + (5 + b) } function f9() { var b = window.a * window.z; return bar() || b } - function f10(x) { var a = 5; return a += 3; } - function f11(x) { var a = 5; return a += 2; } + function f10(x) { return 8; } + function f11(x) { return 7; } } } diff --git a/test/compress/dead-code.js b/test/compress/dead-code.js index 795d1f7c..22eb0d91 100644 --- a/test/compress/dead-code.js +++ b/test/compress/dead-code.js @@ -236,7 +236,7 @@ collapse_vars_lvalues_drop_assign: { } } -collapse_vars_misc1: { +collapse_vars_misc: { options = { collapse_vars: true, dead_code: true, diff --git a/test/compress/evaluate.js b/test/compress/evaluate.js index 868ad154..a7b5a4a5 100644 --- a/test/compress/evaluate.js +++ b/test/compress/evaluate.js @@ -2503,7 +2503,7 @@ inlined_increment_prefix: { expect: { var a = 0; void ++a; - console.log(a += 0); + console.log(1); } expect_stdout: "1" } @@ -2525,7 +2525,7 @@ inlined_increment_postfix: { expect: { var a = 0; void a++; - console.log(a += 0); + console.log(1); } expect_stdout: "1" } @@ -2544,3 +2544,113 @@ compound_assignment_to_property: { } expect_stdout: "PASS" } + +issue_2208_assign: { + options = { + evaluate: true, + reduce_vars: true, + toplevel: true, + } + input: { + a = 42; + console.log({ + p: function() { + return function() { + return this.a; + }(); + } + }.p()); + } + expect: { + a = 42; + console.log({ + p: function() { + return function() { + return this.a; + }(); + } + }.p()); + } + expect_stdout: "42" +} + +issue_2208_postfix: { + options = { + evaluate: true, + reduce_vars: true, + toplevel: true, + } + input: { + a = 41; + a++; + console.log({ + p: function() { + return function() { + return this.a; + }(); + } + }.p()); + } + expect: { + a = 41; + a++; + console.log({ + p: function() { + return function() { + return this.a; + }(); + } + }.p()); + } + expect_stdout: "42" +} + +issue_2208_prefix: { + options = { + evaluate: true, + reduce_vars: true, + toplevel: true, + } + input: { + a = 43; + --a; + console.log({ + p: function() { + return function() { + return this.a; + }(); + } + }.p()); + } + expect: { + a = 43; + --a; + console.log({ + p: function() { + return function() { + return this.a; + }(); + } + }.p()); + } + expect_stdout: "42" +} + +issue_3933: { + options = { + evaluate: true, + reduce_vars: true, + unused: true, + } + input: { + (function(a, b) { + a && (b ^= 1) && console.log("PASS"); + })(1); + } + expect: { + (function(a, b) { + 1, (b ^= 1), console.log("PASS"); + })(); + } + expect_stdout: "PASS" +} |