diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-12-14 01:20:36 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-14 01:20:36 +0800 |
commit | ef618332ea92db57e59f90f166035a0e7cf8a509 (patch) | |
tree | 1f6e6b0f2d8fb9ae54324265b9d1e8514e5da06b /test | |
parent | 7f418978c9d39bd0827108176d817259a6e60f5c (diff) | |
download | tracifyjs-ef618332ea92db57e59f90f166035a0e7cf8a509.tar.gz tracifyjs-ef618332ea92db57e59f90f166035a0e7cf8a509.zip |
fold `cascade` functionality into `collapse_vars` (#2586)
Diffstat (limited to 'test')
-rw-r--r-- | test/compress/asm.js | 1 | ||||
-rw-r--r-- | test/compress/collapse_vars.js | 169 | ||||
-rw-r--r-- | test/compress/conditionals.js | 4 | ||||
-rw-r--r-- | test/compress/drop-unused.js | 10 | ||||
-rw-r--r-- | test/compress/functions.js | 6 | ||||
-rw-r--r-- | test/compress/issue-1034.js | 12 | ||||
-rw-r--r-- | test/compress/issue-1105.js | 2 | ||||
-rw-r--r-- | test/compress/issue-1261.js | 78 | ||||
-rw-r--r-- | test/compress/issue-1275.js | 1 | ||||
-rw-r--r-- | test/compress/issue-1447.js | 1 | ||||
-rw-r--r-- | test/compress/issue-1639.js | 6 | ||||
-rw-r--r-- | test/compress/issue-1656.js | 1 | ||||
-rw-r--r-- | test/compress/issue-281.js | 4 | ||||
-rw-r--r-- | test/compress/issue-368.js | 4 | ||||
-rw-r--r-- | test/compress/issue-892.js | 1 | ||||
-rw-r--r-- | test/compress/issue-976.js | 2 | ||||
-rw-r--r-- | test/compress/issue-979.js | 4 | ||||
-rw-r--r-- | test/compress/pure_getters.js | 12 | ||||
-rw-r--r-- | test/compress/reduce_vars.js | 2 | ||||
-rw-r--r-- | test/compress/return_undefined.js | 1 | ||||
-rw-r--r-- | test/compress/sequences.js | 43 |
21 files changed, 234 insertions, 130 deletions
diff --git a/test/compress/asm.js b/test/compress/asm.js index 527e6b43..a9047c5d 100644 --- a/test/compress/asm.js +++ b/test/compress/asm.js @@ -16,7 +16,6 @@ asm_mixed: { hoist_vars : true, if_return : true, join_vars : true, - cascade : true, side_effects : true, negate_iife : true }; diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js index 9dd69019..1323116a 100644 --- a/test/compress/collapse_vars.js +++ b/test/compress/collapse_vars.js @@ -2,7 +2,7 @@ collapse_vars_side_effects_1: { options = { collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true, comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true, - keep_fargs:true, if_return:true, join_vars:true, cascade:true, side_effects:true, + keep_fargs:true, if_return:true, join_vars:true, side_effects:true, reduce_funcs: true, reduce_vars:true } input: { @@ -83,7 +83,7 @@ collapse_vars_side_effects_2: { options = { collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true, comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true, - keep_fargs:true, if_return:true, join_vars:true, cascade:true, side_effects:true + keep_fargs:true, if_return:true, join_vars:true, side_effects:true } input: { function fn(x) { return console.log(x), x; } @@ -151,7 +151,7 @@ collapse_vars_issue_721: { options = { collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true, comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true, - keep_fargs:true, if_return:true, join_vars:true, cascade:true, side_effects:true, + keep_fargs:true, if_return:true, join_vars:true, side_effects:true, reduce_funcs: true, reduce_vars:true, passes:2 } input: { @@ -218,7 +218,7 @@ collapse_vars_properties: { options = { collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true, comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true, - keep_fargs:true, if_return:true, join_vars:true, cascade:true, side_effects:true, + keep_fargs:true, if_return:true, join_vars:true, side_effects:true, reduce_funcs: true, reduce_vars:true } input: { @@ -246,7 +246,7 @@ collapse_vars_if: { options = { collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true, comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true, - keep_fargs:true, if_return:true, join_vars:true, cascade:true, side_effects:true, + keep_fargs:true, if_return:true, join_vars:true, side_effects:true, reduce_funcs: true, reduce_vars:true } input: { @@ -297,7 +297,7 @@ collapse_vars_while: { options = { collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true, comparisons:true, evaluate:true, booleans:true, loops:false, unused:true, hoist_funs:true, - keep_fargs:true, if_return:true, join_vars:true, cascade:true, side_effects:true, + keep_fargs:true, if_return:true, join_vars:true, side_effects:true, reduce_funcs: true, reduce_vars:true } input: { @@ -346,7 +346,7 @@ collapse_vars_do_while: { options = { collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true, comparisons:true, evaluate:true, booleans:false, loops:false, unused:"keep_assign", - hoist_funs:true, keep_fargs:true, if_return:true, join_vars:true, cascade:true, + hoist_funs:true, keep_fargs:true, if_return:true, join_vars:true, side_effects:true } input: { @@ -422,7 +422,7 @@ collapse_vars_do_while_drop_assign: { options = { collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true, comparisons:true, evaluate:true, booleans:false, loops:false, unused:true, hoist_funs:true, - keep_fargs:true, if_return:true, join_vars:true, cascade:true, side_effects:true + keep_fargs:true, if_return:true, join_vars:true, side_effects:true } input: { function f1(y) { @@ -497,7 +497,7 @@ collapse_vars_seq: { options = { collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true, comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true, - keep_fargs:true, if_return:true, join_vars:true, cascade:true, side_effects:true + keep_fargs:true, if_return:true, join_vars:true, side_effects:true } input: { var f1 = function(x, y) { @@ -505,20 +505,23 @@ collapse_vars_seq: { a = z, b = 7; return a + b; }; + console.log(f1(1, 2)); } expect: { var f1 = function(x, y) { - var a, b, r = x + y; - return a = r * r - r, b = 7, a + b + var r = x + y; + return r * r - r + 7; }; + console.log(f1(1, 2)); } + expect_stdout: "13" } collapse_vars_throw: { options = { collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true, comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true, - keep_fargs:true, if_return:true, join_vars:true, cascade:true, side_effects:true + keep_fargs:true, if_return:true, join_vars:true, side_effects:true } input: { var f1 = function(x, y) { @@ -526,20 +529,31 @@ collapse_vars_throw: { a = z, b = 7; throw a + b; }; + try { + f1(1, 2); + } catch (e) { + console.log(e); + } } expect: { var f1 = function(x, y) { - var a, b, r = x + y; - throw a = r * r - r, b = 7, a + b + var r = x + y; + throw r * r - r + 7; }; + try { + f1(1, 2); + } catch (e) { + console.log(e); + } } + expect_stdout: "13" } collapse_vars_switch: { options = { collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true, comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true, - keep_fargs:true, if_return:true, join_vars:true, cascade:true, side_effects:true + keep_fargs:true, if_return:true, join_vars:true, side_effects:true } input: { function f1() { @@ -579,7 +593,7 @@ collapse_vars_assignment: { options = { collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true, comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true, - keep_fargs:true, if_return:true, join_vars:true, cascade:true, side_effects:true + keep_fargs:true, if_return:true, join_vars:true, side_effects:true } input: { function log(x) { return console.log(x), x; } @@ -652,7 +666,7 @@ collapse_vars_lvalues: { options = { collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true, comparisons:true, evaluate:true, booleans:true, loops:true, unused:"keep_assign", - hoist_funs:true, keep_fargs:true, if_return:true, join_vars:true, cascade:true, + hoist_funs:true, keep_fargs:true, if_return:true, join_vars:true, side_effects:true } input: { @@ -685,7 +699,7 @@ collapse_vars_lvalues_drop_assign: { options = { collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true, comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true, - keep_fargs:true, if_return:true, join_vars:true, cascade:true, side_effects:true, passes:3 + keep_fargs:true, if_return:true, join_vars:true, side_effects:true, passes:3 } input: { function f0(x) { var i = ++x; return x += i; } @@ -717,7 +731,7 @@ collapse_vars_misc1: { options = { collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true, comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true, - keep_fargs:true, if_return:true, join_vars:true, cascade:true, side_effects:true, + keep_fargs:true, if_return:true, join_vars:true, side_effects:true, reduce_funcs: true, reduce_vars:true } input: { @@ -765,7 +779,7 @@ collapse_vars_self_reference: { collapse_vars:true, unused:false, sequences:true, properties:true, dead_code:true, conditionals:true, comparisons:true, evaluate:true, booleans:true, loops:true, hoist_funs:true, - keep_fargs:true, if_return:true, join_vars:true, cascade:true, side_effects:true + keep_fargs:true, if_return:true, join_vars:true, side_effects:true } input: { // avoid bug in self-referential declaration. @@ -795,7 +809,7 @@ collapse_vars_repeated: { options = { collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true, comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true, - keep_fargs:true, if_return:true, join_vars:true, cascade:true, side_effects:true, + keep_fargs:true, if_return:true, join_vars:true, side_effects:true, reduce_funcs: true, reduce_vars:true } input: { @@ -838,7 +852,7 @@ collapse_vars_closures: { options = { collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true, comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true, - keep_fargs:true, if_return:true, join_vars:true, cascade:true, side_effects:true, + keep_fargs:true, if_return:true, join_vars:true, side_effects:true, reduce_funcs: true, reduce_vars:true } input: { @@ -866,7 +880,7 @@ collapse_vars_unary: { options = { collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true, comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true, - keep_fargs:true, if_return:true, join_vars:true, cascade:true, side_effects:true + keep_fargs:true, if_return:true, join_vars:true, side_effects:true } input: { function f0(o, p) { @@ -929,7 +943,7 @@ collapse_vars_try: { options = { collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true, comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true, - keep_fargs:true, if_return:true, join_vars:true, cascade:true, side_effects:true, + keep_fargs:true, if_return:true, join_vars:true, side_effects:true, reduce_funcs: true, reduce_vars:true } input: { @@ -985,7 +999,7 @@ collapse_vars_array: { options = { collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true, comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true, - keep_fargs:true, if_return:true, join_vars:true, cascade:true, side_effects:true + keep_fargs:true, if_return:true, join_vars:true, side_effects:true } input: { function f1(x, y) { @@ -1019,7 +1033,7 @@ collapse_vars_object: { options = { collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true, comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true, - keep_fargs:true, if_return:true, join_vars:true, cascade:true, side_effects:true + keep_fargs:true, if_return:true, join_vars:true, side_effects:true } input: { function f0(x, y) { @@ -1087,7 +1101,7 @@ collapse_vars_eval_and_with: { options = { collapse_vars:true, sequences:false, properties:true, dead_code:true, conditionals:true, comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true, - keep_fargs:true, if_return:true, join_vars:true, cascade:true, side_effects:true + keep_fargs:true, if_return:true, join_vars:true, side_effects:true } input: { // Don't attempt to collapse vars in presence of eval() or with statement. @@ -1127,7 +1141,7 @@ collapse_vars_constants: { options = { collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true, comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true, - keep_fargs:true, if_return:true, join_vars:true, cascade:true, side_effects:true, + keep_fargs:true, if_return:true, join_vars:true, side_effects:true, reduce_funcs: true, reduce_vars:true } input: { @@ -1165,7 +1179,7 @@ collapse_vars_arguments: { options = { collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true, comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true, - keep_fargs:true, if_return:true, join_vars:true, cascade:true, side_effects:true, + keep_fargs:true, if_return:true, join_vars:true, side_effects:true, toplevel:true, reduce_funcs: true, reduce_vars:true } input: { @@ -1188,7 +1202,7 @@ collapse_vars_short_circuit: { options = { collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true, comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true, - keep_fargs:true, if_return:true, join_vars:true, cascade:true, side_effects:true + keep_fargs:true, if_return:true, join_vars:true, side_effects:true } input: { function f0(x) { var a = foo(), b = bar(); return b || x; } @@ -1241,7 +1255,6 @@ collapse_vars_short_circuited_conditions: { keep_fargs: true, if_return: false, join_vars: true, - cascade: true, side_effects: true, } input: { @@ -1279,7 +1292,6 @@ collapse_vars_short_circuited_conditions: { collapse_vars_regexp: { options = { booleans: true, - cascade: true, collapse_vars: true, comparisons: true, conditionals: true, @@ -1443,7 +1455,6 @@ issue_1605_2: { issue_1631_1: { options = { - cascade: true, collapse_vars: true, hoist_funs: true, join_vars: true, @@ -1479,7 +1490,6 @@ issue_1631_1: { issue_1631_2: { options = { - cascade: true, collapse_vars: true, hoist_funs: true, join_vars: true, @@ -1515,7 +1525,6 @@ issue_1631_2: { issue_1631_3: { options = { - cascade: true, collapse_vars: true, hoist_funs: true, join_vars: true, @@ -1690,7 +1699,7 @@ var_defs: { options = { collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true, comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true, - keep_fargs:true, if_return:true, join_vars:true, cascade:true, side_effects:true + keep_fargs:true, if_return:true, join_vars:true, side_effects:true } input: { var f1 = function(x, y) { @@ -3881,3 +3890,91 @@ recursive_function_replacement: { console.log(f(c)); } } + +cascade_conditional: { + options = { + collapse_vars: true, + } + input: { + function f(a, b) { + (a = x(), a) ? a++ : (b = y(a), b(a)); + } + } + expect: { + function f(a, b) { + (a = x()) ? a++ : (b = y(a))(a); + } + } +} + +cascade_if_1: { + options = { + collapse_vars: true, + } + input: { + var a; + if (a = x(), a) + if (a == y()) z(); + } + expect: { + var a; + if (a = x()) + if (a == y()) z(); + } +} + +cascade_if_2: { + options = { + collapse_vars: true, + } + input: { + function f(a, b) { + if (a(), b = x()) return b; + } + } + expect: { + function f(a, b) { + if (a(), b = x()) return b; + } + } +} + +cascade_return: { + options = { + collapse_vars: true, + } + input: { + function f(a) { + return a = x(); + return a; + } + } + expect: { + function f(a) { + return a = x(); + return a; + } + } +} + +cascade_switch: { + options = { + collapse_vars: true, + } + input: { + function f(a, b) { + switch(a = x(), a) { + case a = x(), b(a): + break; + } + } + } + expect: { + function f(a, b) { + switch(a = x()) { + case b(a = x()): + break; + } + } + } +} diff --git a/test/compress/conditionals.js b/test/compress/conditionals.js index 143ece4a..4d61d39f 100644 --- a/test/compress/conditionals.js +++ b/test/compress/conditionals.js @@ -649,7 +649,7 @@ ternary_boolean_consequent: { options = { collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true, comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true, - keep_fargs:true, if_return:true, join_vars:true, cascade:true, side_effects:true + keep_fargs:true, if_return:true, join_vars:true, side_effects:true } input: { function f1() { return a == b ? true : x; } @@ -677,7 +677,7 @@ ternary_boolean_alternative: { options = { collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true, comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true, - keep_fargs:true, if_return:true, join_vars:true, cascade:true, side_effects:true + keep_fargs:true, if_return:true, join_vars:true, side_effects:true } input: { function f1() { return a == b ? x : true; } diff --git a/test/compress/drop-unused.js b/test/compress/drop-unused.js index f9ef7877..275e0f76 100644 --- a/test/compress/drop-unused.js +++ b/test/compress/drop-unused.js @@ -685,7 +685,7 @@ drop_value: { issue_1539: { options = { - cascade: true, + collapse_vars: true, sequences: true, side_effects: true, unused: true, @@ -732,7 +732,7 @@ vardef_value: { assign_binding: { options = { - cascade: true, + collapse_vars: true, side_effects: true, unused: true, } @@ -1273,7 +1273,7 @@ issue_2226_1: { issue_2226_2: { options = { - cascade: true, + collapse_vars: true, sequences: true, side_effects: true, unused: true, @@ -1286,8 +1286,8 @@ issue_2226_2: { } expect: { console.log(function(a, b) { - return a += b; - }(1, 2)); + return a += 2; + }(1)); } expect_stdout: "3" } diff --git a/test/compress/functions.js b/test/compress/functions.js index 15727fc2..7e87692d 100644 --- a/test/compress/functions.js +++ b/test/compress/functions.js @@ -21,7 +21,7 @@ iifes_returning_constants_keep_fargs_true: { join_vars : true, reduce_funcs : true, reduce_vars : true, - cascade : true, + collapse_vars : true, inline : true, } input: { @@ -58,7 +58,7 @@ iifes_returning_constants_keep_fargs_false: { join_vars : true, reduce_funcs : true, reduce_vars : true, - cascade : true, + collapse_vars : true, inline : true, } input: { @@ -423,9 +423,9 @@ inner_ref: { issue_2107: { options = { - cascade: true, collapse_vars: true, inline: true, + passes: 3, sequences: true, side_effects: true, unused: true, diff --git a/test/compress/issue-1034.js b/test/compress/issue-1034.js index f312408c..860a597f 100644 --- a/test/compress/issue-1034.js +++ b/test/compress/issue-1034.js @@ -2,7 +2,7 @@ non_hoisted_function_after_return: { options = { hoist_funs: false, dead_code: true, conditionals: true, comparisons: true, evaluate: true, booleans: true, loops: true, unused: true, keep_fargs: true, - if_return: true, join_vars: true, cascade: true, side_effects: true + if_return: true, join_vars: true, side_effects: true } input: { function foo(x) { @@ -38,7 +38,7 @@ non_hoisted_function_after_return_2a: { options = { hoist_funs: false, dead_code: true, conditionals: true, comparisons: true, evaluate: true, booleans: true, loops: true, unused: true, keep_fargs: true, - if_return: true, join_vars: true, cascade: true, side_effects: true, + if_return: true, join_vars: true, side_effects: true, collapse_vars: false, passes: 2, warnings: "verbose" } input: { @@ -85,7 +85,7 @@ non_hoisted_function_after_return_2b: { options = { hoist_funs: false, dead_code: true, conditionals: true, comparisons: true, evaluate: true, booleans: true, loops: true, unused: true, keep_fargs: true, - if_return: true, join_vars: true, cascade: true, side_effects: true, + if_return: true, join_vars: true, side_effects: true, collapse_vars: false } input: { @@ -123,7 +123,7 @@ non_hoisted_function_after_return_strict: { options = { hoist_funs: false, dead_code: true, conditionals: true, comparisons: true, evaluate: true, booleans: true, loops: true, unused: true, keep_fargs: true, - if_return: true, join_vars: true, cascade: true, side_effects: true + if_return: true, join_vars: true, side_effects: true } input: { "use strict"; @@ -164,7 +164,7 @@ non_hoisted_function_after_return_2a_strict: { options = { hoist_funs: false, dead_code: true, conditionals: true, comparisons: true, evaluate: true, booleans: true, loops: true, unused: true, keep_fargs: true, - if_return: true, join_vars: true, cascade: true, side_effects: true, + if_return: true, join_vars: true, side_effects: true, collapse_vars: false, passes: 2, warnings: "verbose" } input: { @@ -216,7 +216,7 @@ non_hoisted_function_after_return_2b_strict: { options = { hoist_funs: false, dead_code: true, conditionals: true, comparisons: true, evaluate: true, booleans: true, loops: true, unused: true, keep_fargs: true, - if_return: true, join_vars: true, cascade: true, side_effects: true, + if_return: true, join_vars: true, side_effects: true, collapse_vars: false } input: { diff --git a/test/compress/issue-1105.js b/test/compress/issue-1105.js index ea957930..151ca810 100644 --- a/test/compress/issue-1105.js +++ b/test/compress/issue-1105.js @@ -190,7 +190,6 @@ assorted_Infinity_NaN_undefined_in_with_scope: { keep_fargs: true, if_return: true, join_vars: true, - cascade: true, side_effects: true, sequences: false, keep_infinity: false, @@ -253,7 +252,6 @@ assorted_Infinity_NaN_undefined_in_with_scope_keep_infinity: { keep_fargs: true, if_return: true, join_vars: true, - cascade: true, side_effects: true, sequences: false, keep_infinity: true, diff --git a/test/compress/issue-1261.js b/test/compress/issue-1261.js index 994a00b3..9f4f466f 100644 --- a/test/compress/issue-1261.js +++ b/test/compress/issue-1261.js @@ -8,7 +8,6 @@ pure_function_calls: { unused : true, if_return : true, join_vars : true, - cascade : true, negate_iife : true, } input: { @@ -49,13 +48,13 @@ pure_function_calls: { a.b(), f.g(); } expect_warnings: [ - "WARN: Dropping __PURE__ call [test/compress/issue-1261.js:17,8]", - "WARN: Dropping side-effect-free statement [test/compress/issue-1261.js:17,8]", - "WARN: Dropping __PURE__ call [test/compress/issue-1261.js:30,37]", - "WARN: Dropping unused variable iife2 [test/compress/issue-1261.js:30,16]", - "WARN: Dropping side-effect-free statement [test/compress/issue-1261.js:28,8]", - "WARN: Dropping __PURE__ call [test/compress/issue-1261.js:38,8]", - "WARN: Dropping __PURE__ call [test/compress/issue-1261.js:39,31]", + "WARN: Dropping __PURE__ call [test/compress/issue-1261.js:16,8]", + "WARN: Dropping side-effect-free statement [test/compress/issue-1261.js:16,8]", + "WARN: Dropping __PURE__ call [test/compress/issue-1261.js:29,37]", + "WARN: Dropping unused variable iife2 [test/compress/issue-1261.js:29,16]", + "WARN: Dropping side-effect-free statement [test/compress/issue-1261.js:27,8]", + "WARN: Dropping __PURE__ call [test/compress/issue-1261.js:37,8]", + "WARN: Dropping __PURE__ call [test/compress/issue-1261.js:38,31]", ] } @@ -69,7 +68,6 @@ pure_function_calls_toplevel: { unused : true, if_return : true, join_vars : true, - cascade : true, negate_iife : true, toplevel : true, } @@ -112,17 +110,17 @@ pure_function_calls_toplevel: { a.b(), f.g(); } expect_warnings: [ - "WARN: Dropping __PURE__ call [test/compress/issue-1261.js:79,8]", - "WARN: Dropping side-effect-free statement [test/compress/issue-1261.js:79,8]", - "WARN: Dropping __PURE__ call [test/compress/issue-1261.js:92,37]", - "WARN: Dropping unused variable iife2 [test/compress/issue-1261.js:92,16]", - "WARN: Dropping side-effect-free statement [test/compress/issue-1261.js:90,8]", - "WARN: Dropping __PURE__ call [test/compress/issue-1261.js:107,8]", - "WARN: Dropping __PURE__ call [test/compress/issue-1261.js:108,31]", - "WARN: Dropping __PURE__ call [test/compress/issue-1261.js:84,33]", - "WARN: Dropping unused variable iife1 [test/compress/issue-1261.js:84,12]", - "WARN: Dropping __PURE__ call [test/compress/issue-1261.js:100,45]", - "WARN: Dropping unused variable MyClass [test/compress/issue-1261.js:100,12]", + "WARN: Dropping __PURE__ call [test/compress/issue-1261.js:77,8]", + "WARN: Dropping side-effect-free statement [test/compress/issue-1261.js:77,8]", + "WARN: Dropping __PURE__ call [test/compress/issue-1261.js:90,37]", + "WARN: Dropping unused variable iife2 [test/compress/issue-1261.js:90,16]", + "WARN: Dropping side-effect-free statement [test/compress/issue-1261.js:88,8]", + "WARN: Dropping __PURE__ call [test/compress/issue-1261.js:105,8]", + "WARN: Dropping __PURE__ call [test/compress/issue-1261.js:106,31]", + "WARN: Dropping __PURE__ call [test/compress/issue-1261.js:82,33]", + "WARN: Dropping unused variable iife1 [test/compress/issue-1261.js:82,12]", + "WARN: Dropping __PURE__ call [test/compress/issue-1261.js:98,45]", + "WARN: Dropping unused variable MyClass [test/compress/issue-1261.js:98,12]", ] } @@ -157,29 +155,29 @@ should_warn: { baz(); } expect_warnings: [ - "WARN: Dropping __PURE__ call [test/compress/issue-1261.js:137,61]", - "WARN: Dropping __PURE__ call [test/compress/issue-1261.js:137,23]", - "WARN: Dropping side-effect-free statement [test/compress/issue-1261.js:137,23]", - "WARN: Boolean || always true [test/compress/issue-1261.js:138,23]", + "WARN: Dropping __PURE__ call [test/compress/issue-1261.js:135,61]", + "WARN: Dropping __PURE__ call [test/compress/issue-1261.js:135,23]", + "WARN: Dropping side-effect-free statement [test/compress/issue-1261.js:135,23]", + "WARN: Boolean || always true [test/compress/issue-1261.js:136,23]", + "WARN: Dropping __PURE__ call [test/compress/issue-1261.js:136,23]", + "WARN: Condition always true [test/compress/issue-1261.js:136,23]", + "WARN: Condition left of || always true [test/compress/issue-1261.js:137,8]", + "WARN: Condition always true [test/compress/issue-1261.js:137,8]", + "WARN: Boolean && always false [test/compress/issue-1261.js:138,23]", "WARN: Dropping __PURE__ call [test/compress/issue-1261.js:138,23]", - "WARN: Condition always true [test/compress/issue-1261.js:138,23]", - "WARN: Condition left of || always true [test/compress/issue-1261.js:139,8]", - "WARN: Condition always true [test/compress/issue-1261.js:139,8]", - "WARN: Boolean && always false [test/compress/issue-1261.js:140,23]", + "WARN: Condition always false [test/compress/issue-1261.js:138,23]", + "WARN: Condition left of && always false [test/compress/issue-1261.js:139,8]", + "WARN: Condition always false [test/compress/issue-1261.js:139,8]", + "WARN: + in boolean context always true [test/compress/issue-1261.js:140,23]", "WARN: Dropping __PURE__ call [test/compress/issue-1261.js:140,23]", - "WARN: Condition always false [test/compress/issue-1261.js:140,23]", - "WARN: Condition left of && always false [test/compress/issue-1261.js:141,8]", - "WARN: Condition always false [test/compress/issue-1261.js:141,8]", - "WARN: + in boolean context always true [test/compress/issue-1261.js:142,23]", + "WARN: Condition always true [test/compress/issue-1261.js:140,23]", + "WARN: + in boolean context always true [test/compress/issue-1261.js:141,8]", + "WARN: Dropping __PURE__ call [test/compress/issue-1261.js:141,31]", + "WARN: Condition always true [test/compress/issue-1261.js:141,8]", "WARN: Dropping __PURE__ call [test/compress/issue-1261.js:142,23]", - "WARN: Condition always true [test/compress/issue-1261.js:142,23]", - "WARN: + in boolean context always true [test/compress/issue-1261.js:143,8]", - "WARN: Dropping __PURE__ call [test/compress/issue-1261.js:143,31]", + "WARN: Dropping __PURE__ call [test/compress/issue-1261.js:143,24]", "WARN: Condition always true [test/compress/issue-1261.js:143,8]", - "WARN: Dropping __PURE__ call [test/compress/issue-1261.js:144,23]", - "WARN: Dropping __PURE__ call [test/compress/issue-1261.js:145,24]", - "WARN: Condition always true [test/compress/issue-1261.js:145,8]", - "WARN: Dropping __PURE__ call [test/compress/issue-1261.js:146,31]", - "WARN: Condition always false [test/compress/issue-1261.js:146,8]", + "WARN: Dropping __PURE__ call [test/compress/issue-1261.js:144,31]", + "WARN: Condition always false [test/compress/issue-1261.js:144,8]", ] } diff --git a/test/compress/issue-1275.js b/test/compress/issue-1275.js index 5d4f5b70..2553c74f 100644 --- a/test/compress/issue-1275.js +++ b/test/compress/issue-1275.js @@ -9,7 +9,6 @@ string_plus_optimization: { unused : true, if_return : true, join_vars : true, - cascade : true, hoist_funs : true, }; input: { diff --git a/test/compress/issue-1447.js b/test/compress/issue-1447.js index a7f35e5a..0a765685 100644 --- a/test/compress/issue-1447.js +++ b/test/compress/issue-1447.js @@ -32,7 +32,6 @@ conditional_false_stray_else_in_loop: { hoist_vars : true, join_vars : true, if_return : true, - cascade : true, conditionals : false, } input: { diff --git a/test/compress/issue-1639.js b/test/compress/issue-1639.js index fc3db983..80d45a76 100644 --- a/test/compress/issue-1639.js +++ b/test/compress/issue-1639.js @@ -2,7 +2,7 @@ issue_1639_1: { options = { booleans: true, - cascade: true, + collapse_vars: true, conditionals: true, evaluate: true, join_vars: true, @@ -35,7 +35,7 @@ issue_1639_1: { issue_1639_2: { options = { booleans: true, - cascade: true, + collapse_vars: true, conditionals: true, evaluate: true, join_vars: true, @@ -68,7 +68,7 @@ issue_1639_2: { issue_1639_3: { options = { booleans: true, - cascade: true, + collapse_vars: true, conditionals: true, evaluate: true, sequences: true, diff --git a/test/compress/issue-1656.js b/test/compress/issue-1656.js index 27d87652..e44e2094 100644 --- a/test/compress/issue-1656.js +++ b/test/compress/issue-1656.js @@ -1,7 +1,6 @@ f7: { options = { booleans: true, - cascade: true, collapse_vars: true, comparisons: true, conditionals: true, diff --git a/test/compress/issue-281.js b/test/compress/issue-281.js index 6a93136f..1e532dfb 100644 --- a/test/compress/issue-281.js +++ b/test/compress/issue-281.js @@ -453,7 +453,7 @@ pure_annotation_2: { drop_fargs: { options = { - cascade: true, + collapse_vars: true, inline: true, keep_fargs: false, side_effects: true, @@ -476,7 +476,7 @@ drop_fargs: { keep_fargs: { options = { - cascade: true, + collapse_vars: true, inline: true, keep_fargs: true, side_effects: true, diff --git a/test/compress/issue-368.js b/test/compress/issue-368.js index 5960aa64..b0491c29 100644 --- a/test/compress/issue-368.js +++ b/test/compress/issue-368.js @@ -1,6 +1,6 @@ collapse: { options = { - cascade: true, + collapse_vars: true, sequences: true, side_effects: true, unused: true, @@ -41,7 +41,7 @@ collapse: { return void 0 !== ('function' === typeof b ? b() : b) && c(); } function f2(b) { - return b = c(), 'stirng' == typeof ('function' === typeof b ? b() : b) && d(); + return 'stirng' == typeof ('function' === typeof (b = c()) ? b() : b) && d(); } function f3(c) { var a; diff --git a/test/compress/issue-892.js b/test/compress/issue-892.js index b6938c42..81df1cab 100644 --- a/test/compress/issue-892.js +++ b/test/compress/issue-892.js @@ -18,7 +18,6 @@ dont_mangle_arguments: { hoist_vars : true, if_return : true, join_vars : true, - cascade : true, side_effects : true, negate_iife : false }; diff --git a/test/compress/issue-976.js b/test/compress/issue-976.js index b711051b..54d7dad5 100644 --- a/test/compress/issue-976.js +++ b/test/compress/issue-976.js @@ -2,7 +2,7 @@ eval_collapse_vars: { options = { collapse_vars:true, sequences:false, properties:true, dead_code:true, conditionals:true, comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true, - keep_fargs:true, if_return:true, join_vars:true, cascade:true, side_effects:true + keep_fargs:true, if_return:true, join_vars:true, side_effects:true }; input: { function f1() { diff --git a/test/compress/issue-979.js b/test/compress/issue-979.js index 7ed5801d..b2500126 100644 --- a/test/compress/issue-979.js +++ b/test/compress/issue-979.js @@ -2,7 +2,7 @@ issue979_reported: { options = { sequences:true, properties:true, dead_code:true, conditionals:true, comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true, - keep_fargs:true, if_return:true, join_vars:true, cascade:true, side_effects:true + keep_fargs:true, if_return:true, join_vars:true, side_effects:true } input: { function f1() { @@ -32,7 +32,7 @@ issue979_test_negated_is_best: { options = { sequences:true, properties:true, dead_code:true, conditionals:true, comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true, - keep_fargs:true, if_return:true, join_vars:true, cascade:true, side_effects:true + keep_fargs:true, if_return:true, join_vars:true, side_effects:true } input: { function f3() { diff --git a/test/compress/pure_getters.js b/test/compress/pure_getters.js index 5c16b2cd..4174bc1b 100644 --- a/test/compress/pure_getters.js +++ b/test/compress/pure_getters.js @@ -185,7 +185,7 @@ impure_getter_2: { issue_2110_1: { options = { - cascade: true, + collapse_vars: true, pure_getters: "strict", sequences: true, side_effects: true, @@ -274,7 +274,7 @@ set_immutable_1: { set_immutable_2: { options = { - cascade: true, + collapse_vars: true, conditionals: true, pure_getters: "strict", reduce_funcs: true, @@ -324,7 +324,7 @@ set_immutable_3: { set_immutable_4: { options = { - cascade: true, + collapse_vars: true, conditionals: true, pure_getters: "strict", reduce_funcs: true, @@ -375,7 +375,7 @@ set_mutable_1: { set_mutable_2: { options = { - cascade: true, + collapse_vars: true, conditionals: true, pure_getters: "strict", reduce_funcs: true, @@ -400,7 +400,7 @@ set_mutable_2: { issue_2313_1: { options = { - cascade: true, + collapse_vars: true, conditionals: true, pure_getters: "strict", sequences: true, @@ -446,7 +446,7 @@ issue_2313_1: { issue_2313_2: { options = { - cascade: true, + collapse_vars: true, conditionals: true, pure_getters: true, sequences: true, diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js index 6c8bd639..504ce6f0 100644 --- a/test/compress/reduce_vars.js +++ b/test/compress/reduce_vars.js @@ -2262,7 +2262,7 @@ redefine_farg_2: { redefine_farg_3: { options = { - cascade: true, + collapse_vars: true, evaluate: true, inline: true, keep_fargs: false, diff --git a/test/compress/return_undefined.js b/test/compress/return_undefined.js index 4d2b4257..c7e09067 100644 --- a/test/compress/return_undefined.js +++ b/test/compress/return_undefined.js @@ -17,7 +17,6 @@ return_undefined: { keep_fnames : false, hoist_vars : true, join_vars : true, - cascade : true, negate_iife : true }; input: { diff --git a/test/compress/sequences.js b/test/compress/sequences.js index 26f38c25..81b06881 100644 --- a/test/compress/sequences.js +++ b/test/compress/sequences.js @@ -317,7 +317,7 @@ unsafe_undefined: { issue_1685: { options = { - cascade: true, + collapse_vars: true, side_effects: true, } input: { @@ -341,7 +341,7 @@ issue_1685: { func_def_1: { options = { - cascade: true, + collapse_vars: true, side_effects: true, } input: { @@ -361,7 +361,7 @@ func_def_1: { func_def_2: { options = { - cascade: true, + collapse_vars: true, side_effects: true, } input: { @@ -379,7 +379,7 @@ func_def_2: { func_def_3: { options = { - cascade: true, + collapse_vars: true, side_effects: true, } input: { @@ -401,7 +401,7 @@ func_def_3: { func_def_4: { options = { - cascade: true, + collapse_vars: true, side_effects: true, } input: { @@ -427,7 +427,7 @@ func_def_4: { func_def_5: { options = { - cascade: true, + collapse_vars: true, side_effects: true, } input: { @@ -634,7 +634,7 @@ side_effects: { side_effects_cascade_1: { options = { - cascade: true, + collapse_vars: true, conditionals: true, sequences: true, side_effects: true, @@ -655,7 +655,7 @@ side_effects_cascade_1: { side_effects_cascade_2: { options = { - cascade: true, + collapse_vars: true, side_effects: true, } input: { @@ -677,7 +677,7 @@ side_effects_cascade_2: { side_effects_cascade_3: { options = { - cascade: true, + collapse_vars: true, conditionals: true, side_effects: true, } @@ -692,14 +692,14 @@ side_effects_cascade_3: { expect: { function f(a, b) { !(b += a) && ((b = a) || (b -= a, b ^= a)), - --a; + a--; } } } issue_27: { options = { - cascade: true, + collapse_vars: true, passes: 2, sequences: true, side_effects: true, @@ -722,7 +722,7 @@ issue_27: { issue_2062: { options = { booleans: true, - cascade: true, + collapse_vars: true, conditionals: true, side_effects: true, } @@ -741,7 +741,7 @@ issue_2062: { issue_2313: { options = { - cascade: true, + collapse_vars: true, sequences: true, side_effects: true, } @@ -779,3 +779,20 @@ issue_2313: { } expect_stdout: "2 1" } + +cascade_assignment_in_return: { + options = { + collapse_vars: true, + unused: true, + } + input: { + function f(a, b) { + return a = x(), b(a); + } + } + expect: { + function f(a, b) { + return b(x()); + } + } +} |