Files
UglifyJS/test/compress/functions.js
2017-12-25 17:34:16 +08:00

1575 lines
33 KiB
JavaScript

non_ascii_function_identifier_name: {
input: {
function fooλ(δλ) {}
function λ(δλ) {}
(function λ(δλ) {})()
}
expect_exact: "function fooλ(δλ){}function λ(δλ){}(function λ(δλ){})();"
}
iifes_returning_constants_keep_fargs_true: {
options = {
keep_fargs : true,
side_effects : true,
evaluate : true,
unused : true,
dead_code : true,
conditionals : true,
comparisons : true,
booleans : true,
if_return : true,
join_vars : true,
reduce_funcs : true,
reduce_vars : true,
collapse_vars : true,
inline : true,
}
input: {
(function(){ return -1.23; }());
console.log( function foo(){ return "okay"; }() );
console.log( function foo(x, y, z){ return 123; }() );
console.log( function(x, y, z){ return z; }() );
console.log( function(x, y, z){ if (x) return y; return z; }(1, 2, 3) );
console.log( function(x, y){ return x * y; }(2, 3) );
console.log( function(x, y){ return x * y; }(2, 3, a(), b()) );
}
expect: {
console.log("okay");
console.log(123);
console.log(void 0);
console.log(2);
console.log(6);
console.log((a(), b(), 6));
}
expect_stdout: true
}
iifes_returning_constants_keep_fargs_false: {
options = {
keep_fargs : false,
side_effects : true,
evaluate : true,
unused : true,
dead_code : true,
conditionals : true,
comparisons : true,
booleans : true,
if_return : true,
join_vars : true,
reduce_funcs : true,
reduce_vars : true,
collapse_vars : true,
inline : true,
}
input: {
(function(){ return -1.23; }());
console.log( function foo(){ return "okay"; }() );
console.log( function foo(x, y, z){ return 123; }() );
console.log( function(x, y, z){ return z; }() );
console.log( function(x, y, z){ if (x) return y; return z; }(1, 2, 3) );
console.log( function(x, y){ return x * y; }(2, 3) );
console.log( function(x, y){ return x * y; }(2, 3, a(), b()) );
}
expect: {
console.log("okay");
console.log(123);
console.log(void 0);
console.log(2);
console.log(6);
console.log((a(), b(), 6));
}
expect_stdout: true
}
issue_485_crashing_1530: {
options = {
conditionals: true,
dead_code: true,
evaluate: true,
inline: true,
side_effects: true,
}
input: {
(function(a) {
if (true) return;
var b = 42;
})(this);
}
expect: {}
}
issue_1841_1: {
options = {
keep_fargs: false,
pure_getters: "strict",
reduce_funcs: true,
reduce_vars: true,
unused: true,
}
input: {
var b = 10;
!function(arg) {
for (var key in "hi")
var n = arg.baz, n = [ b = 42 ];
}(--b);
console.log(b);
}
expect: {
var b = 10;
!function() {
for (var key in "hi")
b = 42;
}(--b);
console.log(b);
}
expect_exact: "42"
}
issue_1841_2: {
options = {
keep_fargs: false,
pure_getters: false,
reduce_funcs: true,
reduce_vars: true,
unused: true,
}
input: {
var b = 10;
!function(arg) {
for (var key in "hi")
var n = arg.baz, n = [ b = 42 ];
}(--b);
console.log(b);
}
expect: {
var b = 10;
!function(arg) {
for (var key in "hi")
arg.baz, b = 42;
}(--b);
console.log(b);
}
expect_exact: "42"
}
function_returning_constant_literal: {
options = {
inline: true,
passes: 2,
properties: true,
reduce_funcs: true,
reduce_vars: true,
side_effects: true,
toplevel: true,
unused: true,
}
input: {
function greeter() {
return { message: 'Hello there' };
}
var greeting = greeter();
console.log(greeting.message);
}
expect: {
console.log("Hello there");
}
expect_stdout: "Hello there"
}
hoist_funs: {
options = {
hoist_funs: true,
}
input: {
console.log(1, typeof f, typeof g);
if (console.log(2, typeof f, typeof g))
console.log(3, typeof f, typeof g);
else {
console.log(4, typeof f, typeof g);
function f() {}
console.log(5, typeof f, typeof g);
}
function g() {}
console.log(6, typeof f, typeof g);
}
expect: {
function g() {}
console.log(1, typeof f, typeof g);
if (console.log(2, typeof f, typeof g))
console.log(3, typeof f, typeof g);
else {
console.log(4, typeof f, typeof g);
function f() {}
console.log(5, typeof f, typeof g);
}
console.log(6, typeof f, typeof g);
}
expect_stdout: [
"1 'undefined' 'function'",
"2 'undefined' 'function'",
"4 'function' 'function'",
"5 'function' 'function'",
"6 'function' 'function'",
]
node_version: ">=6"
}
hoist_funs_strict: {
options = {
hoist_funs: true,
}
input: {
"use strict";
console.log(1, typeof f, typeof g);
if (console.log(2, typeof f, typeof g))
console.log(3, typeof f, typeof g);
else {
console.log(4, typeof f, typeof g);
function f() {}
console.log(5, typeof f, typeof g);
}
function g() {}
console.log(6, typeof f, typeof g);
}
expect: {
"use strict";
function g() {}
console.log(1, typeof f, typeof g);
if (console.log(2, typeof f, typeof g))
console.log(3, typeof f, typeof g);
else {
console.log(4, typeof f, typeof g);
function f() {}
console.log(5, typeof f, typeof g);
}
console.log(6, typeof f, typeof g);
}
expect_stdout: [
"1 'undefined' 'function'",
"2 'undefined' 'function'",
"4 'function' 'function'",
"5 'function' 'function'",
"6 'undefined' 'function'",
]
node_version: ">=4"
}
issue_203: {
options = {
keep_fargs: false,
side_effects: true,
unsafe_Func: true,
unused: true,
}
input: {
var m = {};
var fn = Function("require", "module", "exports", "module.exports = 42;");
fn(null, m, m.exports);
console.log(m.exports);
}
expect: {
var m = {};
var fn = Function("n,o", "o.exports=42");
fn(null, m, m.exports);
console.log(m.exports);
}
expect_stdout: "42"
}
no_webkit: {
beautify = {
webkit: false,
}
input: {
console.log(function() {
1 + 1;
}.a = 1);
}
expect_exact: "console.log(function(){1+1}.a=1);"
expect_stdout: "1"
}
webkit: {
beautify = {
webkit: true,
}
input: {
console.log(function() {
1 + 1;
}.a = 1);
}
expect_exact: "console.log((function(){1+1}).a=1);"
expect_stdout: "1"
}
issue_2084: {
options = {
collapse_vars: true,
conditionals: true,
evaluate: true,
inline: true,
passes: 2,
reduce_funcs: true,
reduce_vars: true,
sequences: true,
side_effects: true,
unused: true,
}
input: {
var c = 0;
!function() {
!function(c) {
c = 1 + c;
var c = 0;
function f14(a_1) {
if (c = 1 + c, 0 !== 23..toString())
c = 1 + c, a_1 && (a_1[0] = 0);
}
f14();
}(-1);
}();
console.log(c);
}
expect: {
var c = 0;
!function(c) {
c = 1 + c,
c = 1 + (c = 0),
0 !== 23..toString() && (c = 1 + c);
}(-1),
console.log(c);
}
expect_stdout: "0"
}
issue_2097: {
options = {
negate_iife: true,
reduce_funcs: true,
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
function f() {
try {
throw 0;
} catch (e) {
console.log(arguments[0]);
}
}
f(1);
}
expect: {
!function() {
try {
throw 0;
} catch (e) {
console.log(arguments[0]);
}
}(1);
}
expect_stdout: "1"
}
issue_2101: {
options = {
inline: true,
}
input: {
a = {};
console.log(function() {
return function() {
return this.a;
}();
}() === function() {
return a;
}());
}
expect: {
a = {};
console.log(function() {
return this.a;
}() === a);
}
expect_stdout: "true"
}
inner_ref: {
options = {
inline: true,
unused: true,
}
input: {
console.log(function(a) {
return function() {
return a;
}();
}(1), function(a) {
return function(a) {
return a;
}();
}(2));
}
expect: {
console.log(function(a) {
return a;
}(1), function(a) {
return a;
}());
}
expect_stdout: "1 undefined"
}
issue_2107: {
options = {
collapse_vars: true,
inline: true,
passes: 3,
sequences: true,
side_effects: true,
unused: true,
}
input: {
var c = 0;
!function() {
c++;
}(c++ + new function() {
this.a = 0;
var a = (c = c + 1) + (c = 1 + c);
return c++ + a;
}());
console.log(c);
}
expect: {
var c = 0;
c++, new function() {
this.a = 0, c = 1 + (c += 1), c++;
}(), c++, console.log(c);
}
expect_stdout: "5"
}
issue_2114_1: {
options = {
collapse_vars: true,
if_return: true,
inline: true,
keep_fargs: false,
side_effects: true,
unused: true,
}
input: {
var c = 0;
!function(a) {
a = 0;
}([ {
0: c = c + 1,
length: c = 1 + c
}, typeof void function a() {
var b = function f1(a) {
}(b && (b.b += (c = c + 1, 0)));
}() ]);
console.log(c);
}
expect: {
var c = 0;
c = 1 + (c += 1), function() {
var b = void (b && (b.b += (c += 1, 0)));
}();
console.log(c);
}
expect_stdout: "2"
}
issue_2114_2: {
options = {
collapse_vars: true,
if_return: true,
inline: true,
keep_fargs: false,
passes: 2,
side_effects: true,
unused: true,
}
input: {
var c = 0;
!function(a) {
a = 0;
}([ {
0: c = c + 1,
length: c = 1 + c
}, typeof void function a() {
var b = function f1(a) {
}(b && (b.b += (c = c + 1, 0)));
}() ]);
console.log(c);
}
expect: {
var c = 0;
c = 1 + (c += 1), function() {
var b = void (b && (b.b += (c += 1, 0)));
}();
console.log(c);
}
expect_stdout: "2"
}
issue_2428: {
options = {
collapse_vars: true,
inline: true,
passes: 3,
pure_getters: "strict",
reduce_funcs: true,
reduce_vars: true,
side_effects: true,
toplevel: true,
unsafe: true,
unused: true,
}
input: {
function bar(k) {
console.log(k);
}
function foo(x) {
return bar(x);
}
function baz(a) {
foo(a);
}
baz(42);
baz("PASS");
}
expect: {
function baz(a) {
console.log(a);
}
baz(42);
baz("PASS");
}
expect_stdout: [
"42",
"PASS",
]
}
issue_2531_1: {
options = {
evaluate: true,
inline: true,
reduce_funcs: true,
reduce_vars: true,
unused: true,
}
input: {
function outer() {
function inner(value) {
function closure() {
return value;
}
return function() {
return closure();
};
}
return inner("Hello");
}
console.log("Greeting:", outer()());
}
expect: {
function outer() {
return value = "Hello", function() {
return value;
};
var value;
}
console.log("Greeting:", outer()());
}
expect_stdout: "Greeting: Hello"
}
issue_2531_2: {
options = {
evaluate: true,
inline: true,
passes: 3,
reduce_funcs: true,
reduce_vars: true,
side_effects: true,
unused: true,
}
input: {
function outer() {
function inner(value) {
function closure() {
return value;
}
return function() {
return closure();
};
}
return inner("Hello");
}
console.log("Greeting:", outer()());
}
expect: {
function outer() {
return function() {
return "Hello";
};
}
console.log("Greeting:", outer()());
}
expect_stdout: "Greeting: Hello"
}
issue_2531_3: {
options = {
evaluate: true,
inline: true,
passes: 3,
reduce_funcs: true,
reduce_vars: true,
side_effects: true,
toplevel: true,
unused: true,
}
input: {
function outer() {
function inner(value) {
function closure() {
return value;
}
return function() {
return closure();
};
}
return inner("Hello");
}
console.log("Greeting:", outer()());
}
expect: {
console.log("Greeting:", "Hello");
}
expect_stdout: "Greeting: Hello"
}
empty_body: {
options = {
reduce_vars: true,
side_effects: true,
}
input: {
function f() {
function noop() {}
noop();
return noop;
}
}
expect: {
function f() {
function noop() {}
return noop;
}
}
}
inline_loop_1: {
options = {
inline: true,
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
function f() {
return x();
}
for (;;) f();
}
expect: {
for (;;) x();
}
}
inline_loop_2: {
options = {
inline: true,
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
for (;;) f();
function f() {
return x();
}
}
expect: {
for (;;) x();
}
}
inline_loop_3: {
options = {
inline: true,
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
var f = function() {
return x();
};
for (;;) f();
}
expect: {
for (;;) x();
}
}
inline_loop_4: {
options = {
inline: true,
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
for (;;) f();
var f = function() {
return x();
};
}
expect: {
for (;;) f();
var f = function() {
return x();
};
}
}
issue_2476: {
options = {
inline: true,
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
function foo(x, y, z) {
return x < y ? x * y + z : x * z - y;
}
for (var sum = 0, i = 0; i < 10; i++)
sum += foo(i, i + 1, 3 * i);
console.log(sum);
}
expect: {
for (var sum = 0, i = 0; i < 10; i++)
sum += (x = i, y = i + 1, z = 3 * i, x < y ? x * y + z : x * z - y);
var x, y, z;
console.log(sum);
}
expect_stdout: "465"
}
issue_2601_1: {
options = {
inline: true,
reduce_vars: true,
sequences: true,
side_effects: true,
unused: true,
}
input: {
var a = "FAIL";
(function() {
function f(b) {
function g(b) {
b && b();
}
g();
(function() {
b && (a = "PASS");
})();
}
f("foo");
})();
console.log(a);
}
expect: {
var a = "FAIL";
(function() {
b = "foo",
function(b) {
b && b();
}(),
b && (a = "PASS");
var b;
})(),
console.log(a);
}
expect_stdout: "PASS"
}
issue_2601_2: {
rename = true
options = {
evaluate: true,
inline: true,
passes: 3,
reduce_vars: true,
sequences: true,
side_effects: true,
unused: true,
}
mangle = {}
input: {
var a = "FAIL";
(function() {
function f(b) {
function g(b) {
b && b();
}
g();
(function() {
b && (a = "PASS");
})();
}
f("foo");
})();
console.log(a);
}
expect: {
var a = "FAIL";
a = "PASS",
console.log(a);
}
expect_stdout: "PASS"
}
issue_2604_1: {
options = {
inline: true,
side_effects: true,
unused: true,
}
input: {
var a = "FAIL";
(function() {
try {
throw 1;
} catch (b) {
(function f(b) {
b && b();
})();
b && (a = "PASS");
}
})();
console.log(a);
}
expect: {
var a = "FAIL";
(function() {
try {
throw 1;
} catch (b) {
(function(b) {
b && b();
})();
b && (a = "PASS");
}
})();
console.log(a);
}
expect_stdout: "PASS"
}
issue_2604_2: {
rename = true
options = {
evaluate: true,
inline: true,
passes: 3,
reduce_vars: true,
side_effects: true,
unused: true,
}
mangle = {}
input: {
var a = "FAIL";
(function() {
try {
throw 1;
} catch (b) {
(function f(b) {
b && b();
})();
b && (a = "PASS");
}
})();
console.log(a);
}
expect: {
var a = "FAIL";
(function() {
try {
throw 1;
} catch (o) {
o && (a = "PASS");
}
})();
console.log(a);
}
expect_stdout: "PASS"
}
unsafe_apply_1: {
options = {
inline: true,
passes: 2,
reduce_vars: true,
side_effects: true,
unsafe: true,
unused: true,
}
input: {
(function(a, b) {
console.log(a, b);
}).apply("foo", [ "bar" ]);
(function(a, b) {
console.log(this, a, b);
}).apply("foo", [ "bar" ]);
(function(a, b) {
console.log(a, b);
}).apply("foo", [ "bar" ], "baz");
}
expect: {
console.log("bar", void 0);
(function(a, b) {
console.log(this, a, b);
}).call("foo", "bar");
(function(a, b) {
console.log(a, b);
}).apply("foo", [ "bar" ], "baz");
}
expect_stdout: true
}
unsafe_apply_2: {
options = {
reduce_vars: true,
side_effects: true,
toplevel: true,
unsafe: true,
}
input: {
function foo() {
console.log(a, b);
}
var bar = function(a, b) {
console.log(this, a, b);
}
(function() {
foo.apply("foo", [ "bar" ]);
bar.apply("foo", [ "bar" ]);
})();
}
expect: {
function foo() {
console.log(a, b);
}
var bar = function(a, b) {
console.log(this, a, b);
}
(function() {
foo("bar");
bar.call("foo", "bar");
})();
}
expect_stdout: true
}
unsafe_apply_expansion: {
options = {
unsafe: true,
}
input: {
console.log.apply(console, [1, ...[2, 3], 4]);
}
expect: {
console.log.call(console, 1, ...[2, 3], 4);
}
expect_stdout: "1 2 3 4"
node_version: ">=6"
}
unsafe_call_1: {
options = {
inline: true,
passes: 2,
reduce_vars: true,
side_effects: true,
unsafe: true,
unused: true,
}
input: {
(function(a, b) {
console.log(a, b);
}).call("foo", "bar");
(function(a, b) {
console.log(this, a, b);
}).call("foo", "bar");
}
expect: {
console.log("bar", void 0);
(function(a, b) {
console.log(this, a, b);
}).call("foo", "bar");
}
expect_stdout: true
}
unsafe_call_2: {
options = {
reduce_vars: true,
side_effects: true,
toplevel: true,
unsafe: true,
}
input: {
function foo() {
console.log(a, b);
}
var bar = function(a, b) {
console.log(this, a, b);
}
(function() {
foo.call("foo", "bar");
bar.call("foo", "bar");
})();
}
expect: {
function foo() {
console.log(a, b);
}
var bar = function(a, b) {
console.log(this, a, b);
}
(function() {
foo("bar");
bar.call("foo", "bar");
})();
}
expect_stdout: true
}
unsafe_call_3: {
options = {
side_effects: true,
unsafe: true,
}
input: {
console.log(function() {
return arguments[0] + eval("arguments")[1];
}.call(0, 1, 2));
}
expect: {
console.log(function() {
return arguments[0] + eval("arguments")[1];
}(1, 2));
}
expect_stdout: "3"
}
unsafe_call_expansion: {
options = {
unsafe: true,
}
input: {
(function(...a) {
console.log(...a);
}).call(console, 1, ...[2, 3], 4);
}
expect: {
console,
(function(...a) {
console.log(...a);
})(1, ...[2, 3], 4);
}
expect_stdout: "1 2 3 4"
node_version: ">=6"
}
issue_2616: {
options = {
evaluate: true,
inline: true,
reduce_vars: true,
side_effects: true,
unused: true,
}
input: {
var c = "FAIL";
(function() {
function f() {
function g(NaN) {
(true << NaN) - 0/0 || (c = "PASS");
}
g([]);
}
f();
})();
console.log(c);
}
expect: {
var c = "FAIL";
(function() {
!function(NaN) {
(true << NaN) - 0/0 || (c = "PASS");
}([]);
})();
console.log(c);
}
expect_stdout: "PASS"
}
issue_2620_1: {
options = {
inline: true,
reduce_vars: true,
sequences: true,
side_effects: true,
unused: true,
}
input: {
var c = "FAIL";
(function() {
function f(a) {
var b = function g(a) {
a && a();
}();
if (a) {
var d = c = "PASS";
}
}
f(1);
})();
console.log(c);
}
expect: {
var c = "FAIL";
(function() {
(function(a) {
if (function(a) {
a && a();
}(), a) c = "PASS";
})(1);
})(),
console.log(c);
}
expect_stdout: "PASS"
}
issue_2620_2: {
options = {
conditionals: true,
evaluate: true,
inline: true,
passes: 2,
reduce_vars: true,
sequences: true,
side_effects: true,
unused: true,
}
input: {
var c = "FAIL";
(function() {
function f(a) {
var b = function g(a) {
a && a();
}();
if (a) {
var d = c = "PASS";
}
}
f(1);
})();
console.log(c);
}
expect: {
var c = "FAIL";
c = "PASS",
console.log(c);
}
expect_stdout: "PASS"
}
issue_2620_3: {
options = {
evaluate: true,
inline: true,
reduce_vars: true,
side_effects: true,
unused: true,
}
input: {
var c = "FAIL";
(function() {
function f(a, NaN) {
function g() {
switch (a) {
case a:
break;
case c = "PASS", NaN:
break;
}
}
g();
}
f(0/0);
})();
console.log(c);
}
expect: {
var c = "FAIL";
(function() {
(function(a, NaN) {
(function() {
switch (a) {
case a:
break;
case c = "PASS", NaN:
break;
}
})();
})(NaN);
})();
console.log(c);
}
expect_stdout: "PASS"
}
issue_2620_4: {
rename = true,
options = {
evaluate: true,
dead_code: true,
inline: true,
passes: 2,
reduce_vars: true,
side_effects: true,
switches: true,
unused: true,
}
input: {
var c = "FAIL";
(function() {
function f(a, NaN) {
function g() {
switch (a) {
case a:
break;
case c = "PASS", NaN:
break;
}
}
g();
}
f(0/0);
})();
console.log(c);
}
expect: {
var c = "FAIL";
!function() {
switch (NaN) {
case void (c = "PASS"):
}
}();
console.log(c);
}
expect_stdout: "PASS"
}
issue_2630_1: {
options = {
collapse_vars: true,
inline: true,
passes: 2,
reduce_funcs: true,
reduce_vars: true,
sequences: true,
side_effects: true,
unused: true,
}
input: {
var c = 0;
(function() {
while (f());
function f() {
var a = function() {
var b = c++, d = c = 1 + c;
}();
}
})();
console.log(c);
}
expect: {
var c = 0;
(function() {
while (c++, void (c = 1 + c));
})(),
console.log(c);
}
expect_stdout: "2"
}
issue_2630_2: {
options = {
collapse_vars: true,
inline: true,
passes: 2,
reduce_vars: true,
sequences: true,
unused: true,
}
input: {
var c = 0;
!function() {
while (f()) {}
function f() {
var not_used = function() {
c = 1 + c;
}(c = c + 1);
}
}();
console.log(c);
}
expect: {
var c = 0;
!function() {
while (c += 1, void (c = 1 + c));
}(), console.log(c);
}
expect_stdout: "2"
}
issue_2630_3: {
options = {
inline: true,
reduce_vars: true,
unused: true,
}
input: {
var x = 2, a = 1;
(function() {
function f1(a) {
f2();
--x >= 0 && f1({});
}
f1(a++);
function f2() {
a++;
}
})();
console.log(a);
}
expect: {
var x = 2, a = 1;
(function() {
function f1(a) {
f2();
--x >= 0 && f1({});
}
f1(a++);
function f2() {
a++;
}
})();
console.log(a);
}
expect_stdout: "5"
}
issue_2630_4: {
options = {
collapse_vars: true,
inline: true,
reduce_vars: true,
side_effects: true,
unused: true,
}
input: {
var x = 3, a = 1, b = 2;
(function() {
(function f1() {
while (--x >= 0 && f2());
}());
function f2() {
a++ + (b += a);
}
})();
console.log(a);
}
expect: {
var x = 3, a = 1, b = 2;
(function() {
(function() {
while (--x >= 0 && void (a++, b += a));
})();
})();
console.log(a);
}
expect_stdout: "2"
}
issue_2630_5: {
options = {
collapse_vars: true,
inline: true,
reduce_vars: true,
unused: true,
}
input: {
var c = 1;
!function() {
do {
c *= 10;
} while (f());
function f() {
return function() {
return (c = 2 + c) < 100;
}(c = c + 3);
}
}();
console.log(c);
}
expect: {
var c = 1;
!function() {
do {
c *= 10;
} while (c += 3, (c = 2 + c) < 100);
}();
console.log(c);
}
expect_stdout: "155"
}
issue_2647_1: {
options = {
inline: true,
reduce_vars: true,
side_effects: true,
unused: true,
}
input: {
(function(n, o = "FAIL") {
console.log(n);
})("PASS");
(function(n, o = "PASS") {
console.log(o);
})("FAIL");
(function(o = "PASS") {
console.log(o);
})();
(function(n, {o = "FAIL"}) {
console.log(n);
})("PASS", {});
}
expect: {
console.log("PASS");
(function(n, o = "PASS") {
console.log(o);
})();
(function(o = "PASS") {
console.log(o);
})();
(function(n, {o = "FAIL"}) {
console.log("PASS");
})(0, {});
}
expect_stdout: [
"PASS",
"PASS",
"PASS",
"PASS",
]
node_version: ">=6"
}
issue_2647_2: {
options = {
collapse_vars: true,
inline: true,
reduce_vars: true,
unused: true,
}
input: {
(function() {
function foo(x) {
return x.toUpperCase();
}
console.log((() => foo("pass"))());
}());
}
expect: {
(function() {
console.log("pass".toUpperCase());
})();
}
expect_stdout: "PASS"
node_version: ">=4"
}
issue_2647_3: {
options = {
collapse_vars: true,
inline: true,
reduce_vars: true,
unused: true,
}
input: {
(function() {
function foo(x) {
return x.toUpperCase();
}
console.log((() => {
return foo("pass");
})());
}());
}
expect: {
(function() {
console.log("pass".toUpperCase());
})();
}
expect_stdout: "PASS"
node_version: ">=4"
}
recursive_inline: {
options = {
inline: true,
reduce_funcs: true,
reduce_vars: true,
sequences: true,
toplevel: true,
unused: true,
}
input: {
function f() {
h();
}
function g(a) {
a();
}
function h(b) {
g();
if (b) x();
}
}
expect: {}
}