aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/input/reduce/setter.js8
-rw-r--r--test/input/reduce/setter.reduced.js19
-rw-r--r--test/mocha/reduce.js13
-rw-r--r--test/reduce.js2
4 files changed, 41 insertions, 1 deletions
diff --git a/test/input/reduce/setter.js b/test/input/reduce/setter.js
new file mode 100644
index 00000000..87228bc4
--- /dev/null
+++ b/test/input/reduce/setter.js
@@ -0,0 +1,8 @@
+console.log(function f(a) {
+ ({
+ set p(v) {
+ f++;
+ }
+ });
+ return f.length;
+}());
diff --git a/test/input/reduce/setter.reduced.js b/test/input/reduce/setter.reduced.js
new file mode 100644
index 00000000..d947226f
--- /dev/null
+++ b/test/input/reduce/setter.reduced.js
@@ -0,0 +1,19 @@
+console.log(function f(a) {
+ ({
+ set p(v) {
+ f++;
+ }
+ });
+ return f.length;
+}());
+// output: 1
+//
+// minify: 0
+//
+// options: {
+// "compress": {
+// "keep_fargs": false,
+// "unsafe": true
+// },
+// "mangle": false
+// } \ No newline at end of file
diff --git a/test/mocha/reduce.js b/test/mocha/reduce.js
index 7eacbd7f..a8ab67b3 100644
--- a/test/mocha/reduce.js
+++ b/test/mocha/reduce.js
@@ -31,6 +31,19 @@ describe("test/reduce.js", function() {
if (result.error) throw result.error;
assert.strictEqual(result.code, read("test/input/reduce/label.reduced.js"));
});
+ it("Should retain setter arguments", function() {
+ var result = reduce_test(read("test/input/reduce/setter.js"), {
+ compress: {
+ keep_fargs: false,
+ unsafe: true,
+ },
+ mangle: false,
+ }, {
+ verbose: false,
+ });
+ if (result.error) throw result.error;
+ assert.strictEqual(result.code, read("test/input/reduce/setter.reduced.js"));
+ });
it("Should handle test cases with --toplevel", function() {
var result = reduce_test([
"var Infinity = 42;",
diff --git a/test/reduce.js b/test/reduce.js
index eb6fb5c1..f9e08254 100644
--- a/test/reduce.js
+++ b/test/reduce.js
@@ -75,8 +75,8 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options)
if (node instanceof U.AST_LabelRef) return;
if (!in_list && node instanceof U.AST_SymbolDeclaration) return;
if (node instanceof U.AST_Toplevel) return;
-
var parent = tt.parent();
+ if (node instanceof U.AST_SymbolFunarg && parent instanceof U.AST_Accessor) return;
// ensure that the _permute prop is a number.
// can not use `node.start._permute |= 0;` as it will erase fractional part.