diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2019-05-19 12:59:40 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-19 12:59:40 +0800 |
commit | ae77ebe5a5f1be4b2634036f48d8b570b569cb21 (patch) | |
tree | 754c0f68fd2ae5f06b3bd006a35c2b8eea22da0e /test/compress | |
parent | 04439edceccfdc450901907cd248425b3ba384ae (diff) | |
download | tracifyjs-ae77ebe5a5f1be4b2634036f48d8b570b569cb21.tar.gz tracifyjs-ae77ebe5a5f1be4b2634036f48d8b570b569cb21.zip |
fix corner case in `arguments` (#3421)
fixes #3420
Diffstat (limited to 'test/compress')
-rw-r--r-- | test/compress/arguments.js | 154 | ||||
-rw-r--r-- | test/compress/keep_fargs.js | 66 |
2 files changed, 220 insertions, 0 deletions
diff --git a/test/compress/arguments.js b/test/compress/arguments.js index eaff8119..119eaf2c 100644 --- a/test/compress/arguments.js +++ b/test/compress/arguments.js @@ -622,3 +622,157 @@ issue_3282_2_passes: { } expect_stdout: true } + +issue_3420_1: { + options = { + arguments: true, + keep_fargs: "strict", + } + input: { + console.log(function() { + return function() { + return arguments[0]; + }; + }().length); + } + expect: { + console.log(function() { + return function() { + return arguments[0]; + }; + }().length); + } + expect_stdout: "0" +} + +issue_3420_2: { + options = { + arguments: true, + keep_fargs: "strict", + } + input: { + var foo = function() { + delete arguments[0]; + }; + foo(); + } + expect: { + var foo = function() { + delete arguments[0]; + }; + foo(); + } + expect_stdout: true +} + +issue_3420_3: { + options = { + arguments: true, + keep_fargs: "strict", + } + input: { + "use strict"; + var foo = function() { + delete arguments[0]; + }; + foo(); + } + expect: { + "use strict"; + var foo = function() { + delete arguments[0]; + }; + foo(); + } + expect_stdout: true +} + +issue_3420_4: { + options = { + arguments: true, + keep_fargs: "strict", + } + input: { + !function() { + console.log(arguments[0]); + delete arguments[0]; + console.log(arguments[0]); + }(42); + } + expect: { + !function(argument_0) { + console.log(argument_0); + delete arguments[0]; + console.log(arguments[0]); + }(42); + } + expect_stdout: [ + "42", + "undefined", + ] +} + +issue_3420_5: { + options = { + arguments: true, + keep_fargs: "strict", + } + input: { + "use strict"; + !function() { + console.log(arguments[0]); + delete arguments[0]; + console.log(arguments[0]); + }(42); + } + expect: { + "use strict"; + !function(argument_0) { + console.log(argument_0); + delete arguments[0]; + console.log(arguments[0]); + }(42); + } + expect_stdout: [ + "42", + "undefined", + ] +} + +issue_3420_6: { + options = { + arguments: true, + keep_fargs: "strict", + } + input: { + console.log(function() { + return delete arguments[0]; + }()); + } + expect: { + console.log(function() { + return delete arguments[0]; + }()); + } + expect_stdout: "true" +} + +issue_3420_7: { + options = { + arguments: true, + keep_fargs: "strict", + } + input: { + "use strict"; + console.log(function() { + return delete arguments[0]; + }()); + } + expect: { + "use strict"; + console.log(function() { + return delete arguments[0]; + }()); + } + expect_stdout: "true" +} diff --git a/test/compress/keep_fargs.js b/test/compress/keep_fargs.js index b23e96f0..558b10bb 100644 --- a/test/compress/keep_fargs.js +++ b/test/compress/keep_fargs.js @@ -1051,3 +1051,69 @@ function_name_mangle_ie8: { expect_exact: "(function(){console.log(typeof function o(){})})();" expect_stdout: "function" } + +issue_3420_1: { + options = { + keep_fargs: "strict", + unused: true, + } + input: { + console.log(function() { + return function(a, b, c, d) { + return a + b; + }; + }().length); + } + expect: { + console.log(function() { + return function(a, b, c, d) { + return a + b; + }; + }().length); + } + expect_stdout: "4" +} + +issue_3420_2: { + options = { + inline: true, + keep_fargs: "strict", + unused: true, + } + input: { + console.log(function() { + return function(a, b, c, d) { + return a + b; + }; + }().length); + } + expect: { + console.log(function(a, b, c, d) { + return a + b; + }.length); + } + expect_stdout: "4" +} + +issue_3420_3: { + options = { + inline: true, + keep_fargs: "strict", + reduce_vars: true, + unused: true, + } + input: { + console.log(function() { + function f(a, b, c, d) { + return a + b; + } + return f; + }().length); + } + expect: { + console.log(function(a, b, c, d) { + return a + b; + }.length); + } + expect_stdout: "4" +} |