Merge branch 'master' into harmony-v2.8.14
This commit is contained in:
@@ -2791,7 +2791,7 @@ merge(Compressor.prototype, {
|
|||||||
if (self.args.length != 1) {
|
if (self.args.length != 1) {
|
||||||
return make_node(AST_Array, self, {
|
return make_node(AST_Array, self, {
|
||||||
elements: self.args
|
elements: self.args
|
||||||
}).transform(compressor);
|
}).optimize(compressor);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "Object":
|
case "Object":
|
||||||
@@ -2809,7 +2809,7 @@ merge(Compressor.prototype, {
|
|||||||
left: self.args[0],
|
left: self.args[0],
|
||||||
operator: "+",
|
operator: "+",
|
||||||
right: make_node(AST_String, self, { value: "" })
|
right: make_node(AST_String, self, { value: "" })
|
||||||
}).transform(compressor);
|
}).optimize(compressor);
|
||||||
break;
|
break;
|
||||||
case "Number":
|
case "Number":
|
||||||
if (self.args.length == 0) return make_node(AST_Number, self, {
|
if (self.args.length == 0) return make_node(AST_Number, self, {
|
||||||
@@ -2818,7 +2818,7 @@ merge(Compressor.prototype, {
|
|||||||
if (self.args.length == 1) return make_node(AST_UnaryPrefix, self, {
|
if (self.args.length == 1) return make_node(AST_UnaryPrefix, self, {
|
||||||
expression: self.args[0],
|
expression: self.args[0],
|
||||||
operator: "+"
|
operator: "+"
|
||||||
}).transform(compressor);
|
}).optimize(compressor);
|
||||||
case "Boolean":
|
case "Boolean":
|
||||||
if (self.args.length == 0) return make_node(AST_False, self);
|
if (self.args.length == 0) return make_node(AST_False, self);
|
||||||
if (self.args.length == 1) return make_node(AST_UnaryPrefix, self, {
|
if (self.args.length == 1) return make_node(AST_UnaryPrefix, self, {
|
||||||
@@ -2827,7 +2827,7 @@ merge(Compressor.prototype, {
|
|||||||
operator: "!"
|
operator: "!"
|
||||||
}),
|
}),
|
||||||
operator: "!"
|
operator: "!"
|
||||||
}).transform(compressor);
|
}).optimize(compressor);
|
||||||
break;
|
break;
|
||||||
case "Function":
|
case "Function":
|
||||||
// new Function() => function(){}
|
// new Function() => function(){}
|
||||||
@@ -2897,7 +2897,7 @@ merge(Compressor.prototype, {
|
|||||||
left: make_node(AST_String, self, { value: "" }),
|
left: make_node(AST_String, self, { value: "" }),
|
||||||
operator: "+",
|
operator: "+",
|
||||||
right: exp.expression
|
right: exp.expression
|
||||||
}).transform(compressor);
|
}).optimize(compressor);
|
||||||
}
|
}
|
||||||
else if (exp instanceof AST_Dot && exp.expression instanceof AST_Array && exp.property == "join") EXIT: {
|
else if (exp instanceof AST_Dot && exp.expression instanceof AST_Array && exp.property == "join") EXIT: {
|
||||||
var separator;
|
var separator;
|
||||||
@@ -2951,7 +2951,7 @@ merge(Compressor.prototype, {
|
|||||||
left : prev,
|
left : prev,
|
||||||
right : el
|
right : el
|
||||||
});
|
});
|
||||||
}, first).transform(compressor);
|
}, first).optimize(compressor);
|
||||||
}
|
}
|
||||||
// need this awkward cloning to not affect original element
|
// need this awkward cloning to not affect original element
|
||||||
// best_of will decide which one to get through.
|
// best_of will decide which one to get through.
|
||||||
@@ -2961,6 +2961,16 @@ merge(Compressor.prototype, {
|
|||||||
node.expression.expression.elements = elements;
|
node.expression.expression.elements = elements;
|
||||||
return best_of(compressor, self, node);
|
return best_of(compressor, self, node);
|
||||||
}
|
}
|
||||||
|
else if (exp instanceof AST_Dot && exp.expression.is_string(compressor) && exp.property == "charAt") {
|
||||||
|
var arg = self.args[0];
|
||||||
|
var index = arg ? arg.evaluate(compressor) : 0;
|
||||||
|
if (index !== arg) {
|
||||||
|
return make_node(AST_Sub, exp, {
|
||||||
|
expression: exp.expression,
|
||||||
|
property: make_node_from_constant(index | 0, arg || exp)
|
||||||
|
}).optimize(compressor);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (exp instanceof AST_Function && !self.expression.is_generator) {
|
if (exp instanceof AST_Function && !self.expression.is_generator) {
|
||||||
if (exp.body[0] instanceof AST_Return) {
|
if (exp.body[0] instanceof AST_Return) {
|
||||||
@@ -3129,14 +3139,6 @@ merge(Compressor.prototype, {
|
|||||||
return self;
|
return self;
|
||||||
});
|
});
|
||||||
|
|
||||||
function has_side_effects_or_prop_access(node, compressor) {
|
|
||||||
var save_pure_getters = compressor.option("pure_getters");
|
|
||||||
compressor.options.pure_getters = false;
|
|
||||||
var ret = node.has_side_effects(compressor);
|
|
||||||
compressor.options.pure_getters = save_pure_getters;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
AST_Binary.DEFMETHOD("lift_sequences", function(compressor){
|
AST_Binary.DEFMETHOD("lift_sequences", function(compressor){
|
||||||
if (compressor.option("sequences")) {
|
if (compressor.option("sequences")) {
|
||||||
if (this.left instanceof AST_Seq) {
|
if (this.left instanceof AST_Seq) {
|
||||||
@@ -3144,18 +3146,23 @@ merge(Compressor.prototype, {
|
|||||||
var x = seq.to_array();
|
var x = seq.to_array();
|
||||||
this.left = x.pop();
|
this.left = x.pop();
|
||||||
x.push(this);
|
x.push(this);
|
||||||
seq = AST_Seq.from_array(x).transform(compressor);
|
return AST_Seq.from_array(x).optimize(compressor);
|
||||||
return seq;
|
|
||||||
}
|
}
|
||||||
if (this.right instanceof AST_Seq
|
if (this.right instanceof AST_Seq && !this.left.has_side_effects(compressor)) {
|
||||||
&& this instanceof AST_Assign
|
var assign = this.operator == "=" && this.left instanceof AST_SymbolRef;
|
||||||
&& !has_side_effects_or_prop_access(this.left, compressor)) {
|
var root = this.right;
|
||||||
var seq = this.right;
|
var cursor, seq = root;
|
||||||
var x = seq.to_array();
|
while (assign || !seq.car.has_side_effects(compressor)) {
|
||||||
this.right = x.pop();
|
cursor = seq;
|
||||||
x.push(this);
|
if (seq.cdr instanceof AST_Seq) {
|
||||||
seq = AST_Seq.from_array(x).transform(compressor);
|
seq = seq.cdr;
|
||||||
return seq;
|
} else break;
|
||||||
|
}
|
||||||
|
if (cursor) {
|
||||||
|
this.right = cursor.cdr;
|
||||||
|
cursor.cdr = this;
|
||||||
|
return root.optimize(compressor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
@@ -3190,32 +3197,6 @@ merge(Compressor.prototype, {
|
|||||||
reverse();
|
reverse();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (/^[!=]==?$/.test(self.operator)) {
|
|
||||||
if (self.left instanceof AST_SymbolRef && self.right instanceof AST_Conditional) {
|
|
||||||
if (self.right.consequent instanceof AST_SymbolRef
|
|
||||||
&& self.right.consequent.definition() === self.left.definition()) {
|
|
||||||
if (/^==/.test(self.operator)) return self.right.condition;
|
|
||||||
if (/^!=/.test(self.operator)) return self.right.condition.negate(compressor);
|
|
||||||
}
|
|
||||||
if (self.right.alternative instanceof AST_SymbolRef
|
|
||||||
&& self.right.alternative.definition() === self.left.definition()) {
|
|
||||||
if (/^==/.test(self.operator)) return self.right.condition.negate(compressor);
|
|
||||||
if (/^!=/.test(self.operator)) return self.right.condition;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (self.right instanceof AST_SymbolRef && self.left instanceof AST_Conditional) {
|
|
||||||
if (self.left.consequent instanceof AST_SymbolRef
|
|
||||||
&& self.left.consequent.definition() === self.right.definition()) {
|
|
||||||
if (/^==/.test(self.operator)) return self.left.condition;
|
|
||||||
if (/^!=/.test(self.operator)) return self.left.condition.negate(compressor);
|
|
||||||
}
|
|
||||||
if (self.left.alternative instanceof AST_SymbolRef
|
|
||||||
&& self.left.alternative.definition() === self.right.definition()) {
|
|
||||||
if (/^==/.test(self.operator)) return self.left.condition.negate(compressor);
|
|
||||||
if (/^!=/.test(self.operator)) return self.left.condition;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
self = self.lift_sequences(compressor);
|
self = self.lift_sequences(compressor);
|
||||||
if (compressor.option("comparisons")) switch (self.operator) {
|
if (compressor.option("comparisons")) switch (self.operator) {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"homepage": "http://lisperator.net/uglifyjs",
|
"homepage": "http://lisperator.net/uglifyjs",
|
||||||
"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": "2.8.13",
|
"version": "2.8.14",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.8.0"
|
"node": ">=0.8.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ collapse_vars_side_effects_1: {
|
|||||||
z = i += 4;
|
z = i += 4;
|
||||||
log(x, z, y, i);
|
log(x, z, y, i);
|
||||||
}
|
}
|
||||||
|
f1(), f2(), f3(), f4();
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
function f1() {
|
function f1() {
|
||||||
@@ -73,7 +74,9 @@ collapse_vars_side_effects_1: {
|
|||||||
y = i += 3;
|
y = i += 3;
|
||||||
log(x, i += 4, y, i);
|
log(x, i += 4, y, i);
|
||||||
}
|
}
|
||||||
|
f1(), f2(), f3(), f4();
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
collapse_vars_side_effects_2: {
|
collapse_vars_side_effects_2: {
|
||||||
@@ -823,6 +826,7 @@ collapse_vars_repeated: {
|
|||||||
console.log(e + "!");
|
console.log(e + "!");
|
||||||
})("!");
|
})("!");
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
collapse_vars_closures: {
|
collapse_vars_closures: {
|
||||||
@@ -1109,6 +1113,7 @@ collapse_vars_eval_and_with: {
|
|||||||
return function() { with (o) console.log(a) };
|
return function() { with (o) console.log(a) };
|
||||||
})()();
|
})()();
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
collapse_vars_constants: {
|
collapse_vars_constants: {
|
||||||
@@ -1168,6 +1173,7 @@ collapse_vars_arguments: {
|
|||||||
(function(){console.log(arguments);})(7, 1);
|
(function(){console.log(arguments);})(7, 1);
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
collapse_vars_short_circuit: {
|
collapse_vars_short_circuit: {
|
||||||
@@ -1317,6 +1323,7 @@ collapse_vars_regexp: {
|
|||||||
console.log(result[0]);
|
console.log(result[0]);
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_1537: {
|
issue_1537: {
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ concat_2: {
|
|||||||
"1" + "2" + "3"
|
"1" + "2" + "3"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
concat_3: {
|
concat_3: {
|
||||||
@@ -79,6 +80,7 @@ concat_3: {
|
|||||||
1 + 2 + "3" + "4" + "5"
|
1 + 2 + "3" + "4" + "5"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
concat_4: {
|
concat_4: {
|
||||||
@@ -107,6 +109,7 @@ concat_4: {
|
|||||||
1 + "2" + "3" + "4" + "5"
|
1 + "2" + "3" + "4" + "5"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
concat_5: {
|
concat_5: {
|
||||||
@@ -135,6 +138,7 @@ concat_5: {
|
|||||||
"1" + 2 + "3" + "4" + "5"
|
"1" + 2 + "3" + "4" + "5"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
concat_6: {
|
concat_6: {
|
||||||
@@ -163,6 +167,7 @@ concat_6: {
|
|||||||
"1" + "2" + "3" + "4" + "5"
|
"1" + "2" + "3" + "4" + "5"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
concat_7: {
|
concat_7: {
|
||||||
@@ -188,6 +193,7 @@ concat_7: {
|
|||||||
x += "foo"
|
x += "foo"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
concat_8: {
|
concat_8: {
|
||||||
@@ -213,4 +219,5 @@ concat_8: {
|
|||||||
x += "foo"
|
x += "foo"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -797,3 +797,99 @@ no_evaluate: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
equality_conditionals_false: {
|
||||||
|
options = {
|
||||||
|
conditionals: false,
|
||||||
|
sequences: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f(a, b, c) {
|
||||||
|
console.log(
|
||||||
|
a == (b ? a : a),
|
||||||
|
a == (b ? a : c),
|
||||||
|
a != (b ? a : a),
|
||||||
|
a != (b ? a : c),
|
||||||
|
a === (b ? a : a),
|
||||||
|
a === (b ? a : c),
|
||||||
|
a !== (b ? a : a),
|
||||||
|
a !== (b ? a : c)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
f(0, 0, 0);
|
||||||
|
f(0, true, 0);
|
||||||
|
f(1, 2, 3);
|
||||||
|
f(1, null, 3);
|
||||||
|
f(NaN);
|
||||||
|
f(NaN, "foo");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f(a, b, c) {
|
||||||
|
console.log(
|
||||||
|
a == (b ? a : a),
|
||||||
|
a == (b ? a : c),
|
||||||
|
a != (b ? a : a),
|
||||||
|
a != (b ? a : c),
|
||||||
|
a === (b ? a : a),
|
||||||
|
a === (b ? a : c),
|
||||||
|
a !== (b ? a : a),
|
||||||
|
a !== (b ? a : c)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
f(0, 0, 0),
|
||||||
|
f(0, true, 0),
|
||||||
|
f(1, 2, 3),
|
||||||
|
f(1, null, 3),
|
||||||
|
f(NaN),
|
||||||
|
f(NaN, "foo");
|
||||||
|
}
|
||||||
|
expect_stdout: true
|
||||||
|
}
|
||||||
|
|
||||||
|
equality_conditionals_true: {
|
||||||
|
options = {
|
||||||
|
conditionals: true,
|
||||||
|
sequences: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f(a, b, c) {
|
||||||
|
console.log(
|
||||||
|
a == (b ? a : a),
|
||||||
|
a == (b ? a : c),
|
||||||
|
a != (b ? a : a),
|
||||||
|
a != (b ? a : c),
|
||||||
|
a === (b ? a : a),
|
||||||
|
a === (b ? a : c),
|
||||||
|
a !== (b ? a : a),
|
||||||
|
a !== (b ? a : c)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
f(0, 0, 0);
|
||||||
|
f(0, true, 0);
|
||||||
|
f(1, 2, 3);
|
||||||
|
f(1, null, 3);
|
||||||
|
f(NaN);
|
||||||
|
f(NaN, "foo");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f(a, b, c) {
|
||||||
|
console.log(
|
||||||
|
(b, a == a),
|
||||||
|
a == (b ? a : c),
|
||||||
|
(b, a != a),
|
||||||
|
a != (b ? a : c),
|
||||||
|
(b, a === a),
|
||||||
|
a === (b ? a : c),
|
||||||
|
(b, a !== a),
|
||||||
|
a !== (b ? a : c)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
f(0, 0, 0),
|
||||||
|
f(0, true, 0),
|
||||||
|
f(1, 2, 3),
|
||||||
|
f(1, null, 3),
|
||||||
|
f(NaN),
|
||||||
|
f(NaN, "foo");
|
||||||
|
}
|
||||||
|
expect_stdout: true
|
||||||
|
}
|
||||||
|
|||||||
@@ -162,4 +162,5 @@ regexp_literal_not_const: {
|
|||||||
while (result = REGEXP_LITERAL.exec("acdabcdeabbb")) console.log(result[0]);
|
while (result = REGEXP_LITERAL.exec("acdabcdeabbb")) console.log(result[0]);
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ dead_code_constant_boolean_should_warn_more: {
|
|||||||
var x = 10, y;
|
var x = 10, y;
|
||||||
var moo;
|
var moo;
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
dead_code_block_decls_die: {
|
dead_code_block_decls_die: {
|
||||||
@@ -135,6 +136,7 @@ dead_code_const_declaration: {
|
|||||||
var moo;
|
var moo;
|
||||||
function bar() {}
|
function bar() {}
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
dead_code_const_annotation: {
|
dead_code_const_annotation: {
|
||||||
@@ -162,6 +164,7 @@ dead_code_const_annotation: {
|
|||||||
var moo;
|
var moo;
|
||||||
function bar() {}
|
function bar() {}
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
dead_code_const_annotation_regex: {
|
dead_code_const_annotation_regex: {
|
||||||
@@ -185,6 +188,7 @@ dead_code_const_annotation_regex: {
|
|||||||
var CONST_FOO_ANN = !1;
|
var CONST_FOO_ANN = !1;
|
||||||
CONST_FOO_ANN && console.log('reachable');
|
CONST_FOO_ANN && console.log('reachable');
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
dead_code_const_annotation_complex_scope: {
|
dead_code_const_annotation_complex_scope: {
|
||||||
@@ -230,4 +234,5 @@ dead_code_const_annotation_complex_scope: {
|
|||||||
var meat = 'beef';
|
var meat = 'beef';
|
||||||
var pork = 'bad';
|
var pork = 'bad';
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -200,6 +200,7 @@ negative_zero: {
|
|||||||
1 / (-0)
|
1 / (-0)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
positive_zero: {
|
positive_zero: {
|
||||||
@@ -220,6 +221,7 @@ positive_zero: {
|
|||||||
1 / (0)
|
1 / (0)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
pow: {
|
pow: {
|
||||||
@@ -337,6 +339,7 @@ unsafe_constant: {
|
|||||||
(void 0).a
|
(void 0).a
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe_object: {
|
unsafe_object: {
|
||||||
@@ -360,6 +363,7 @@ unsafe_object: {
|
|||||||
1..b + 1
|
1..b + 1
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe_object_nested: {
|
unsafe_object_nested: {
|
||||||
@@ -383,6 +387,7 @@ unsafe_object_nested: {
|
|||||||
2
|
2
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe_object_complex: {
|
unsafe_object_complex: {
|
||||||
@@ -406,6 +411,7 @@ unsafe_object_complex: {
|
|||||||
2
|
2
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe_object_repeated: {
|
unsafe_object_repeated: {
|
||||||
@@ -429,6 +435,7 @@ unsafe_object_repeated: {
|
|||||||
1..b + 1
|
1..b + 1
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe_object_accessor: {
|
unsafe_object_accessor: {
|
||||||
@@ -478,6 +485,7 @@ unsafe_function: {
|
|||||||
({a:{b:1},b:function(){}}).a.b + 1
|
({a:{b:1},b:function(){}}).a.b + 1
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe_integer_key: {
|
unsafe_integer_key: {
|
||||||
@@ -505,6 +513,7 @@ unsafe_integer_key: {
|
|||||||
1["1"] + 1
|
1["1"] + 1
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe_integer_key_complex: {
|
unsafe_integer_key_complex: {
|
||||||
@@ -532,6 +541,7 @@ unsafe_integer_key_complex: {
|
|||||||
2
|
2
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe_float_key: {
|
unsafe_float_key: {
|
||||||
@@ -559,6 +569,7 @@ unsafe_float_key: {
|
|||||||
1["3.14"] + 1
|
1["3.14"] + 1
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe_float_key_complex: {
|
unsafe_float_key_complex: {
|
||||||
@@ -586,6 +597,7 @@ unsafe_float_key_complex: {
|
|||||||
2
|
2
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe_array: {
|
unsafe_array: {
|
||||||
@@ -621,6 +633,7 @@ unsafe_array: {
|
|||||||
(void 0)[1] + 1
|
(void 0)[1] + 1
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe_string: {
|
unsafe_string: {
|
||||||
@@ -648,6 +661,7 @@ unsafe_string: {
|
|||||||
"11"
|
"11"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe_array_bad_index: {
|
unsafe_array_bad_index: {
|
||||||
@@ -669,6 +683,7 @@ unsafe_array_bad_index: {
|
|||||||
[1, 2, 3, 4][3.14] + 1
|
[1, 2, 3, 4][3.14] + 1
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe_string_bad_index: {
|
unsafe_string_bad_index: {
|
||||||
@@ -690,6 +705,7 @@ unsafe_string_bad_index: {
|
|||||||
"1234"[3.14] + 1
|
"1234"[3.14] + 1
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe_prototype_function: {
|
unsafe_prototype_function: {
|
||||||
@@ -736,6 +752,7 @@ call_args: {
|
|||||||
console.log(1);
|
console.log(1);
|
||||||
+(1, 1);
|
+(1, 1);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
call_args_drop_param: {
|
call_args_drop_param: {
|
||||||
@@ -757,6 +774,7 @@ call_args_drop_param: {
|
|||||||
console.log(1);
|
console.log(1);
|
||||||
+(b, 1);
|
+(b, 1);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
in_boolean_context: {
|
in_boolean_context: {
|
||||||
@@ -794,4 +812,74 @@ in_boolean_context: {
|
|||||||
(foo(), !1)
|
(foo(), !1)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe_charAt: {
|
||||||
|
options = {
|
||||||
|
evaluate : true,
|
||||||
|
unsafe : true
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(
|
||||||
|
"1234" + 1,
|
||||||
|
"1234".charAt(0) + 1,
|
||||||
|
"1234".charAt(6 - 5) + 1,
|
||||||
|
("12" + "34").charAt(0) + 1,
|
||||||
|
("12" + "34").charAt(6 - 5) + 1,
|
||||||
|
[1, 2, 3, 4].join("").charAt(0) + 1
|
||||||
|
);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(
|
||||||
|
"12341",
|
||||||
|
"11",
|
||||||
|
"21",
|
||||||
|
"11",
|
||||||
|
"21",
|
||||||
|
"11"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
expect_stdout: true
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe_charAt_bad_index: {
|
||||||
|
options = {
|
||||||
|
evaluate : true,
|
||||||
|
unsafe : true
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(
|
||||||
|
"1234".charAt() + 1,
|
||||||
|
"1234".charAt("a") + 1,
|
||||||
|
"1234".charAt(3.14) + 1
|
||||||
|
);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(
|
||||||
|
"11",
|
||||||
|
"11",
|
||||||
|
"41"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
expect_stdout: true
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe_charAt_noop: {
|
||||||
|
options = {
|
||||||
|
evaluate : true,
|
||||||
|
unsafe : true
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(
|
||||||
|
s.charAt(0),
|
||||||
|
"string".charAt(x)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(
|
||||||
|
s.charAt(0),
|
||||||
|
"string".charAt(x)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ iifes_returning_constants_keep_fargs_true: {
|
|||||||
console.log(6);
|
console.log(6);
|
||||||
console.log((a(), b(), 6));
|
console.log((a(), b(), 6));
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
iifes_returning_constants_keep_fargs_false: {
|
iifes_returning_constants_keep_fargs_false: {
|
||||||
@@ -73,6 +74,7 @@ iifes_returning_constants_keep_fargs_false: {
|
|||||||
console.log(6);
|
console.log(6);
|
||||||
console.log((a(), b(), 6));
|
console.log((a(), b(), 6));
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_485_crashing_1530: {
|
issue_485_crashing_1530: {
|
||||||
|
|||||||
@@ -46,4 +46,5 @@ string_plus_optimization: {
|
|||||||
}
|
}
|
||||||
foo();
|
foo();
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ issue_1321_no_debug: {
|
|||||||
x["a"] = 2 * x.b;
|
x["a"] = 2 * x.b;
|
||||||
console.log(x.b, x["a"]);
|
console.log(x.b, x["a"]);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_1321_debug: {
|
issue_1321_debug: {
|
||||||
@@ -33,6 +34,7 @@ issue_1321_debug: {
|
|||||||
x["_$foo$_"] = 2 * x.a;
|
x["_$foo$_"] = 2 * x.a;
|
||||||
console.log(x.a, x["_$foo$_"]);
|
console.log(x.a, x["_$foo$_"]);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_1321_with_quoted: {
|
issue_1321_with_quoted: {
|
||||||
@@ -51,4 +53,5 @@ issue_1321_with_quoted: {
|
|||||||
x["b"] = 2 * x.a;
|
x["b"] = 2 * x.a;
|
||||||
console.log(x.a, x["b"]);
|
console.log(x.a, x["b"]);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,4 +42,5 @@ conditional_false_stray_else_in_loop: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
expect_exact: "for(var i=1;i<=4;++i)if(!(i<=2))console.log(i);"
|
expect_exact: "for(var i=1;i<=4;++i)if(!(i<=2))console.log(i);"
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ dead_code_const_annotation_regex: {
|
|||||||
var CONST_FOO_ANN = !1;
|
var CONST_FOO_ANN = !1;
|
||||||
if (CONST_FOO_ANN) console.log('reachable');
|
if (CONST_FOO_ANN) console.log('reachable');
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
drop_console_2: {
|
drop_console_2: {
|
||||||
@@ -225,6 +226,7 @@ issue_1254_negate_iife_true: {
|
|||||||
})()();
|
})()();
|
||||||
}
|
}
|
||||||
expect_exact: '(function(){return function(){console.log("test")}})()();'
|
expect_exact: '(function(){return function(){console.log("test")}})()();'
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_1254_negate_iife_nested: {
|
issue_1254_negate_iife_nested: {
|
||||||
@@ -240,6 +242,7 @@ issue_1254_negate_iife_nested: {
|
|||||||
})()()()()();
|
})()()()()();
|
||||||
}
|
}
|
||||||
expect_exact: '(function(){return function(){console.log("test")}})()()()()();'
|
expect_exact: '(function(){return function(){console.log("test")}})()()()()();'
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
conditional: {
|
conditional: {
|
||||||
|
|||||||
@@ -29,4 +29,5 @@ dont_mangle_arguments: {
|
|||||||
})(5,6,7);
|
})(5,6,7);
|
||||||
}
|
}
|
||||||
expect_exact: "(function(){var arguments=arguments,o=9;console.log(o,arguments)})(5,6,7);"
|
expect_exact: "(function(){var arguments=arguments,o=9;console.log(o,arguments)})(5,6,7);"
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ eval_collapse_vars: {
|
|||||||
eval("console.log(a);");
|
eval("console.log(a);");
|
||||||
})(eval);
|
})(eval);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
eval_unused: {
|
eval_unused: {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ labels_1: {
|
|||||||
expect: {
|
expect: {
|
||||||
foo || console.log("bar");
|
foo || console.log("bar");
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
labels_2: {
|
labels_2: {
|
||||||
@@ -40,6 +41,7 @@ labels_3: {
|
|||||||
for (var i = 0; i < 5; ++i)
|
for (var i = 0; i < 5; ++i)
|
||||||
i < 3 || console.log(i);
|
i < 3 || console.log(i);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
labels_4: {
|
labels_4: {
|
||||||
@@ -54,6 +56,7 @@ labels_4: {
|
|||||||
for (var i = 0; i < 5; ++i)
|
for (var i = 0; i < 5; ++i)
|
||||||
i < 3 || console.log(i);
|
i < 3 || console.log(i);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
labels_5: {
|
labels_5: {
|
||||||
|
|||||||
@@ -166,6 +166,7 @@ keep_collapse_const_in_own_block_scope: {
|
|||||||
console.log(i);
|
console.log(i);
|
||||||
console.log(c);
|
console.log(c);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
keep_collapse_const_in_own_block_scope_2: {
|
keep_collapse_const_in_own_block_scope_2: {
|
||||||
@@ -186,6 +187,7 @@ keep_collapse_const_in_own_block_scope_2: {
|
|||||||
console.log(i);
|
console.log(i);
|
||||||
console.log(c);
|
console.log(c);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
evaluate: {
|
evaluate: {
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ negate_iife_3_evaluate: {
|
|||||||
expect: {
|
expect: {
|
||||||
console.log(true);
|
console.log(true);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
negate_iife_3_side_effects: {
|
negate_iife_3_side_effects: {
|
||||||
@@ -111,6 +112,7 @@ negate_iife_3_off_evaluate: {
|
|||||||
expect: {
|
expect: {
|
||||||
console.log(true);
|
console.log(true);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
negate_iife_4: {
|
negate_iife_4: {
|
||||||
@@ -243,6 +245,7 @@ negate_iife_nested: {
|
|||||||
}(7);
|
}(7);
|
||||||
}).f();
|
}).f();
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
negate_iife_nested_off: {
|
negate_iife_nested_off: {
|
||||||
@@ -275,6 +278,7 @@ negate_iife_nested_off: {
|
|||||||
})(7);
|
})(7);
|
||||||
}).f();
|
}).f();
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
negate_iife_issue_1073: {
|
negate_iife_issue_1073: {
|
||||||
@@ -299,6 +303,7 @@ negate_iife_issue_1073: {
|
|||||||
};
|
};
|
||||||
}(7))();
|
}(7))();
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_1254_negate_iife_false: {
|
issue_1254_negate_iife_false: {
|
||||||
@@ -313,6 +318,7 @@ issue_1254_negate_iife_false: {
|
|||||||
})()();
|
})()();
|
||||||
}
|
}
|
||||||
expect_exact: '(function(){return function(){console.log("test")}})()();'
|
expect_exact: '(function(){return function(){console.log("test")}})()();'
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_1254_negate_iife_true: {
|
issue_1254_negate_iife_true: {
|
||||||
@@ -327,6 +333,7 @@ issue_1254_negate_iife_true: {
|
|||||||
})()();
|
})()();
|
||||||
}
|
}
|
||||||
expect_exact: '!function(){return function(){console.log("test")}}()();'
|
expect_exact: '!function(){return function(){console.log("test")}}()();'
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_1254_negate_iife_nested: {
|
issue_1254_negate_iife_nested: {
|
||||||
@@ -341,6 +348,7 @@ issue_1254_negate_iife_nested: {
|
|||||||
})()()()()();
|
})()()()()();
|
||||||
}
|
}
|
||||||
expect_exact: '!function(){return function(){console.log("test")}}()()()()();'
|
expect_exact: '!function(){return function(){console.log("test")}}()()()()();'
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_1288: {
|
issue_1288: {
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ reduce_vars: {
|
|||||||
})();
|
})();
|
||||||
console.log(2);
|
console.log(2);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
modified: {
|
modified: {
|
||||||
@@ -166,7 +167,7 @@ modified: {
|
|||||||
console.log(A ? 'yes' : 'no');
|
console.log(A ? 'yes' : 'no');
|
||||||
console.log(B ? 'yes' : 'no');
|
console.log(B ? 'yes' : 'no');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe_evaluate: {
|
unsafe_evaluate: {
|
||||||
@@ -401,6 +402,7 @@ iife: {
|
|||||||
console.log(0, 1 * b, 5);
|
console.log(0, 1 * b, 5);
|
||||||
}(1, 2, 3);
|
}(1, 2, 3);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
iife_new: {
|
iife_new: {
|
||||||
@@ -420,6 +422,7 @@ iife_new: {
|
|||||||
console.log(0, 1 * b, 5);
|
console.log(0, 1 * b, 5);
|
||||||
}(1, 2, 3);
|
}(1, 2, 3);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
multi_def: {
|
multi_def: {
|
||||||
@@ -707,6 +710,7 @@ toplevel_on: {
|
|||||||
expect: {
|
expect: {
|
||||||
console.log(3);
|
console.log(3);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
toplevel_off: {
|
toplevel_off: {
|
||||||
@@ -724,6 +728,7 @@ toplevel_off: {
|
|||||||
var x = 3;
|
var x = 3;
|
||||||
console.log(x);
|
console.log(x);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
toplevel_on_loops_1: {
|
toplevel_on_loops_1: {
|
||||||
@@ -751,6 +756,7 @@ toplevel_on_loops_1: {
|
|||||||
})();
|
})();
|
||||||
while (x);
|
while (x);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
toplevel_off_loops_1: {
|
toplevel_off_loops_1: {
|
||||||
@@ -779,6 +785,7 @@ toplevel_off_loops_1: {
|
|||||||
bar();
|
bar();
|
||||||
while (x);
|
while (x);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
toplevel_on_loops_2: {
|
toplevel_on_loops_2: {
|
||||||
@@ -1121,6 +1128,7 @@ defun_label: {
|
|||||||
}(2));
|
}(2));
|
||||||
}();
|
}();
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
double_reference: {
|
double_reference: {
|
||||||
@@ -1164,6 +1172,7 @@ iife_arguments_1: {
|
|||||||
return f;
|
return f;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
iife_arguments_2: {
|
iife_arguments_2: {
|
||||||
@@ -1186,6 +1195,7 @@ iife_arguments_2: {
|
|||||||
}() === arguments[0]);
|
}() === arguments[0]);
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
iife_eval_1: {
|
iife_eval_1: {
|
||||||
@@ -1207,6 +1217,7 @@ iife_eval_1: {
|
|||||||
return f;
|
return f;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
iife_eval_2: {
|
iife_eval_2: {
|
||||||
@@ -1230,6 +1241,7 @@ iife_eval_2: {
|
|||||||
console.log(x() === eval("x"));
|
console.log(x() === eval("x"));
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
iife_func_side_effects: {
|
iife_func_side_effects: {
|
||||||
@@ -1326,6 +1338,7 @@ issue_1595_4: {
|
|||||||
if (a) iife(a - 1, b, c);
|
if (a) iife(a - 1, b, c);
|
||||||
})(3, 4, 5);
|
})(3, 4, 5);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_1606: {
|
issue_1606: {
|
||||||
|
|||||||
@@ -128,6 +128,7 @@ do_screw_try_catch_undefined: {
|
|||||||
return void 0===o
|
return void 0===o
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
dont_screw_try_catch_undefined: {
|
dont_screw_try_catch_undefined: {
|
||||||
@@ -156,6 +157,7 @@ dont_screw_try_catch_undefined: {
|
|||||||
return n === undefined
|
return n === undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
reduce_vars: {
|
reduce_vars: {
|
||||||
@@ -208,6 +210,7 @@ issue_1586_1: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
expect_exact: "function f(){try{}catch(c){console.log(c.message)}}"
|
expect_exact: "function f(){try{}catch(c){console.log(c.message)}}"
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_1586_2: {
|
issue_1586_2: {
|
||||||
@@ -226,4 +229,5 @@ issue_1586_2: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
expect_exact: "function f(){try{}catch(c){console.log(c.message)}}"
|
expect_exact: "function f(){try{}catch(c){console.log(c.message)}}"
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ make_sequences_4: {
|
|||||||
switch (x = 5, y) {}
|
switch (x = 5, y) {}
|
||||||
with (x = 5, obj);
|
with (x = 5, obj);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
lift_sequences_1: {
|
lift_sequences_1: {
|
||||||
@@ -103,15 +104,18 @@ lift_sequences_1: {
|
|||||||
lift_sequences_2: {
|
lift_sequences_2: {
|
||||||
options = { sequences: true, evaluate: true };
|
options = { sequences: true, evaluate: true };
|
||||||
input: {
|
input: {
|
||||||
var foo, bar;
|
var foo = 1, bar;
|
||||||
foo.x = (foo = {}, 10);
|
foo.x = (foo = {}, 10);
|
||||||
bar = (bar = {}, 10);
|
bar = (bar = {}, 10);
|
||||||
|
console.log(foo, bar);
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
var foo, bar;
|
var foo = 1, bar;
|
||||||
foo.x = (foo = {}, 10),
|
foo.x = (foo = {}, 10),
|
||||||
bar = {}, bar = 10;
|
bar = {}, bar = 10,
|
||||||
|
console.log(foo, bar);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
lift_sequences_3: {
|
lift_sequences_3: {
|
||||||
@@ -138,6 +142,23 @@ lift_sequences_4: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lift_sequences_5: {
|
||||||
|
options = {
|
||||||
|
sequences: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = 2, b;
|
||||||
|
a *= (b, a = 4, 3);
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = 2, b;
|
||||||
|
b, a *= (a = 4, 3),
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect_stdout: "6"
|
||||||
|
}
|
||||||
|
|
||||||
for_sequences: {
|
for_sequences: {
|
||||||
options = { sequences: true };
|
options = { sequences: true };
|
||||||
input: {
|
input: {
|
||||||
@@ -230,6 +251,7 @@ negate_iife_for: {
|
|||||||
for (!function() {}(), i = 0; i < 5; i++) console.log(i);
|
for (!function() {}(), i = 0; i < 5; i++) console.log(i);
|
||||||
for (function() {}(); i < 5; i++) console.log(i);
|
for (function() {}(); i < 5; i++) console.log(i);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
iife: {
|
iife: {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ booleans_evaluate: {
|
|||||||
console.log(!0, !0);
|
console.log(!0, !0);
|
||||||
console.log(!1, !1);
|
console.log(!1, !1);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
booleans_global_defs: {
|
booleans_global_defs: {
|
||||||
@@ -29,6 +30,7 @@ booleans_global_defs: {
|
|||||||
expect: {
|
expect: {
|
||||||
console.log(!0);
|
console.log(!0);
|
||||||
}
|
}
|
||||||
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
condition_evaluate: {
|
condition_evaluate: {
|
||||||
|
|||||||
@@ -11,6 +11,17 @@ var vm = require("vm");
|
|||||||
var tests_dir = path.dirname(module.filename);
|
var tests_dir = path.dirname(module.filename);
|
||||||
var failures = 0;
|
var failures = 0;
|
||||||
var failed_files = {};
|
var failed_files = {};
|
||||||
|
var same_stdout = ~process.version.lastIndexOf("v0.12.", 0) ? function(expected, actual) {
|
||||||
|
if (typeof expected != typeof actual) return false;
|
||||||
|
if (typeof expected != "string") {
|
||||||
|
if (expected.name != actual.name) return false;
|
||||||
|
expected = expected.message.slice(expected.message.lastIndexOf("\n") + 1);
|
||||||
|
actual = actual.message.slice(actual.message.lastIndexOf("\n") + 1);
|
||||||
|
}
|
||||||
|
return expected == actual;
|
||||||
|
} : function(expected, actual) {
|
||||||
|
return typeof expected == typeof actual && expected.toString() == actual.toString();
|
||||||
|
};
|
||||||
|
|
||||||
run_compress_tests();
|
run_compress_tests();
|
||||||
if (failures) {
|
if (failures) {
|
||||||
@@ -172,7 +183,7 @@ function run_compress_tests() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (test.expect_stdout) {
|
if (test.expect_stdout) {
|
||||||
var stdout = run_code(input_code);
|
var stdout = run_code(make_code(input, output_options));
|
||||||
if (test.expect_stdout === true) {
|
if (test.expect_stdout === true) {
|
||||||
test.expect_stdout = stdout;
|
test.expect_stdout = stdout;
|
||||||
}
|
}
|
||||||
@@ -336,7 +347,3 @@ function run_code(code) {
|
|||||||
process.stdout.write = original_write;
|
process.stdout.write = original_write;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function same_stdout(expected, actual) {
|
|
||||||
return typeof expected == typeof actual && expected.toString() == actual.toString();
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user