aboutsummaryrefslogtreecommitdiff
path: root/test/compress/reduce_vars.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/compress/reduce_vars.js')
-rw-r--r--test/compress/reduce_vars.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js
index e7189492..02ff5e43 100644
--- a/test/compress/reduce_vars.js
+++ b/test/compress/reduce_vars.js
@@ -4477,3 +4477,51 @@ perf_8: {
}
expect_stdout: "348150"
}
+
+issue_2485: {
+ options = {
+ reduce_funcs: true,
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ var foo = function(bar) {
+ var n = function(a, b) {
+ return a + b;
+ };
+ var sumAll = function(arg) {
+ return arg.reduce(n, 0);
+ };
+ var runSumAll = function(arg) {
+ return sumAll(arg);
+ };
+ bar.baz = function(arg) {
+ var n = runSumAll(arg);
+ return (n.get = 1), n;
+ };
+ return bar;
+ };
+ var bar = foo({});
+ console.log(bar.baz([1, 2, 3]));
+ }
+ expect: {
+ var foo = function(bar) {
+ var n = function(a, b) {
+ return a + b;
+ };
+ var runSumAll = function(arg) {
+ return function(arg) {
+ return arg.reduce(n, 0);
+ }(arg);
+ };
+ bar.baz = function(arg) {
+ var n = runSumAll(arg);
+ return (n.get = 1), n;
+ };
+ return bar;
+ };
+ var bar = foo({});
+ console.log(bar.baz([1, 2, 3]));
+ }
+ expect_stdout: "6"
+}