diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/compress/reduce_vars.js | 92 |
1 files changed, 68 insertions, 24 deletions
diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js index f7bdcb36..22c1a874 100644 --- a/test/compress/reduce_vars.js +++ b/test/compress/reduce_vars.js @@ -297,7 +297,7 @@ unsafe_evaluate_array: { } } -unsafe_evaluate_equality: { +unsafe_evaluate_equality_1: { options = { evaluate : true, reduce_vars : true, @@ -305,47 +305,62 @@ unsafe_evaluate_equality: { unused : true } input: { - function f0(){ + function f0() { var a = {}; - console.log(a === a); + return a === a; } - - function f1(){ + function f1() { var a = []; - console.log(a === a); + return a === a; + } + console.log(f0(), f1()); + } + expect: { + function f0() { + return true; + } + function f1() { + return true; } + console.log(f0(), f1()); + } + expect_stdout: true +} - function f2(){ +unsafe_evaluate_equality_2: { + options = { + collapse_vars: true, + evaluate : true, + passes : 2, + reduce_vars : true, + unsafe : true, + unused : true + } + input: { + function f2() { var a = {a:1, b:2}; var b = a; var c = a; - console.log(b === c); + return b === c; } - - function f3(){ + function f3() { var a = [1, 2, 3]; var b = a; var c = a; - console.log(b === c); + return b === c; } + console.log(f2(), f3()); } expect: { - function f0(){ - console.log(true); - } - - function f1(){ - console.log(true); - } - - function f2(){ - console.log(true); + function f2() { + return true; } - - function f3(){ - console.log(true); + function f3() { + return true; } + console.log(f2(), f3()); } + expect_stdout: true } passes: { @@ -2417,3 +2432,32 @@ issue_1850_4: { } expect_stdout: true } + +issue_1865: { + options = { + evaluate: true, + reduce_vars: true, + unsafe: true, + } + input: { + function f(a) { + a.b = false; + } + console.log(function() { + var some = { thing: true }; + f(some); + return some.thing; + }()); + } + expect: { + function f(a) { + a.b = false; + } + console.log(function() { + var some = { thing: true }; + f(some); + return some.thing; + }()); + } + expect_stdout: true +} |