aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-12-29 16:22:03 +0000
committerGitHub <noreply@github.com>2020-12-30 00:22:03 +0800
commit1956edd503bde9db8e99d8a499d54d5a508f8bb8 (patch)
tree32b1f05ad7820a1070639ef78ae5caf4fcfd0ac9 /test
parent560ccc1221639dca9db354ad6830e418a9f0073d (diff)
downloadtracifyjs-1956edd503bde9db8e99d8a499d54d5a508f8bb8.tar.gz
tracifyjs-1956edd503bde9db8e99d8a499d54d5a508f8bb8.zip
fix corner cases with `arguments` (#4481)
fixes #4480
Diffstat (limited to 'test')
-rw-r--r--test/compress/arguments.js17
-rw-r--r--test/compress/evaluate.js25
-rw-r--r--test/compress/keep_fargs.js50
3 files changed, 41 insertions, 51 deletions
diff --git a/test/compress/arguments.js b/test/compress/arguments.js
index 3ca244af..655d75a4 100644
--- a/test/compress/arguments.js
+++ b/test/compress/arguments.js
@@ -101,6 +101,13 @@ replace_index_drop_fargs_1: {
var arguments;
console.log(arguments[1], arguments["1"], arguments["foo"]);
})("bar", 42);
+ (function() {
+ var arguments = {
+ 1: "foo",
+ foo: "bar",
+ };
+ console.log(arguments[1], arguments["1"], arguments["foo"]);
+ })("bar", 42);
}
expect: {
var arguments = [];
@@ -114,8 +121,15 @@ replace_index_drop_fargs_1: {
(function(arguments) {
console.log(arguments[1], arguments[1], arguments.foo);
})("bar", 42);
- (function() {
+ (function(argument_0, argument_1) {
var arguments;
+ console.log(argument_1, argument_1, arguments.foo);
+ })("bar", 42);
+ (function() {
+ var arguments = {
+ 1: "foo",
+ foo: "bar",
+ };
console.log(arguments[1], arguments[1], arguments.foo);
})("bar", 42);
}
@@ -125,6 +139,7 @@ replace_index_drop_fargs_1: {
"42 42 undefined",
"a a undefined",
"42 42 undefined",
+ "foo foo bar",
]
}
diff --git a/test/compress/evaluate.js b/test/compress/evaluate.js
index 7466d63b..73c982f2 100644
--- a/test/compress/evaluate.js
+++ b/test/compress/evaluate.js
@@ -3117,3 +3117,28 @@ issue_4422: {
}
expect_stdout: "PASS"
}
+
+issue_4480: {
+ options = {
+ evaluate: true,
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ var a = function f(b) {
+ b = "FAIL";
+ arguments[0] = "PASS";
+ var arguments = 0;
+ console.log(b);
+ }(a);
+ }
+ expect: {
+ var a = function(b) {
+ b = "FAIL";
+ arguments[0] = "PASS";
+ var arguments = 0;
+ console.log(b);
+ }(a);
+ }
+ expect_stdout: "PASS"
+}
diff --git a/test/compress/keep_fargs.js b/test/compress/keep_fargs.js
index 049684a7..d5d7ef93 100644
--- a/test/compress/keep_fargs.js
+++ b/test/compress/keep_fargs.js
@@ -80,56 +80,6 @@ keep_fargs_true: {
]
}
-replace_index: {
- options = {
- arguments: true,
- evaluate: true,
- keep_fargs: false,
- properties: true,
- }
- input: {
- var arguments = [];
- console.log(arguments[0]);
- (function() {
- console.log(arguments[1], arguments["1"], arguments["foo"]);
- })("bar", 42);
- (function(a, b) {
- console.log(arguments[1], arguments["1"], arguments["foo"]);
- })("bar", 42);
- (function(arguments) {
- console.log(arguments[1], arguments["1"], arguments["foo"]);
- })("bar", 42);
- (function() {
- var arguments;
- console.log(arguments[1], arguments["1"], arguments["foo"]);
- })("bar", 42);
- }
- expect: {
- var arguments = [];
- console.log(arguments[0]);
- (function(argument_0, argument_1) {
- console.log(argument_1, argument_1, arguments.foo);
- })("bar", 42);
- (function(a, b) {
- console.log(b, b, arguments.foo);
- })("bar", 42);
- (function(arguments) {
- console.log(arguments[1], arguments[1], arguments.foo);
- })("bar", 42);
- (function() {
- var arguments;
- console.log(arguments[1], arguments[1], arguments.foo);
- })("bar", 42);
- }
- expect_stdout: [
- "undefined",
- "42 42 undefined",
- "42 42 undefined",
- "a a undefined",
- "42 42 undefined",
- ]
-}
-
replace_index_strict: {
options = {
arguments: true,