Compare commits
10 Commits
harmony-v3
...
harmony-v3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e595171b9 | ||
|
|
6973abbfe1 | ||
|
|
4eb4cb656c | ||
|
|
193612ac67 | ||
|
|
95cfce68ea | ||
|
|
e0461dc3c8 | ||
|
|
ec4202590d | ||
|
|
5e2cd07d6f | ||
|
|
bea9dbd812 | ||
|
|
bc01a85ba0 |
@@ -1759,7 +1759,7 @@ merge(Compressor.prototype, {
|
|||||||
var stat = null;
|
var stat = null;
|
||||||
for (var i = 0, len = block.body.length; i < len; i++) {
|
for (var i = 0, len = block.body.length; i < len; i++) {
|
||||||
var line = block.body[i];
|
var line = block.body[i];
|
||||||
if (line instanceof AST_Definitions && declarations_only(line)) {
|
if (line instanceof AST_Var && declarations_only(line)) {
|
||||||
decls.push(line);
|
decls.push(line);
|
||||||
} else if (stat) {
|
} else if (stat) {
|
||||||
return false;
|
return false;
|
||||||
@@ -1803,7 +1803,9 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (stat instanceof AST_ForIn) {
|
} else if (stat instanceof AST_ForIn) {
|
||||||
stat.object = cons_seq(stat.object);
|
if (!(stat.init instanceof AST_Const) && !(stat.init instanceof AST_Let)) {
|
||||||
|
stat.object = cons_seq(stat.object);
|
||||||
|
}
|
||||||
} else if (stat instanceof AST_If) {
|
} else if (stat instanceof AST_If) {
|
||||||
stat.condition = cons_seq(stat.condition);
|
stat.condition = cons_seq(stat.condition);
|
||||||
} else if (stat instanceof AST_Switch) {
|
} else if (stat instanceof AST_Switch) {
|
||||||
@@ -3238,9 +3240,11 @@ merge(Compressor.prototype, {
|
|||||||
if (var_defs.length > 1 && (!def.value || sym.orig.indexOf(def.name) > sym.eliminated)) {
|
if (var_defs.length > 1 && (!def.value || sym.orig.indexOf(def.name) > sym.eliminated)) {
|
||||||
compressor.warn("Dropping duplicated definition of variable {name} [{file}:{line},{col}]", template(def.name));
|
compressor.warn("Dropping duplicated definition of variable {name} [{file}:{line},{col}]", template(def.name));
|
||||||
if (def.value) {
|
if (def.value) {
|
||||||
|
var ref = make_node(AST_SymbolRef, def.name, def.name);
|
||||||
|
sym.references.push(ref);
|
||||||
var assign = make_node(AST_Assign, def, {
|
var assign = make_node(AST_Assign, def, {
|
||||||
operator: "=",
|
operator: "=",
|
||||||
left: make_node(AST_SymbolRef, def.name, def.name),
|
left: ref,
|
||||||
right: def.value
|
right: def.value
|
||||||
});
|
});
|
||||||
if (fixed_ids[sym.id] === def) {
|
if (fixed_ids[sym.id] === def) {
|
||||||
@@ -3692,8 +3696,10 @@ merge(Compressor.prototype, {
|
|||||||
while (left instanceof AST_PropAccess) {
|
while (left instanceof AST_PropAccess) {
|
||||||
left = left.expression;
|
left = left.expression;
|
||||||
}
|
}
|
||||||
if (left instanceof AST_Symbol) return this;
|
if (left.is_constant_expression(compressor.find_parent(AST_Scope))) {
|
||||||
return this.right.drop_side_effect_free(compressor);
|
return this.right.drop_side_effect_free(compressor);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
});
|
});
|
||||||
def(AST_Conditional, function(compressor){
|
def(AST_Conditional, function(compressor){
|
||||||
var consequent = this.consequent.drop_side_effect_free(compressor);
|
var consequent = this.consequent.drop_side_effect_free(compressor);
|
||||||
|
|||||||
@@ -772,6 +772,7 @@ function OutputStream(options) {
|
|||||||
|| p instanceof AST_DefaultAssign // x => (x = (0, function(){}))
|
|| p instanceof AST_DefaultAssign // x => (x = (0, function(){}))
|
||||||
|| p instanceof AST_Expansion // [...(a, b)]
|
|| p instanceof AST_Expansion // [...(a, b)]
|
||||||
|| p instanceof AST_ForOf && this === p.object // for (e of (foo, bar)) {}
|
|| p instanceof AST_ForOf && this === p.object // for (e of (foo, bar)) {}
|
||||||
|
|| p instanceof AST_Yield // yield (foo, bar)
|
||||||
;
|
;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -411,7 +411,7 @@ AST_Scope.DEFMETHOD("find_variable", function(name){
|
|||||||
|
|
||||||
AST_Scope.DEFMETHOD("def_function", function(symbol, init){
|
AST_Scope.DEFMETHOD("def_function", function(symbol, init){
|
||||||
var def = this.def_variable(symbol, init);
|
var def = this.def_variable(symbol, init);
|
||||||
if (!def.init) def.init = init;
|
if (!def.init || def.init instanceof AST_Defun) def.init = init;
|
||||||
this.functions.set(symbol.name, def);
|
this.functions.set(symbol.name, def);
|
||||||
return def;
|
return def;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"homepage": "https://github.com/mishoo/UglifyJS2/tree/harmony",
|
"homepage": "https://github.com/mishoo/UglifyJS2/tree/harmony",
|
||||||
"author": "Mihai Bazon <mihai.bazon@gmail.com> (http://lisperator.net/)",
|
"author": "Mihai Bazon <mihai.bazon@gmail.com> (http://lisperator.net/)",
|
||||||
"license": "BSD-2-Clause",
|
"license": "BSD-2-Clause",
|
||||||
"version": "3.3.8",
|
"version": "3.3.9",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.8.0"
|
"node": ">=0.8.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ issue_1664: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "1"
|
expect_stdout: "1"
|
||||||
node_version: ">=6"
|
node_version: ">=6"
|
||||||
|
reminify: false // FIXME - block scoped function
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_1672_for: {
|
issue_1672_for: {
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ dead_code_2_should_warn: {
|
|||||||
}
|
}
|
||||||
expect_stdout: true
|
expect_stdout: true
|
||||||
node_version: ">=6"
|
node_version: ">=6"
|
||||||
|
reminify: false // FIXME - block scoped function
|
||||||
}
|
}
|
||||||
|
|
||||||
dead_code_2_should_warn_strict: {
|
dead_code_2_should_warn_strict: {
|
||||||
@@ -100,6 +101,7 @@ dead_code_2_should_warn_strict: {
|
|||||||
}
|
}
|
||||||
expect_stdout: true
|
expect_stdout: true
|
||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
|
reminify: false // FIXME - block scoped function
|
||||||
}
|
}
|
||||||
|
|
||||||
dead_code_constant_boolean_should_warn_more: {
|
dead_code_constant_boolean_should_warn_more: {
|
||||||
@@ -135,6 +137,7 @@ dead_code_constant_boolean_should_warn_more: {
|
|||||||
}
|
}
|
||||||
expect_stdout: true
|
expect_stdout: true
|
||||||
node_version: ">=6"
|
node_version: ">=6"
|
||||||
|
reminify: false // FIXME - block scoped function
|
||||||
}
|
}
|
||||||
|
|
||||||
dead_code_constant_boolean_should_warn_more_strict: {
|
dead_code_constant_boolean_should_warn_more_strict: {
|
||||||
@@ -171,6 +174,7 @@ dead_code_constant_boolean_should_warn_more_strict: {
|
|||||||
}
|
}
|
||||||
expect_stdout: true
|
expect_stdout: true
|
||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
|
reminify: false // FIXME - block scoped function
|
||||||
}
|
}
|
||||||
|
|
||||||
dead_code_block_decls_die: {
|
dead_code_block_decls_die: {
|
||||||
|
|||||||
@@ -2066,3 +2066,30 @@ issue_2768: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "PASS undefined"
|
expect_stdout: "PASS undefined"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_2846: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f(a, b) {
|
||||||
|
var a = 0;
|
||||||
|
b && b(a);
|
||||||
|
return a++;
|
||||||
|
}
|
||||||
|
var c = f();
|
||||||
|
console.log(c);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var c = function(a, b) {
|
||||||
|
a = 0;
|
||||||
|
b && b(a);
|
||||||
|
return a++;
|
||||||
|
}();
|
||||||
|
console.log(c);
|
||||||
|
}
|
||||||
|
expect_stdout: "0"
|
||||||
|
}
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ same_variable_in_multiple_for_loop: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
expect_stdout: true
|
expect_stdout: true
|
||||||
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
||||||
same_variable_in_multiple_forOf: {
|
same_variable_in_multiple_forOf: {
|
||||||
@@ -79,6 +80,7 @@ same_variable_in_multiple_forOf: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
expect_stdout: true
|
expect_stdout: true
|
||||||
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
||||||
same_variable_in_multiple_forIn: {
|
same_variable_in_multiple_forIn: {
|
||||||
@@ -120,6 +122,7 @@ same_variable_in_multiple_forIn: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
expect_stdout: true
|
expect_stdout: true
|
||||||
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
||||||
different_variable_in_multiple_for_loop: {
|
different_variable_in_multiple_for_loop: {
|
||||||
@@ -162,6 +165,7 @@ different_variable_in_multiple_for_loop: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
expect_stdout: true
|
expect_stdout: true
|
||||||
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
||||||
different_variable_in_multiple_forOf: {
|
different_variable_in_multiple_forOf: {
|
||||||
@@ -203,6 +207,7 @@ different_variable_in_multiple_forOf: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
expect_stdout: true
|
expect_stdout: true
|
||||||
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
||||||
different_variable_in_multiple_forIn: {
|
different_variable_in_multiple_forIn: {
|
||||||
@@ -244,6 +249,175 @@ different_variable_in_multiple_forIn: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
expect_stdout: true
|
expect_stdout: true
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|
||||||
|
same_variable_in_multiple_forOf_sequences_let: {
|
||||||
|
options = {
|
||||||
|
hoist_funs: true,
|
||||||
|
dead_code: true,
|
||||||
|
conditionals: true,
|
||||||
|
comparisons: true,
|
||||||
|
evaluate: true,
|
||||||
|
booleans: true,
|
||||||
|
loops: true,
|
||||||
|
unused: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
collapse_vars: true,
|
||||||
|
}
|
||||||
|
mangle = {}
|
||||||
|
input: {
|
||||||
|
var test = [ "a", "b", "c" ];
|
||||||
|
for (let tmp of test) {
|
||||||
|
console.log(tmp);
|
||||||
|
let dd;
|
||||||
|
dd = [ "e", "f", "g" ];
|
||||||
|
for (let tmp of dd) {
|
||||||
|
console.log(tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var test = [ "a", "b", "c" ];
|
||||||
|
for (let o of test) {
|
||||||
|
let e;
|
||||||
|
console.log(o), e = [ "e", "f", "g" ];
|
||||||
|
for (let o of e)
|
||||||
|
console.log(o);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: true
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|
||||||
|
same_variable_in_multiple_forOf_sequences_const: {
|
||||||
|
options = {
|
||||||
|
hoist_funs: true,
|
||||||
|
dead_code: true,
|
||||||
|
conditionals: true,
|
||||||
|
comparisons: true,
|
||||||
|
evaluate: true,
|
||||||
|
booleans: true,
|
||||||
|
loops: true,
|
||||||
|
unused: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
collapse_vars: true,
|
||||||
|
}
|
||||||
|
mangle = {}
|
||||||
|
input: {
|
||||||
|
var test = [ "a", "b", "c" ];
|
||||||
|
for (const tmp of test) {
|
||||||
|
console.log(tmp);
|
||||||
|
let dd;
|
||||||
|
dd = [ "e", "f", "g" ];
|
||||||
|
for (const tmp of dd) {
|
||||||
|
console.log(tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var test = [ "a", "b", "c" ];
|
||||||
|
for (const o of test) {
|
||||||
|
let t;
|
||||||
|
console.log(o), t = [ "e", "f", "g" ];
|
||||||
|
for (const o of t)
|
||||||
|
console.log(o);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: true
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|
||||||
|
same_variable_in_multiple_forIn_sequences_let: {
|
||||||
|
options = {
|
||||||
|
hoist_funs: true,
|
||||||
|
dead_code: true,
|
||||||
|
conditionals: true,
|
||||||
|
comparisons: true,
|
||||||
|
evaluate: true,
|
||||||
|
booleans: true,
|
||||||
|
loops: true,
|
||||||
|
unused: false,
|
||||||
|
keep_fargs: true,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
collapse_vars: true,
|
||||||
|
}
|
||||||
|
mangle = {}
|
||||||
|
input: {
|
||||||
|
var test = [ "a", "b", "c" ];
|
||||||
|
for (let tmp in test) {
|
||||||
|
console.log(tmp);
|
||||||
|
let dd;
|
||||||
|
dd = [ "e", "f", "g" ];
|
||||||
|
for (let tmp in test) {
|
||||||
|
console.log(tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var test = [ "a", "b", "c" ];
|
||||||
|
for (let e in test) {
|
||||||
|
let t;
|
||||||
|
console.log(e), t = [ "e", "f", "g" ];
|
||||||
|
for (let e in test)
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: true
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|
||||||
|
same_variable_in_multiple_forIn_sequences_const: {
|
||||||
|
options = {
|
||||||
|
hoist_funs: true,
|
||||||
|
dead_code: true,
|
||||||
|
conditionals: true,
|
||||||
|
comparisons: true,
|
||||||
|
evaluate: true,
|
||||||
|
booleans: true,
|
||||||
|
loops: true,
|
||||||
|
unused: false,
|
||||||
|
keep_fargs: true,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
collapse_vars: true,
|
||||||
|
}
|
||||||
|
mangle = {}
|
||||||
|
input: {
|
||||||
|
var test = [ "a", "b", "c" ];
|
||||||
|
for (const tmp in test) {
|
||||||
|
console.log(tmp);
|
||||||
|
let dd;
|
||||||
|
dd = [ "e", "f", "g" ];
|
||||||
|
for (const tmp in test) {
|
||||||
|
console.log(tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var test = [ "a", "b", "c" ];
|
||||||
|
for (const o in test) {
|
||||||
|
let t;
|
||||||
|
console.log(o), t = [ "e", "f", "g" ];
|
||||||
|
for (const o in test)
|
||||||
|
console.log(o);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: true
|
||||||
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
||||||
more_variable_in_multiple_for: {
|
more_variable_in_multiple_for: {
|
||||||
@@ -281,4 +455,5 @@ more_variable_in_multiple_for: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
expect_stdout: true
|
expect_stdout: true
|
||||||
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -818,3 +818,30 @@ issue_2678: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_2838: {
|
||||||
|
options = {
|
||||||
|
pure_getters: true,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f(a, b) {
|
||||||
|
(a || b).c = "PASS";
|
||||||
|
(function() {
|
||||||
|
return f(a, b);
|
||||||
|
}).prototype.foo = "bar";
|
||||||
|
}
|
||||||
|
var o = {};
|
||||||
|
f(null, o);
|
||||||
|
console.log(o.c);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f(a, b) {
|
||||||
|
(a || b).c = "PASS";
|
||||||
|
}
|
||||||
|
var o = {};
|
||||||
|
f(null, o);
|
||||||
|
console.log(o.c);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|||||||
@@ -5950,3 +5950,26 @@ issue_2799_2: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_2836: {
|
||||||
|
options = {
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f() {
|
||||||
|
return "FAIL";
|
||||||
|
}
|
||||||
|
console.log(f());
|
||||||
|
function f() {
|
||||||
|
return "PASS";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(function() {
|
||||||
|
return "PASS";
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|||||||
@@ -211,3 +211,43 @@ issue_2689: {
|
|||||||
}
|
}
|
||||||
expect_exact: "function*y(){return new(yield x())}"
|
expect_exact: "function*y(){return new(yield x())}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_2832: {
|
||||||
|
beautify = {
|
||||||
|
beautify: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function* gen(i) {
|
||||||
|
const result = yield (x = i, -x);
|
||||||
|
var x;
|
||||||
|
console.log(x);
|
||||||
|
console.log(result);
|
||||||
|
yield 2;
|
||||||
|
}
|
||||||
|
var x = gen(1);
|
||||||
|
console.log(x.next("first").value);
|
||||||
|
console.log(x.next("second").value);
|
||||||
|
}
|
||||||
|
expect_exact: [
|
||||||
|
"function* gen(i) {",
|
||||||
|
" const result = yield (x = i, -x);",
|
||||||
|
" var x;",
|
||||||
|
" console.log(x);",
|
||||||
|
" console.log(result);",
|
||||||
|
" yield 2;",
|
||||||
|
"}",
|
||||||
|
"",
|
||||||
|
"var x = gen(1);",
|
||||||
|
"",
|
||||||
|
'console.log(x.next("first").value);',
|
||||||
|
"",
|
||||||
|
'console.log(x.next("second").value);',
|
||||||
|
]
|
||||||
|
expect_stdout: [
|
||||||
|
"-1",
|
||||||
|
"1",
|
||||||
|
"second",
|
||||||
|
"2",
|
||||||
|
]
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|||||||
@@ -208,6 +208,9 @@ function run_compress_tests() {
|
|||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (test.reminify && !reminify(test.options, input_code, input_formatted, test.expect_stdout)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -261,6 +264,16 @@ function parse_test(file) {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function read_boolean(stat) {
|
||||||
|
if (stat.TYPE == "SimpleStatement") {
|
||||||
|
var body = stat.body;
|
||||||
|
if (body instanceof U.AST_Boolean) {
|
||||||
|
return body.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new Error("Should be boolean");
|
||||||
|
}
|
||||||
|
|
||||||
function read_string(stat) {
|
function read_string(stat) {
|
||||||
if (stat.TYPE == "SimpleStatement") {
|
if (stat.TYPE == "SimpleStatement") {
|
||||||
var body = stat.body;
|
var body = stat.body;
|
||||||
@@ -279,7 +292,11 @@ function parse_test(file) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function get_one_test(name, block) {
|
function get_one_test(name, block) {
|
||||||
var test = { name: name, options: {} };
|
var test = {
|
||||||
|
name: name,
|
||||||
|
options: {},
|
||||||
|
reminify: true,
|
||||||
|
};
|
||||||
var tw = new U.TreeWalker(function(node, descend){
|
var tw = new U.TreeWalker(function(node, descend){
|
||||||
if (node instanceof U.AST_Assign) {
|
if (node instanceof U.AST_Assign) {
|
||||||
if (!(node.left instanceof U.AST_SymbolRef)) {
|
if (!(node.left instanceof U.AST_SymbolRef)) {
|
||||||
@@ -299,6 +316,7 @@ function parse_test(file) {
|
|||||||
"expect_warnings",
|
"expect_warnings",
|
||||||
"expect_stdout",
|
"expect_stdout",
|
||||||
"node_version",
|
"node_version",
|
||||||
|
"reminify",
|
||||||
].indexOf(label.name) >= 0,
|
].indexOf(label.name) >= 0,
|
||||||
tmpl("Unsupported label {name} [{line},{col}]", {
|
tmpl("Unsupported label {name} [{line},{col}]", {
|
||||||
name: label.name,
|
name: label.name,
|
||||||
@@ -309,6 +327,9 @@ function parse_test(file) {
|
|||||||
var stat = node.body;
|
var stat = node.body;
|
||||||
if (label.name == "expect_exact" || label.name == "node_version") {
|
if (label.name == "expect_exact" || label.name == "node_version") {
|
||||||
test[label.name] = read_string(stat);
|
test[label.name] = read_string(stat);
|
||||||
|
} else if (label.name == "reminify") {
|
||||||
|
var value = read_boolean(stat);
|
||||||
|
test.reminify = value == null || value;
|
||||||
} else if (label.name == "expect_stdout") {
|
} else if (label.name == "expect_stdout") {
|
||||||
var body = stat.body;
|
var body = stat.body;
|
||||||
if (body instanceof U.AST_Boolean) {
|
if (body instanceof U.AST_Boolean) {
|
||||||
@@ -358,14 +379,17 @@ function evaluate(code) {
|
|||||||
function reminify(orig_options, input_code, input_formatted, expect_stdout) {
|
function reminify(orig_options, input_code, input_formatted, expect_stdout) {
|
||||||
for (var i = 0; i < minify_options.length; i++) {
|
for (var i = 0; i < minify_options.length; i++) {
|
||||||
var options = JSON.parse(minify_options[i]);
|
var options = JSON.parse(minify_options[i]);
|
||||||
if (options.compress) [
|
options.keep_fnames = orig_options.keep_fnames;
|
||||||
"keep_fargs",
|
options.keep_classnames = orig_options.keep_classnames;
|
||||||
"keep_fnames",
|
if (orig_options.compress) {
|
||||||
].forEach(function(name) {
|
options.compress.keep_classnames = orig_options.compress.keep_classnames;
|
||||||
if (name in orig_options) {
|
options.compress.keep_fargs = orig_options.compress.keep_fargs;
|
||||||
options.compress[name] = orig_options[name];
|
options.compress.keep_fnames = orig_options.compress.keep_fnames;
|
||||||
}
|
}
|
||||||
});
|
if (orig_options.mangle) {
|
||||||
|
options.mangle.keep_classnames = orig_options.mangle.keep_classnames;
|
||||||
|
options.mangle.keep_fnames = orig_options.mangle.keep_fnames;
|
||||||
|
}
|
||||||
var options_formatted = JSON.stringify(options, null, 4);
|
var options_formatted = JSON.stringify(options, null, 4);
|
||||||
var result = U.minify(input_code, options);
|
var result = U.minify(input_code, options);
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user