Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0d17c5b0fa | ||
|
|
5b20bad4b3 | ||
|
|
765a06340f | ||
|
|
5045e140b1 | ||
|
|
10648c9af6 | ||
|
|
87e67ec299 | ||
|
|
61a0dad9fe | ||
|
|
3e2c51a4da | ||
|
|
0e29ad5eb9 | ||
|
|
0f2687ecfc | ||
|
|
1c0defdc03 | ||
|
|
dcbf2236c7 | ||
|
|
24bb288832 |
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@@ -14,6 +14,10 @@ jobs:
|
|||||||
TYPE: ${{ matrix.script }}
|
TYPE: ${{ matrix.script }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
|
- uses: actions/cache@v1
|
||||||
|
with:
|
||||||
|
path: tmp
|
||||||
|
key: tmp ${{ matrix.script }}
|
||||||
- shell: bash
|
- shell: bash
|
||||||
run: |
|
run: |
|
||||||
git clone --branch v1.5.2 --depth 1 https://github.com/jasongin/nvs.git ~/.nvs
|
git clone --branch v1.5.2 --depth 1 https://github.com/jasongin/nvs.git ~/.nvs
|
||||||
|
|||||||
@@ -1235,7 +1235,7 @@ merge(Compressor.prototype, {
|
|||||||
var lvalues = get_lvalues(candidate);
|
var lvalues = get_lvalues(candidate);
|
||||||
var lhs_local = is_lhs_local(lhs);
|
var lhs_local = is_lhs_local(lhs);
|
||||||
if (!side_effects) side_effects = value_has_side_effects(candidate);
|
if (!side_effects) side_effects = value_has_side_effects(candidate);
|
||||||
var replace_all = replace_all_symbols();
|
var replace_all = replace_all_symbols(candidate);
|
||||||
var may_throw = candidate.may_throw(compressor) ? in_try ? function(node) {
|
var may_throw = candidate.may_throw(compressor) ? in_try ? function(node) {
|
||||||
return node.has_side_effects(compressor);
|
return node.has_side_effects(compressor);
|
||||||
} : side_effects_external : return_false;
|
} : side_effects_external : return_false;
|
||||||
@@ -1283,6 +1283,7 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
branch.expression = branch.expression.transform(scanner);
|
branch.expression = branch.expression.transform(scanner);
|
||||||
if (!replace_all) break;
|
if (!replace_all) break;
|
||||||
|
scan_rhs = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
abort = true;
|
abort = true;
|
||||||
@@ -1312,6 +1313,7 @@ merge(Compressor.prototype, {
|
|||||||
|
|
||||||
function in_conditional(node, parent) {
|
function in_conditional(node, parent) {
|
||||||
if (parent instanceof AST_Binary) return lazy_op[parent.operator] && parent.left !== node;
|
if (parent instanceof AST_Binary) return lazy_op[parent.operator] && parent.left !== node;
|
||||||
|
if (parent instanceof AST_Case) return parent.expression !== node;
|
||||||
if (parent instanceof AST_Conditional) return parent.condition !== node;
|
if (parent instanceof AST_Conditional) return parent.condition !== node;
|
||||||
return parent instanceof AST_If && parent.condition !== node;
|
return parent instanceof AST_If && parent.condition !== node;
|
||||||
}
|
}
|
||||||
@@ -1477,19 +1479,43 @@ merge(Compressor.prototype, {
|
|||||||
if (parent instanceof AST_Call) return node;
|
if (parent instanceof AST_Call) return node;
|
||||||
if (parent instanceof AST_Case) return node;
|
if (parent instanceof AST_Case) return node;
|
||||||
if (parent instanceof AST_Conditional) return node;
|
if (parent instanceof AST_Conditional) return node;
|
||||||
if (parent instanceof AST_Definitions) return find_stop(parent, level + 1);
|
if (parent instanceof AST_Definitions) return find_stop_unused(parent, level + 1);
|
||||||
if (parent instanceof AST_Exit) return node;
|
if (parent instanceof AST_Exit) return node;
|
||||||
if (parent instanceof AST_If) return node;
|
if (parent instanceof AST_If) return node;
|
||||||
if (parent instanceof AST_IterationStatement) return node;
|
if (parent instanceof AST_IterationStatement) return node;
|
||||||
if (parent instanceof AST_PropAccess) return node;
|
if (parent instanceof AST_PropAccess) return node;
|
||||||
if (parent instanceof AST_Sequence) return find_stop(parent, level + 1);
|
if (parent instanceof AST_Sequence) {
|
||||||
if (parent instanceof AST_SimpleStatement) return find_stop(parent, level + 1);
|
return (parent.tail_node() === node ? find_stop : find_stop_unused)(parent, level + 1);
|
||||||
|
}
|
||||||
|
if (parent instanceof AST_SimpleStatement) return find_stop_unused(parent, level + 1);
|
||||||
if (parent instanceof AST_Switch) return node;
|
if (parent instanceof AST_Switch) return node;
|
||||||
if (parent instanceof AST_Unary) return node;
|
if (parent instanceof AST_Unary) return node;
|
||||||
if (parent instanceof AST_VarDef) return node;
|
if (parent instanceof AST_VarDef) return node;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function find_stop_unused(node, level) {
|
||||||
|
var parent = scanner.parent(level);
|
||||||
|
if (is_last_node(node, parent)) return node;
|
||||||
|
if (in_conditional(node, parent)) return node;
|
||||||
|
if (parent instanceof AST_Assign) return find_stop_unused(parent, level + 1);
|
||||||
|
if (parent instanceof AST_Binary) return find_stop_unused(parent, level + 1);
|
||||||
|
if (parent instanceof AST_Call) return find_stop_unused(parent, level + 1);
|
||||||
|
if (parent instanceof AST_Case) return find_stop_unused(parent, level + 1);
|
||||||
|
if (parent instanceof AST_Conditional) return find_stop_unused(parent, level + 1);
|
||||||
|
if (parent instanceof AST_Definitions) return find_stop_unused(parent, level + 1);
|
||||||
|
if (parent instanceof AST_Exit) return find_stop_unused(parent, level + 1);
|
||||||
|
if (parent instanceof AST_If) return find_stop_unused(parent, level + 1);
|
||||||
|
if (parent instanceof AST_IterationStatement) return node;
|
||||||
|
if (parent instanceof AST_PropAccess) return find_stop_unused(parent, level + 1);
|
||||||
|
if (parent instanceof AST_Sequence) return find_stop_unused(parent, level + 1);
|
||||||
|
if (parent instanceof AST_SimpleStatement) return find_stop_unused(parent, level + 1);
|
||||||
|
if (parent instanceof AST_Switch) return find_stop_unused(parent, level + 1);
|
||||||
|
if (parent instanceof AST_Unary) return find_stop_unused(parent, level + 1);
|
||||||
|
if (parent instanceof AST_VarDef) return find_stop_unused(parent, level + 1);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
function mangleable_var(var_def) {
|
function mangleable_var(var_def) {
|
||||||
var value = var_def.value;
|
var value = var_def.value;
|
||||||
if (!(value instanceof AST_SymbolRef)) return;
|
if (!(value instanceof AST_SymbolRef)) return;
|
||||||
@@ -1656,7 +1682,8 @@ merge(Compressor.prototype, {
|
|||||||
return get_rvalue(expr).has_side_effects(compressor);
|
return get_rvalue(expr).has_side_effects(compressor);
|
||||||
}
|
}
|
||||||
|
|
||||||
function replace_all_symbols() {
|
function replace_all_symbols(expr) {
|
||||||
|
if (expr instanceof AST_Unary) return false;
|
||||||
if (side_effects) return false;
|
if (side_effects) return false;
|
||||||
if (value_def) return true;
|
if (value_def) return true;
|
||||||
if (lhs instanceof AST_SymbolRef) {
|
if (lhs instanceof AST_SymbolRef) {
|
||||||
@@ -1671,7 +1698,7 @@ merge(Compressor.prototype, {
|
|||||||
function symbol_in_lvalues(sym, parent) {
|
function symbol_in_lvalues(sym, parent) {
|
||||||
var lvalue = lvalues[sym.name];
|
var lvalue = lvalues[sym.name];
|
||||||
if (!lvalue) return;
|
if (!lvalue) return;
|
||||||
if (lvalue !== lhs) return !(parent instanceof AST_Call && parent.expression === sym);
|
if (lvalue !== lhs) return true;
|
||||||
scan_rhs = false;
|
scan_rhs = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2881,6 +2908,7 @@ merge(Compressor.prototype, {
|
|||||||
if (!non_converting_binary[this.operator]) depth++;
|
if (!non_converting_binary[this.operator]) depth++;
|
||||||
var left = this.left._eval(compressor, cached, depth);
|
var left = this.left._eval(compressor, cached, depth);
|
||||||
if (left === this.left) return this;
|
if (left === this.left) return this;
|
||||||
|
if (this.operator == (left ? "||" : "&&")) return left;
|
||||||
var right = this.right._eval(compressor, cached, depth);
|
var right = this.right._eval(compressor, cached, depth);
|
||||||
if (right === this.right) return this;
|
if (right === this.right) return this;
|
||||||
var result;
|
var result;
|
||||||
@@ -2995,6 +3023,7 @@ merge(Compressor.prototype, {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
convert_to_predicate(static_values);
|
convert_to_predicate(static_values);
|
||||||
|
var regexp_props = makePredicate("global ignoreCase multiline source");
|
||||||
def(AST_PropAccess, function(compressor, cached, depth) {
|
def(AST_PropAccess, function(compressor, cached, depth) {
|
||||||
if (compressor.option("unsafe")) {
|
if (compressor.option("unsafe")) {
|
||||||
var key = this.property;
|
var key = this.property;
|
||||||
@@ -3010,9 +3039,12 @@ merge(Compressor.prototype, {
|
|||||||
val = global_objs[exp.name];
|
val = global_objs[exp.name];
|
||||||
} else {
|
} else {
|
||||||
val = exp._eval(compressor, cached, depth + 1);
|
val = exp._eval(compressor, cached, depth + 1);
|
||||||
if (!val || val === exp) return this;
|
if (val == null || val === exp) return this;
|
||||||
if (typeof val == "object" && !HOP(val, key)) return this;
|
if (val instanceof RegExp) {
|
||||||
if (typeof val == "function") switch (key) {
|
if (!regexp_props[key]) return this;
|
||||||
|
} else if (typeof val == "object") {
|
||||||
|
if (!HOP(val, key)) return this;
|
||||||
|
} else if (typeof val == "function") switch (key) {
|
||||||
case "name":
|
case "name":
|
||||||
return val.node.name ? val.node.name.name : "";
|
return val.node.name ? val.node.name.name : "";
|
||||||
case "length":
|
case "length":
|
||||||
@@ -3045,7 +3077,10 @@ merge(Compressor.prototype, {
|
|||||||
cached.push(node);
|
cached.push(node);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return stat.value ? stat.value._eval(compressor, cached, depth) : undefined;
|
if (!stat.value) return undefined;
|
||||||
|
var val = stat.value._eval(compressor, cached, depth);
|
||||||
|
if (val === stat.value) return this;
|
||||||
|
return val;
|
||||||
} else if (compressor.option("unsafe") && exp instanceof AST_PropAccess) {
|
} else if (compressor.option("unsafe") && exp instanceof AST_PropAccess) {
|
||||||
var key = exp.property;
|
var key = exp.property;
|
||||||
if (key instanceof AST_Node) {
|
if (key instanceof AST_Node) {
|
||||||
@@ -3060,7 +3095,7 @@ merge(Compressor.prototype, {
|
|||||||
val = global_objs[e.name];
|
val = global_objs[e.name];
|
||||||
} else {
|
} else {
|
||||||
val = e._eval(compressor, cached, depth + 1);
|
val = e._eval(compressor, cached, depth + 1);
|
||||||
if (val === e || !val) return this;
|
if (val == null || val === e) return this;
|
||||||
var native_fn = native_fns[val.constructor.name];
|
var native_fn = native_fns[val.constructor.name];
|
||||||
if (!native_fn || !native_fn[key]) return this;
|
if (!native_fn || !native_fn[key]) return this;
|
||||||
}
|
}
|
||||||
@@ -6508,16 +6543,24 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (self.left instanceof AST_SymbolRef) {
|
} else if (self.left instanceof AST_SymbolRef) {
|
||||||
var def = self.left.definition();
|
|
||||||
if (def.scope === compressor.find_parent(AST_Lambda)) {
|
|
||||||
if (self.left.is_immutable()) return strip_assignment();
|
if (self.left.is_immutable()) return strip_assignment();
|
||||||
|
var def = self.left.definition();
|
||||||
|
var scope = def.scope.resolve();
|
||||||
|
var local = scope === compressor.find_parent(AST_Lambda);
|
||||||
var level = 0, node, parent = self;
|
var level = 0, node, parent = self;
|
||||||
do {
|
do {
|
||||||
node = parent;
|
node = parent;
|
||||||
parent = compressor.parent(level++);
|
parent = compressor.parent(level++);
|
||||||
if (parent instanceof AST_Exit) {
|
if (parent instanceof AST_Assign) {
|
||||||
|
if (!(parent.left instanceof AST_SymbolRef)) continue;
|
||||||
|
if (parent.left.definition() !== def) continue;
|
||||||
if (in_try(level, parent)) break;
|
if (in_try(level, parent)) break;
|
||||||
if (is_reachable(def.scope, [ def ])) break;
|
def.fixed = false;
|
||||||
|
return strip_assignment();
|
||||||
|
} else if (parent instanceof AST_Exit) {
|
||||||
|
if (!local) break;
|
||||||
|
if (in_try(level, parent)) break;
|
||||||
|
if (is_reachable(scope, [ def ])) break;
|
||||||
def.fixed = false;
|
def.fixed = false;
|
||||||
return strip_assignment();
|
return strip_assignment();
|
||||||
}
|
}
|
||||||
@@ -6526,7 +6569,6 @@ merge(Compressor.prototype, {
|
|||||||
|| parent instanceof AST_UnaryPrefix);
|
|| parent instanceof AST_UnaryPrefix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
self = self.lift_sequences(compressor);
|
self = self.lift_sequences(compressor);
|
||||||
if (!compressor.option("assignments")) return self;
|
if (!compressor.option("assignments")) return self;
|
||||||
if (self.operator == "=" && self.left instanceof AST_SymbolRef && self.right instanceof AST_Binary) {
|
if (self.operator == "=" && self.left instanceof AST_SymbolRef && self.right instanceof AST_Binary) {
|
||||||
@@ -6564,9 +6606,9 @@ merge(Compressor.prototype, {
|
|||||||
self.right = make_node(AST_Null, right);
|
self.right = make_node(AST_Null, right);
|
||||||
var may_throw = node.may_throw(compressor);
|
var may_throw = node.may_throw(compressor);
|
||||||
self.right = right;
|
self.right = right;
|
||||||
var scope = self.left.definition().scope;
|
|
||||||
var parent;
|
var parent;
|
||||||
while ((parent = compressor.parent(level++)) !== scope) {
|
while (parent = compressor.parent(level++)) {
|
||||||
|
if (parent === scope) return false;
|
||||||
if (parent instanceof AST_Try) {
|
if (parent instanceof AST_Try) {
|
||||||
if (parent.bfinally) return true;
|
if (parent.bfinally) return true;
|
||||||
if (may_throw && parent.bcatch) return true;
|
if (may_throw && parent.bcatch) return true;
|
||||||
@@ -6633,7 +6675,7 @@ merge(Compressor.prototype, {
|
|||||||
&& alt_tail instanceof AST_Assign
|
&& alt_tail instanceof AST_Assign
|
||||||
&& seq_tail.operator == alt_tail.operator
|
&& seq_tail.operator == alt_tail.operator
|
||||||
&& seq_tail.left.equivalent_to(alt_tail.left)
|
&& seq_tail.left.equivalent_to(alt_tail.left)
|
||||||
&& (is_eq && !seq_tail.left.has_side_effects(compressor)
|
&& (is_eq && seq_tail.left instanceof AST_SymbolRef
|
||||||
|| !condition.has_side_effects(compressor)
|
|| !condition.has_side_effects(compressor)
|
||||||
&& can_shift_lhs_of_tail(consequent)
|
&& can_shift_lhs_of_tail(consequent)
|
||||||
&& can_shift_lhs_of_tail(alternative))) {
|
&& can_shift_lhs_of_tail(alternative))) {
|
||||||
@@ -6802,16 +6844,9 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function can_shift_lhs_of_tail(node) {
|
function can_shift_lhs_of_tail(node) {
|
||||||
if (node === node.tail_node()) return true;
|
return node === node.tail_node() || all(node.expressions.slice(0, -1), function(expr) {
|
||||||
var exprs = node.expressions;
|
return !expr.has_side_effects(compressor);
|
||||||
for (var i = exprs.length - 1; --i >= 0;) {
|
});
|
||||||
var expr = exprs[i];
|
|
||||||
if (!(expr instanceof AST_Assign) && expr.has_side_effects(compressor)
|
|
||||||
|| expr.operator != "="
|
|
||||||
|| expr.left.has_side_effects(compressor)
|
|
||||||
|| expr.right.has_side_effects(compressor)) return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function pop_lhs(node) {
|
function pop_lhs(node) {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
"description": "JavaScript parser, mangler/compressor and beautifier toolkit",
|
"description": "JavaScript parser, mangler/compressor and beautifier toolkit",
|
||||||
"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.6.6",
|
"version": "3.6.9",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.8.0"
|
"node": ">=0.8.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -6348,3 +6348,123 @@ issue_3526_2: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_3562: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
conditionals: true,
|
||||||
|
sequences: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f(a) {
|
||||||
|
console.log("PASS", a);
|
||||||
|
}
|
||||||
|
function g(b) {
|
||||||
|
console.log("FAIL", b);
|
||||||
|
}
|
||||||
|
var h;
|
||||||
|
var c;
|
||||||
|
if (console) {
|
||||||
|
h = f;
|
||||||
|
c = "PASS";
|
||||||
|
} else {
|
||||||
|
h = g;
|
||||||
|
c = "FAIL";
|
||||||
|
}
|
||||||
|
h(c);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f(a) {
|
||||||
|
console.log("PASS", a);
|
||||||
|
}
|
||||||
|
function g(b) {
|
||||||
|
console.log("FAIL", b);
|
||||||
|
}
|
||||||
|
var h;
|
||||||
|
var c;
|
||||||
|
c = console ? (h = f, "PASS") : (h = g, "FAIL"),
|
||||||
|
h(c);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
dot_throw_assign_sequence: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = "FAIL";
|
||||||
|
try {
|
||||||
|
var b;
|
||||||
|
b[0] = (a = "PASS", 0);
|
||||||
|
a = 1 + a;
|
||||||
|
} catch (c) {
|
||||||
|
}
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = "FAIL";
|
||||||
|
try {
|
||||||
|
var b;
|
||||||
|
b[0] = (a = "PASS", 0);
|
||||||
|
a = 1 + a;
|
||||||
|
} catch (c) {
|
||||||
|
}
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
call_assign_order: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a, b = 1, c = 0, log = console.log;
|
||||||
|
(function() {
|
||||||
|
a = b = "PASS";
|
||||||
|
})((b = "FAIL", c++));
|
||||||
|
log(a, b);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a, b = 1, c = 0, log = console.log;
|
||||||
|
(function() {
|
||||||
|
a = b = "PASS";
|
||||||
|
})((b = "FAIL", c++));
|
||||||
|
log(a, b);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_3573: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var c = 0;
|
||||||
|
(function(b) {
|
||||||
|
while (--b) {
|
||||||
|
b = NaN;
|
||||||
|
switch (0 / this < 0) {
|
||||||
|
case c++, false:
|
||||||
|
case c++, NaN:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})(3);
|
||||||
|
console.log(c);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var c = 0;
|
||||||
|
(function(b) {
|
||||||
|
while (--b) {
|
||||||
|
b = NaN;
|
||||||
|
switch (0 / this < 0) {
|
||||||
|
case c++, false:
|
||||||
|
case c++, NaN:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})(3);
|
||||||
|
console.log(c);
|
||||||
|
}
|
||||||
|
expect_stdout: "1"
|
||||||
|
}
|
||||||
|
|||||||
@@ -1489,3 +1489,29 @@ angularjs_chain: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_3576: {
|
||||||
|
options = {
|
||||||
|
conditionals: true,
|
||||||
|
evaluate: true,
|
||||||
|
pure_getters: "strict",
|
||||||
|
reduce_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var c = "FAIL";
|
||||||
|
(function(a) {
|
||||||
|
(a = -1) ? (a && (a.a = 0)) : (a && (a.a = 0));
|
||||||
|
a && a[c = "PASS"]++;
|
||||||
|
})();
|
||||||
|
console.log(c);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var c = "FAIL";
|
||||||
|
(function(a) {
|
||||||
|
a = -1, a, a.a = 0;
|
||||||
|
a, a[c = "PASS"]++;
|
||||||
|
})();
|
||||||
|
console.log(c);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|||||||
@@ -1064,3 +1064,68 @@ issue_3552: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unreachable_assign: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(A = "P" + (A = "A" + (B = "S" + (A = B = "S"))), A, B);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(A = "P" + "A" + (B = "S" + "S"), A, B);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS PASS SS"
|
||||||
|
}
|
||||||
|
|
||||||
|
catch_return_assign: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(function() {
|
||||||
|
try {
|
||||||
|
throw "FAIL";
|
||||||
|
} catch (e) {
|
||||||
|
return e = "PASS";
|
||||||
|
}
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(function() {
|
||||||
|
try {
|
||||||
|
throw "FAIL";
|
||||||
|
} catch (e) {
|
||||||
|
return "PASS";
|
||||||
|
}
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_3578: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = "FAIL", b, c;
|
||||||
|
try {
|
||||||
|
b = c.p = b = 0;
|
||||||
|
} catch (e) {
|
||||||
|
b += 42;
|
||||||
|
b && (a = "PASS");
|
||||||
|
}
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = "FAIL", b, c;
|
||||||
|
try {
|
||||||
|
b = c.p = b = 0;
|
||||||
|
} catch (e) {
|
||||||
|
b += 42;
|
||||||
|
b && (a = "PASS");
|
||||||
|
}
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|||||||
@@ -237,22 +237,39 @@ unsafe_constant: {
|
|||||||
unsafe: true,
|
unsafe: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
console.log(
|
console.log(true.a, false.a);
|
||||||
true.a,
|
console.log(true.valueOf(), false.valueOf());
|
||||||
false.a,
|
try {
|
||||||
null.a,
|
console.log(null.a);
|
||||||
undefined.a
|
} catch (e) {
|
||||||
);
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
console.log(undefined.a);
|
||||||
|
} catch (e) {
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
console.log(
|
console.log(void 0, void 0);
|
||||||
void 0,
|
console.log(true, false);
|
||||||
false.a,
|
try {
|
||||||
null.a,
|
console.log(null.a);
|
||||||
(void 0).a
|
} catch (e) {
|
||||||
);
|
console.log("PASS");
|
||||||
}
|
}
|
||||||
expect_stdout: true
|
try {
|
||||||
|
console.log((void 0).a);
|
||||||
|
} catch (e) {
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"undefined undefined",
|
||||||
|
"true false",
|
||||||
|
"PASS",
|
||||||
|
"PASS",
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe_object: {
|
unsafe_object: {
|
||||||
@@ -1859,3 +1876,27 @@ issue_3558: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "1 0"
|
expect_stdout: "1 0"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_3568: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
unsafe: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = 0;
|
||||||
|
function f(b) {
|
||||||
|
return b && b.p;
|
||||||
|
}
|
||||||
|
console.log(f(++a + f()));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = 0;
|
||||||
|
function f(b) {
|
||||||
|
return b && b.p;
|
||||||
|
}
|
||||||
|
console.log(NaN);
|
||||||
|
}
|
||||||
|
expect_stdout: "NaN"
|
||||||
|
}
|
||||||
|
|||||||
@@ -3370,3 +3370,33 @@ issue_3512: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_3562: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = "PASS";
|
||||||
|
function f(b) {
|
||||||
|
f = function() {
|
||||||
|
console.log(b);
|
||||||
|
};
|
||||||
|
return "FAIL";
|
||||||
|
}
|
||||||
|
a = f(a);
|
||||||
|
f(a);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = "PASS";
|
||||||
|
function f(b) {
|
||||||
|
f = function() {
|
||||||
|
console.log(b);
|
||||||
|
};
|
||||||
|
return "FAIL";
|
||||||
|
}
|
||||||
|
a = f(a);
|
||||||
|
f(a);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|||||||
@@ -36,6 +36,20 @@ regexp_2: {
|
|||||||
expect_stdout: '["PASS","pass"]'
|
expect_stdout: '["PASS","pass"]'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
regexp_properties: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
unsafe: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(/abc/g.source, /abc/g.global, /abc/g.ignoreCase, /abc/g.lastIndex, /abc/g.multiline);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log("abc", true, false, /abc/g.lastIndex, false);
|
||||||
|
}
|
||||||
|
expect_stdout: "abc true false 0 false"
|
||||||
|
}
|
||||||
|
|
||||||
issue_3434_1: {
|
issue_3434_1: {
|
||||||
options = {
|
options = {
|
||||||
evaluate: true,
|
evaluate: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user