diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/compress/collapse_vars.js | 46 | ||||
-rw-r--r-- | test/compress/drop-unused.js | 25 | ||||
-rw-r--r-- | test/compress/sequences.js | 24 |
3 files changed, 95 insertions, 0 deletions
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js index 4215cebe..0d578d7d 100644 --- a/test/compress/collapse_vars.js +++ b/test/compress/collapse_vars.js @@ -2186,3 +2186,49 @@ compound_assignment: { } expect_stdout: "4" } + +reassign_const_1: { + options = { + collapse_vars: true, + } + input: { + function f() { + const a = 1; + a = 2; + return a; + } + console.log(f()); + } + expect: { + function f() { + const a = 1; + a = 2; + return a; + } + console.log(f()); + } + expect_stdout: true +} + +reassign_const_2: { + options = { + collapse_vars: true, + } + input: { + function f() { + const a = 1; + ++a; + return a; + } + console.log(f()); + } + expect: { + function f() { + const a = 1; + ++a; + return a; + } + console.log(f()); + } + expect_stdout: true +} diff --git a/test/compress/drop-unused.js b/test/compress/drop-unused.js index ddf90bfa..96bd336c 100644 --- a/test/compress/drop-unused.js +++ b/test/compress/drop-unused.js @@ -1147,3 +1147,28 @@ var_catch_toplevel: { }(); } } + +reassign_const: { + options = { + cascade: true, + sequences: true, + side_effects: true, + unused: true, + } + input: { + function f() { + const a = 1; + a = 2; + return a; + } + console.log(f()); + } + expect: { + function f() { + const a = 1; + return a = 2, a; + } + console.log(f()); + } + expect_stdout: true +} diff --git a/test/compress/sequences.js b/test/compress/sequences.js index 10492565..9edf627e 100644 --- a/test/compress/sequences.js +++ b/test/compress/sequences.js @@ -710,3 +710,27 @@ issue_27: { })(jQuery); } } + +reassign_const: { + options = { + cascade: true, + sequences: true, + side_effects: true, + } + input: { + function f() { + const a = 1; + a++; + return a; + } + console.log(f()); + } + expect: { + function f() { + const a = 1; + return a++, a; + } + console.log(f()); + } + expect_stdout: true +} |