Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fdee083465 | ||
|
|
5ffc17d4aa | ||
|
|
6aa750010f | ||
|
|
76df77c08c | ||
|
|
957d5537a8 |
@@ -620,6 +620,8 @@ If you're using the `X-SourceMap` header instead, you can just omit `sourceMap.u
|
|||||||
|
|
||||||
- `dead_code` (default: `true`) -- remove unreachable code
|
- `dead_code` (default: `true`) -- remove unreachable code
|
||||||
|
|
||||||
|
- `directives` (default: `true`) -- remove redundant or non-standard directives
|
||||||
|
|
||||||
- `drop_console` (default: `false`) -- Pass `true` to discard calls to
|
- `drop_console` (default: `false`) -- Pass `true` to discard calls to
|
||||||
`console.*` functions. If you wish to drop a specific function call
|
`console.*` functions. If you wish to drop a specific function call
|
||||||
such as `console.info` and/or retain side effects from function arguments
|
such as `console.info` and/or retain side effects from function arguments
|
||||||
|
|||||||
@@ -328,7 +328,7 @@ var AST_Toplevel = DEFNODE("Toplevel", "globals", {
|
|||||||
var body = this.body;
|
var body = this.body;
|
||||||
var wrapped_tl = "(function(exports){'$ORIG';})(typeof " + name + "=='undefined'?(" + name + "={}):" + name + ");";
|
var wrapped_tl = "(function(exports){'$ORIG';})(typeof " + name + "=='undefined'?(" + name + "={}):" + name + ");";
|
||||||
wrapped_tl = parse(wrapped_tl);
|
wrapped_tl = parse(wrapped_tl);
|
||||||
wrapped_tl = wrapped_tl.transform(new TreeTransformer(function before(node) {
|
wrapped_tl = wrapped_tl.transform(new TreeTransformer(function(node) {
|
||||||
if (node instanceof AST_Directive && node.value == "$ORIG") {
|
if (node instanceof AST_Directive && node.value == "$ORIG") {
|
||||||
return MAP.splice(body);
|
return MAP.splice(body);
|
||||||
}
|
}
|
||||||
|
|||||||
515
lib/compress.js
515
lib/compress.js
@@ -54,6 +54,7 @@ function Compressor(options, false_by_default) {
|
|||||||
comparisons : !false_by_default,
|
comparisons : !false_by_default,
|
||||||
conditionals : !false_by_default,
|
conditionals : !false_by_default,
|
||||||
dead_code : !false_by_default,
|
dead_code : !false_by_default,
|
||||||
|
directives : !false_by_default,
|
||||||
drop_console : false,
|
drop_console : false,
|
||||||
drop_debugger : !false_by_default,
|
drop_debugger : !false_by_default,
|
||||||
evaluate : !false_by_default,
|
evaluate : !false_by_default,
|
||||||
@@ -424,6 +425,7 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function safe_to_read(tw, def) {
|
function safe_to_read(tw, def) {
|
||||||
|
if (def.single_use == "m") return false;
|
||||||
if (tw.safe_ids[def.id]) {
|
if (tw.safe_ids[def.id]) {
|
||||||
if (def.fixed == null) {
|
if (def.fixed == null) {
|
||||||
var orig = def.orig[0];
|
var orig = def.orig[0];
|
||||||
@@ -704,7 +706,7 @@ merge(Compressor.prototype, {
|
|||||||
tw.loop_ids[d.id] = tw.in_loop;
|
tw.loop_ids[d.id] = tw.in_loop;
|
||||||
}
|
}
|
||||||
var value;
|
var value;
|
||||||
if (d.fixed === undefined || !safe_to_read(tw, d) || d.single_use == "m") {
|
if (d.fixed === undefined || !safe_to_read(tw, d)) {
|
||||||
d.fixed = false;
|
d.fixed = false;
|
||||||
} else if (d.fixed) {
|
} else if (d.fixed) {
|
||||||
value = this.fixed_value();
|
value = this.fixed_value();
|
||||||
@@ -2264,29 +2266,35 @@ merge(Compressor.prototype, {
|
|||||||
|
|
||||||
// methods to determine whether an expression has a boolean result type
|
// methods to determine whether an expression has a boolean result type
|
||||||
(function(def) {
|
(function(def) {
|
||||||
var unary_bool = makePredicate("! delete");
|
|
||||||
var binary_bool = makePredicate("in instanceof == != === !== < <= >= >");
|
|
||||||
def(AST_Node, return_false);
|
def(AST_Node, return_false);
|
||||||
|
def(AST_Assign, function(compressor) {
|
||||||
|
return this.operator == "=" && this.right.is_boolean(compressor);
|
||||||
|
});
|
||||||
|
var binary = makePredicate("in instanceof == != === !== < <= >= >");
|
||||||
|
def(AST_Binary, function(compressor) {
|
||||||
|
return binary[this.operator] || lazy_op[this.operator]
|
||||||
|
&& this.left.is_boolean(compressor)
|
||||||
|
&& this.right.is_boolean(compressor);
|
||||||
|
});
|
||||||
|
def(AST_Boolean, return_true);
|
||||||
|
var fn = makePredicate("every hasOwnProperty isPrototypeOf propertyIsEnumerable some");
|
||||||
|
def(AST_Call, function(compressor) {
|
||||||
|
if (!compressor.option("unsafe")) return false;
|
||||||
|
var exp = this.expression;
|
||||||
|
return exp instanceof AST_Dot && (fn[exp.property]
|
||||||
|
|| exp.property == "test" && exp.expression instanceof AST_RegExp);
|
||||||
|
});
|
||||||
|
def(AST_Conditional, function(compressor) {
|
||||||
|
return this.consequent.is_boolean(compressor) && this.alternative.is_boolean(compressor);
|
||||||
|
});
|
||||||
|
def(AST_New, return_false);
|
||||||
|
def(AST_Sequence, function(compressor) {
|
||||||
|
return this.tail_node().is_boolean(compressor);
|
||||||
|
});
|
||||||
|
var unary = makePredicate("! delete");
|
||||||
def(AST_UnaryPrefix, function() {
|
def(AST_UnaryPrefix, function() {
|
||||||
return unary_bool[this.operator];
|
return unary[this.operator];
|
||||||
});
|
});
|
||||||
def(AST_Binary, function() {
|
|
||||||
return binary_bool[this.operator]
|
|
||||||
|| lazy_op[this.operator]
|
|
||||||
&& this.left.is_boolean()
|
|
||||||
&& this.right.is_boolean();
|
|
||||||
});
|
|
||||||
def(AST_Conditional, function() {
|
|
||||||
return this.consequent.is_boolean() && this.alternative.is_boolean();
|
|
||||||
});
|
|
||||||
def(AST_Assign, function() {
|
|
||||||
return this.operator == "=" && this.right.is_boolean();
|
|
||||||
});
|
|
||||||
def(AST_Sequence, function() {
|
|
||||||
return this.tail_node().is_boolean();
|
|
||||||
});
|
|
||||||
def(AST_True, return_true);
|
|
||||||
def(AST_False, return_true);
|
|
||||||
})(function(node, func) {
|
})(function(node, func) {
|
||||||
node.DEFMETHOD("is_boolean", func);
|
node.DEFMETHOD("is_boolean", func);
|
||||||
});
|
});
|
||||||
@@ -2294,27 +2302,80 @@ merge(Compressor.prototype, {
|
|||||||
// methods to determine if an expression has a numeric result type
|
// methods to determine if an expression has a numeric result type
|
||||||
(function(def) {
|
(function(def) {
|
||||||
def(AST_Node, return_false);
|
def(AST_Node, return_false);
|
||||||
def(AST_Number, return_true);
|
|
||||||
var unary = makePredicate("+ - ~ ++ --");
|
|
||||||
def(AST_Unary, function() {
|
|
||||||
return unary[this.operator];
|
|
||||||
});
|
|
||||||
var binary = makePredicate("- * / % & | ^ << >> >>>");
|
var binary = makePredicate("- * / % & | ^ << >> >>>");
|
||||||
|
def(AST_Assign, function(compressor) {
|
||||||
|
return binary[this.operator.slice(0, -1)]
|
||||||
|
|| this.operator == "=" && this.right.is_number(compressor);
|
||||||
|
});
|
||||||
def(AST_Binary, function(compressor) {
|
def(AST_Binary, function(compressor) {
|
||||||
return binary[this.operator] || this.operator == "+"
|
return binary[this.operator] || this.operator == "+"
|
||||||
&& this.left.is_number(compressor)
|
&& this.left.is_number(compressor)
|
||||||
&& this.right.is_number(compressor);
|
&& this.right.is_number(compressor);
|
||||||
});
|
});
|
||||||
def(AST_Assign, function(compressor) {
|
var fn = makePredicate([
|
||||||
return binary[this.operator.slice(0, -1)]
|
"charCodeAt",
|
||||||
|| this.operator == "=" && this.right.is_number(compressor);
|
"getDate",
|
||||||
});
|
"getDay",
|
||||||
def(AST_Sequence, function(compressor) {
|
"getFullYear",
|
||||||
return this.tail_node().is_number(compressor);
|
"getHours",
|
||||||
|
"getMilliseconds",
|
||||||
|
"getMinutes",
|
||||||
|
"getMonth",
|
||||||
|
"getSeconds",
|
||||||
|
"getTime",
|
||||||
|
"getTimezoneOffset",
|
||||||
|
"getUTCDate",
|
||||||
|
"getUTCDay",
|
||||||
|
"getUTCFullYear",
|
||||||
|
"getUTCHours",
|
||||||
|
"getUTCMilliseconds",
|
||||||
|
"getUTCMinutes",
|
||||||
|
"getUTCMonth",
|
||||||
|
"getUTCSeconds",
|
||||||
|
"getYear",
|
||||||
|
"indexOf",
|
||||||
|
"lastIndexOf",
|
||||||
|
"localeCompare",
|
||||||
|
"push",
|
||||||
|
"search",
|
||||||
|
"setDate",
|
||||||
|
"setFullYear",
|
||||||
|
"setHours",
|
||||||
|
"setMilliseconds",
|
||||||
|
"setMinutes",
|
||||||
|
"setMonth",
|
||||||
|
"setSeconds",
|
||||||
|
"setTime",
|
||||||
|
"setUTCDate",
|
||||||
|
"setUTCFullYear",
|
||||||
|
"setUTCHours",
|
||||||
|
"setUTCMilliseconds",
|
||||||
|
"setUTCMinutes",
|
||||||
|
"setUTCMonth",
|
||||||
|
"setUTCSeconds",
|
||||||
|
"setYear",
|
||||||
|
"toExponential",
|
||||||
|
"toFixed",
|
||||||
|
"toPrecision",
|
||||||
|
]);
|
||||||
|
def(AST_Call, function(compressor) {
|
||||||
|
if (!compressor.option("unsafe")) return false;
|
||||||
|
var exp = this.expression;
|
||||||
|
return exp instanceof AST_Dot && (fn[exp.property]
|
||||||
|
|| is_undeclared_ref(exp.expression) && exp.expression.name == "Math");
|
||||||
});
|
});
|
||||||
def(AST_Conditional, function(compressor) {
|
def(AST_Conditional, function(compressor) {
|
||||||
return this.consequent.is_number(compressor) && this.alternative.is_number(compressor);
|
return this.consequent.is_number(compressor) && this.alternative.is_number(compressor);
|
||||||
});
|
});
|
||||||
|
def(AST_New, return_false);
|
||||||
|
def(AST_Number, return_true);
|
||||||
|
def(AST_Sequence, function(compressor) {
|
||||||
|
return this.tail_node().is_number(compressor);
|
||||||
|
});
|
||||||
|
var unary = makePredicate("+ - ~ ++ --");
|
||||||
|
def(AST_Unary, function() {
|
||||||
|
return unary[this.operator];
|
||||||
|
});
|
||||||
})(function(node, func) {
|
})(function(node, func) {
|
||||||
node.DEFMETHOD("is_number", func);
|
node.DEFMETHOD("is_number", func);
|
||||||
});
|
});
|
||||||
@@ -2902,7 +2963,7 @@ merge(Compressor.prototype, {
|
|||||||
var map;
|
var map;
|
||||||
if (expr instanceof AST_Array) {
|
if (expr instanceof AST_Array) {
|
||||||
map = native_fns.Array;
|
map = native_fns.Array;
|
||||||
} else if (expr.is_boolean()) {
|
} else if (expr.is_boolean(compressor)) {
|
||||||
map = native_fns.Boolean;
|
map = native_fns.Boolean;
|
||||||
} else if (expr.is_number(compressor)) {
|
} else if (expr.is_number(compressor)) {
|
||||||
map = native_fns.Number;
|
map = native_fns.Number;
|
||||||
@@ -3205,8 +3266,10 @@ merge(Compressor.prototype, {
|
|||||||
|
|
||||||
/* -----[ optimizers ]----- */
|
/* -----[ optimizers ]----- */
|
||||||
|
|
||||||
|
var directives = makePredicate(["use asm", "use strict"]);
|
||||||
OPT(AST_Directive, function(self, compressor) {
|
OPT(AST_Directive, function(self, compressor) {
|
||||||
if (compressor.has_directive(self.value) !== self) {
|
if (compressor.option("directives")
|
||||||
|
&& (!directives[self.value] || compressor.has_directive(self.value) !== self)) {
|
||||||
return make_node(AST_EmptyStatement, self);
|
return make_node(AST_EmptyStatement, self);
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
@@ -3353,202 +3416,200 @@ merge(Compressor.prototype, {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
// pass 3: we should drop declarations not in_use
|
// pass 3: we should drop declarations not in_use
|
||||||
var tt = new TreeTransformer(
|
var tt = new TreeTransformer(function(node, descend, in_list) {
|
||||||
function before(node, descend, in_list) {
|
var parent = tt.parent();
|
||||||
var parent = tt.parent();
|
if (drop_vars) {
|
||||||
if (drop_vars) {
|
var props = [], sym = assign_as_unused(node, props);
|
||||||
var props = [], sym = assign_as_unused(node, props);
|
if (sym instanceof AST_SymbolRef) {
|
||||||
if (sym instanceof AST_SymbolRef) {
|
var def = sym.definition();
|
||||||
var def = sym.definition();
|
var in_use = def.id in in_use_ids;
|
||||||
var in_use = def.id in in_use_ids;
|
var value = null;
|
||||||
var value = null;
|
if (node instanceof AST_Assign) {
|
||||||
if (node instanceof AST_Assign) {
|
if (!in_use || node.left === sym && def.id in fixed_ids && fixed_ids[def.id] !== node) {
|
||||||
if (!in_use || node.left === sym && def.id in fixed_ids && fixed_ids[def.id] !== node) {
|
value = node.right;
|
||||||
value = node.right;
|
|
||||||
}
|
|
||||||
} else if (!in_use) {
|
|
||||||
value = make_node(AST_Number, node, {
|
|
||||||
value: 0
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if (value) {
|
} else if (!in_use) {
|
||||||
props.push(value);
|
value = make_node(AST_Number, node, {
|
||||||
return maintain_this_binding(compressor, parent, node, make_sequence(node, props.map(function(prop) {
|
value: 0
|
||||||
return prop.transform(tt);
|
|
||||||
})));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (scope !== self) return;
|
|
||||||
if (node instanceof AST_Function
|
|
||||||
&& node.name
|
|
||||||
&& !compressor.option("keep_fnames")) {
|
|
||||||
var def = node.name.definition();
|
|
||||||
// any declarations with same name will overshadow
|
|
||||||
// name of this anonymous function and can therefore
|
|
||||||
// never be used anywhere
|
|
||||||
if (!(def.id in in_use_ids) || def.orig.length > 1) node.name = null;
|
|
||||||
}
|
|
||||||
if (node instanceof AST_Lambda && !(node instanceof AST_Accessor)) {
|
|
||||||
var trim = !compressor.option("keep_fargs");
|
|
||||||
for (var a = node.argnames, i = a.length; --i >= 0;) {
|
|
||||||
var sym = a[i];
|
|
||||||
if (!(sym.definition().id in in_use_ids)) {
|
|
||||||
sym.__unused = true;
|
|
||||||
if (trim) {
|
|
||||||
a.pop();
|
|
||||||
compressor[sym.unreferenced() ? "warn" : "info"]("Dropping unused function argument {name} [{file}:{line},{col}]", template(sym));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
trim = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (drop_funcs && node instanceof AST_Defun && node !== self) {
|
|
||||||
var def = node.name.definition();
|
|
||||||
if (!(def.id in in_use_ids)) {
|
|
||||||
compressor[node.name.unreferenced() ? "warn" : "info"]("Dropping unused function {name} [{file}:{line},{col}]", template(node.name));
|
|
||||||
def.eliminated++;
|
|
||||||
return make_node(AST_EmptyStatement, node);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (node instanceof AST_Definitions && !(parent instanceof AST_ForIn && parent.init === node)) {
|
|
||||||
// place uninitialized names at the start
|
|
||||||
var body = [], head = [], tail = [];
|
|
||||||
// for unused names whose initialization has
|
|
||||||
// side effects, we can cascade the init. code
|
|
||||||
// into the next one, or next statement.
|
|
||||||
var side_effects = [];
|
|
||||||
node.definitions.forEach(function(def) {
|
|
||||||
if (def.value) def.value = def.value.transform(tt);
|
|
||||||
var sym = def.name.definition();
|
|
||||||
if (!drop_vars || sym.id in in_use_ids) {
|
|
||||||
if (def.value && sym.id in fixed_ids && fixed_ids[sym.id] !== def) {
|
|
||||||
def.value = def.value.drop_side_effect_free(compressor);
|
|
||||||
}
|
|
||||||
if (def.name instanceof AST_SymbolVar) {
|
|
||||||
var var_defs = var_defs_by_id.get(sym.id);
|
|
||||||
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));
|
|
||||||
if (def.value) {
|
|
||||||
var ref = make_node(AST_SymbolRef, def.name, def.name);
|
|
||||||
sym.references.push(ref);
|
|
||||||
var assign = make_node(AST_Assign, def, {
|
|
||||||
operator: "=",
|
|
||||||
left: ref,
|
|
||||||
right: def.value
|
|
||||||
});
|
|
||||||
if (fixed_ids[sym.id] === def) {
|
|
||||||
fixed_ids[sym.id] = assign;
|
|
||||||
}
|
|
||||||
side_effects.push(assign.transform(tt));
|
|
||||||
}
|
|
||||||
remove(var_defs, def);
|
|
||||||
sym.eliminated++;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (def.value) {
|
|
||||||
if (side_effects.length > 0) {
|
|
||||||
if (tail.length > 0) {
|
|
||||||
side_effects.push(def.value);
|
|
||||||
def.value = make_sequence(def.value, side_effects);
|
|
||||||
} else {
|
|
||||||
body.push(make_node(AST_SimpleStatement, node, {
|
|
||||||
body: make_sequence(node, side_effects)
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
side_effects = [];
|
|
||||||
}
|
|
||||||
tail.push(def);
|
|
||||||
} else {
|
|
||||||
head.push(def);
|
|
||||||
}
|
|
||||||
} else if (sym.orig[0] instanceof AST_SymbolCatch) {
|
|
||||||
var value = def.value && def.value.drop_side_effect_free(compressor);
|
|
||||||
if (value) side_effects.push(value);
|
|
||||||
def.value = null;
|
|
||||||
head.push(def);
|
|
||||||
} else {
|
|
||||||
var value = def.value && def.value.drop_side_effect_free(compressor);
|
|
||||||
if (value) {
|
|
||||||
compressor.warn("Side effects in initialization of unused variable {name} [{file}:{line},{col}]", template(def.name));
|
|
||||||
side_effects.push(value);
|
|
||||||
} else {
|
|
||||||
compressor[def.name.unreferenced() ? "warn" : "info"]("Dropping unused variable {name} [{file}:{line},{col}]", template(def.name));
|
|
||||||
}
|
|
||||||
sym.eliminated++;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (head.length > 0 || tail.length > 0) {
|
|
||||||
node.definitions = head.concat(tail);
|
|
||||||
body.push(node);
|
|
||||||
}
|
|
||||||
if (side_effects.length > 0) {
|
|
||||||
body.push(make_node(AST_SimpleStatement, node, {
|
|
||||||
body: make_sequence(node, side_effects)
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
switch (body.length) {
|
|
||||||
case 0:
|
|
||||||
return in_list ? MAP.skip : make_node(AST_EmptyStatement, node);
|
|
||||||
case 1:
|
|
||||||
return body[0];
|
|
||||||
default:
|
|
||||||
return in_list ? MAP.splice(body) : make_node(AST_BlockStatement, node, {
|
|
||||||
body: body
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
if (value) {
|
||||||
// certain combination of unused name + side effect leads to:
|
props.push(value);
|
||||||
// https://github.com/mishoo/UglifyJS2/issues/44
|
return maintain_this_binding(compressor, parent, node, make_sequence(node, props.map(function(prop) {
|
||||||
// https://github.com/mishoo/UglifyJS2/issues/1830
|
return prop.transform(tt);
|
||||||
// https://github.com/mishoo/UglifyJS2/issues/1838
|
})));
|
||||||
// that's an invalid AST.
|
|
||||||
// We fix it at this stage by moving the `var` outside the `for`.
|
|
||||||
if (node instanceof AST_For) {
|
|
||||||
descend(node, this);
|
|
||||||
var block;
|
|
||||||
if (node.init instanceof AST_BlockStatement) {
|
|
||||||
block = node.init;
|
|
||||||
node.init = block.body.pop();
|
|
||||||
block.body.push(node);
|
|
||||||
}
|
}
|
||||||
if (node.init instanceof AST_SimpleStatement) {
|
|
||||||
node.init = node.init.body;
|
|
||||||
} else if (is_empty(node.init)) {
|
|
||||||
node.init = null;
|
|
||||||
}
|
|
||||||
return !block ? node : in_list ? MAP.splice(block.body) : block;
|
|
||||||
}
|
|
||||||
if (node instanceof AST_LabeledStatement && node.body instanceof AST_For) {
|
|
||||||
descend(node, this);
|
|
||||||
if (node.body instanceof AST_BlockStatement) {
|
|
||||||
var block = node.body;
|
|
||||||
node.body = block.body.pop();
|
|
||||||
block.body.push(node);
|
|
||||||
return in_list ? MAP.splice(block.body) : block;
|
|
||||||
}
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
if (node instanceof AST_Scope) {
|
|
||||||
var save_scope = scope;
|
|
||||||
scope = node;
|
|
||||||
descend(node, this);
|
|
||||||
scope = save_scope;
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
|
|
||||||
function template(sym) {
|
|
||||||
return {
|
|
||||||
name : sym.name,
|
|
||||||
file : sym.start.file,
|
|
||||||
line : sym.start.line,
|
|
||||||
col : sym.start.col
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
if (scope !== self) return;
|
||||||
|
if (node instanceof AST_Function
|
||||||
|
&& node.name
|
||||||
|
&& !compressor.option("keep_fnames")) {
|
||||||
|
var def = node.name.definition();
|
||||||
|
// any declarations with same name will overshadow
|
||||||
|
// name of this anonymous function and can therefore
|
||||||
|
// never be used anywhere
|
||||||
|
if (!(def.id in in_use_ids) || def.orig.length > 1) node.name = null;
|
||||||
|
}
|
||||||
|
if (node instanceof AST_Lambda && !(node instanceof AST_Accessor)) {
|
||||||
|
var trim = !compressor.option("keep_fargs");
|
||||||
|
for (var a = node.argnames, i = a.length; --i >= 0;) {
|
||||||
|
var sym = a[i];
|
||||||
|
if (!(sym.definition().id in in_use_ids)) {
|
||||||
|
sym.__unused = true;
|
||||||
|
if (trim) {
|
||||||
|
a.pop();
|
||||||
|
compressor[sym.unreferenced() ? "warn" : "info"]("Dropping unused function argument {name} [{file}:{line},{col}]", template(sym));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
trim = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (drop_funcs && node instanceof AST_Defun && node !== self) {
|
||||||
|
var def = node.name.definition();
|
||||||
|
if (!(def.id in in_use_ids)) {
|
||||||
|
compressor[node.name.unreferenced() ? "warn" : "info"]("Dropping unused function {name} [{file}:{line},{col}]", template(node.name));
|
||||||
|
def.eliminated++;
|
||||||
|
return make_node(AST_EmptyStatement, node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (node instanceof AST_Definitions && !(parent instanceof AST_ForIn && parent.init === node)) {
|
||||||
|
// place uninitialized names at the start
|
||||||
|
var body = [], head = [], tail = [];
|
||||||
|
// for unused names whose initialization has
|
||||||
|
// side effects, we can cascade the init. code
|
||||||
|
// into the next one, or next statement.
|
||||||
|
var side_effects = [];
|
||||||
|
node.definitions.forEach(function(def) {
|
||||||
|
if (def.value) def.value = def.value.transform(tt);
|
||||||
|
var sym = def.name.definition();
|
||||||
|
if (!drop_vars || sym.id in in_use_ids) {
|
||||||
|
if (def.value && sym.id in fixed_ids && fixed_ids[sym.id] !== def) {
|
||||||
|
def.value = def.value.drop_side_effect_free(compressor);
|
||||||
|
}
|
||||||
|
if (def.name instanceof AST_SymbolVar) {
|
||||||
|
var var_defs = var_defs_by_id.get(sym.id);
|
||||||
|
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));
|
||||||
|
if (def.value) {
|
||||||
|
var ref = make_node(AST_SymbolRef, def.name, def.name);
|
||||||
|
sym.references.push(ref);
|
||||||
|
var assign = make_node(AST_Assign, def, {
|
||||||
|
operator: "=",
|
||||||
|
left: ref,
|
||||||
|
right: def.value
|
||||||
|
});
|
||||||
|
if (fixed_ids[sym.id] === def) {
|
||||||
|
fixed_ids[sym.id] = assign;
|
||||||
|
}
|
||||||
|
side_effects.push(assign.transform(tt));
|
||||||
|
}
|
||||||
|
remove(var_defs, def);
|
||||||
|
sym.eliminated++;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (def.value) {
|
||||||
|
if (side_effects.length > 0) {
|
||||||
|
if (tail.length > 0) {
|
||||||
|
side_effects.push(def.value);
|
||||||
|
def.value = make_sequence(def.value, side_effects);
|
||||||
|
} else {
|
||||||
|
body.push(make_node(AST_SimpleStatement, node, {
|
||||||
|
body: make_sequence(node, side_effects)
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
side_effects = [];
|
||||||
|
}
|
||||||
|
tail.push(def);
|
||||||
|
} else {
|
||||||
|
head.push(def);
|
||||||
|
}
|
||||||
|
} else if (sym.orig[0] instanceof AST_SymbolCatch) {
|
||||||
|
var value = def.value && def.value.drop_side_effect_free(compressor);
|
||||||
|
if (value) side_effects.push(value);
|
||||||
|
def.value = null;
|
||||||
|
head.push(def);
|
||||||
|
} else {
|
||||||
|
var value = def.value && def.value.drop_side_effect_free(compressor);
|
||||||
|
if (value) {
|
||||||
|
compressor.warn("Side effects in initialization of unused variable {name} [{file}:{line},{col}]", template(def.name));
|
||||||
|
side_effects.push(value);
|
||||||
|
} else {
|
||||||
|
compressor[def.name.unreferenced() ? "warn" : "info"]("Dropping unused variable {name} [{file}:{line},{col}]", template(def.name));
|
||||||
|
}
|
||||||
|
sym.eliminated++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (head.length > 0 || tail.length > 0) {
|
||||||
|
node.definitions = head.concat(tail);
|
||||||
|
body.push(node);
|
||||||
|
}
|
||||||
|
if (side_effects.length > 0) {
|
||||||
|
body.push(make_node(AST_SimpleStatement, node, {
|
||||||
|
body: make_sequence(node, side_effects)
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
switch (body.length) {
|
||||||
|
case 0:
|
||||||
|
return in_list ? MAP.skip : make_node(AST_EmptyStatement, node);
|
||||||
|
case 1:
|
||||||
|
return body[0];
|
||||||
|
default:
|
||||||
|
return in_list ? MAP.splice(body) : make_node(AST_BlockStatement, node, {
|
||||||
|
body: body
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// certain combination of unused name + side effect leads to:
|
||||||
|
// https://github.com/mishoo/UglifyJS2/issues/44
|
||||||
|
// https://github.com/mishoo/UglifyJS2/issues/1830
|
||||||
|
// https://github.com/mishoo/UglifyJS2/issues/1838
|
||||||
|
// that's an invalid AST.
|
||||||
|
// We fix it at this stage by moving the `var` outside the `for`.
|
||||||
|
if (node instanceof AST_For) {
|
||||||
|
descend(node, this);
|
||||||
|
var block;
|
||||||
|
if (node.init instanceof AST_BlockStatement) {
|
||||||
|
block = node.init;
|
||||||
|
node.init = block.body.pop();
|
||||||
|
block.body.push(node);
|
||||||
|
}
|
||||||
|
if (node.init instanceof AST_SimpleStatement) {
|
||||||
|
node.init = node.init.body;
|
||||||
|
} else if (is_empty(node.init)) {
|
||||||
|
node.init = null;
|
||||||
|
}
|
||||||
|
return !block ? node : in_list ? MAP.splice(block.body) : block;
|
||||||
|
}
|
||||||
|
if (node instanceof AST_LabeledStatement && node.body instanceof AST_For) {
|
||||||
|
descend(node, this);
|
||||||
|
if (node.body instanceof AST_BlockStatement) {
|
||||||
|
var block = node.body;
|
||||||
|
node.body = block.body.pop();
|
||||||
|
block.body.push(node);
|
||||||
|
return in_list ? MAP.splice(block.body) : block;
|
||||||
|
}
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
if (node instanceof AST_Scope) {
|
||||||
|
var save_scope = scope;
|
||||||
|
scope = node;
|
||||||
|
descend(node, this);
|
||||||
|
scope = save_scope;
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
function template(sym) {
|
||||||
|
return {
|
||||||
|
name : sym.name,
|
||||||
|
file : sym.start.file,
|
||||||
|
line : sym.start.line,
|
||||||
|
col : sym.start.col
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
self.transform(tt);
|
self.transform(tt);
|
||||||
|
|
||||||
function verify_safe_usage(def, read, modified) {
|
function verify_safe_usage(def, read, modified) {
|
||||||
@@ -5247,7 +5308,7 @@ merge(Compressor.prototype, {
|
|||||||
var is_strict_comparison = true;
|
var is_strict_comparison = true;
|
||||||
if ((self.left.is_string(compressor) && self.right.is_string(compressor)) ||
|
if ((self.left.is_string(compressor) && self.right.is_string(compressor)) ||
|
||||||
(self.left.is_number(compressor) && self.right.is_number(compressor)) ||
|
(self.left.is_number(compressor) && self.right.is_number(compressor)) ||
|
||||||
(self.left.is_boolean() && self.right.is_boolean()) ||
|
(self.left.is_boolean(compressor) && self.right.is_boolean(compressor)) ||
|
||||||
self.left.equivalent_to(self.right)) {
|
self.left.equivalent_to(self.right)) {
|
||||||
self.operator = self.operator.substr(0, 2);
|
self.operator = self.operator.substr(0, 2);
|
||||||
}
|
}
|
||||||
@@ -5328,7 +5389,7 @@ merge(Compressor.prototype, {
|
|||||||
]).optimize(compressor);
|
]).optimize(compressor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (compressor.option("comparisons") && self.is_boolean()) {
|
if (compressor.option("comparisons") && self.is_boolean(compressor)) {
|
||||||
if (!(compressor.parent() instanceof AST_Binary)
|
if (!(compressor.parent() instanceof AST_Binary)
|
||||||
|| compressor.parent() instanceof AST_Assign) {
|
|| compressor.parent() instanceof AST_Assign) {
|
||||||
var negated = make_node(AST_UnaryPrefix, self, {
|
var negated = make_node(AST_UnaryPrefix, self, {
|
||||||
@@ -6102,7 +6163,7 @@ merge(Compressor.prototype, {
|
|||||||
return self;
|
return self;
|
||||||
|
|
||||||
function booleanize(node) {
|
function booleanize(node) {
|
||||||
if (node.is_boolean()) return node;
|
if (node.is_boolean(compressor)) return node;
|
||||||
// !!expression
|
// !!expression
|
||||||
return make_node(AST_UnaryPrefix, node, {
|
return make_node(AST_UnaryPrefix, node, {
|
||||||
operator: "!",
|
operator: "!",
|
||||||
|
|||||||
@@ -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.4.2",
|
"version": "3.4.3",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.8.0"
|
"node": ">=0.8.0"
|
||||||
},
|
},
|
||||||
@@ -23,11 +23,11 @@
|
|||||||
"LICENSE"
|
"LICENSE"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"commander": "~2.15.0",
|
"commander": "~2.16.0",
|
||||||
"source-map": "~0.6.1"
|
"source-map": "~0.6.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"acorn": "~5.5.3",
|
"acorn": "~5.7.1",
|
||||||
"semver": "~5.5.0"
|
"semver": "~5.5.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ holes_and_undefined: {
|
|||||||
|
|
||||||
constant_join: {
|
constant_join: {
|
||||||
options = {
|
options = {
|
||||||
unsafe : true,
|
evaluate: true,
|
||||||
evaluate : true
|
unsafe: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
var a = [ "foo", "bar", "baz" ].join("");
|
var a = [ "foo", "bar", "baz" ].join("");
|
||||||
var a1 = [ "foo", "bar", "baz" ].join();
|
var a1 = [ "foo", "bar", "baz" ].join();
|
||||||
@@ -64,9 +64,9 @@ constant_join: {
|
|||||||
|
|
||||||
constant_join_2: {
|
constant_join_2: {
|
||||||
options = {
|
options = {
|
||||||
unsafe : true,
|
evaluate: true,
|
||||||
evaluate : true
|
unsafe: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
var a = [ "foo", "bar", boo(), "baz", "x", "y" ].join("");
|
var a = [ "foo", "bar", boo(), "baz", "x", "y" ].join("");
|
||||||
var b = [ "foo", "bar", boo(), "baz", "x", "y" ].join("-");
|
var b = [ "foo", "bar", boo(), "baz", "x", "y" ].join("-");
|
||||||
@@ -93,9 +93,9 @@ constant_join_2: {
|
|||||||
|
|
||||||
constant_join_3: {
|
constant_join_3: {
|
||||||
options = {
|
options = {
|
||||||
unsafe: true,
|
|
||||||
evaluate: true,
|
evaluate: true,
|
||||||
};
|
unsafe: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
var a = [ null ].join();
|
var a = [ null ].join();
|
||||||
var b = [ , ].join();
|
var b = [ , ].join();
|
||||||
@@ -133,7 +133,7 @@ for_loop: {
|
|||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
unsafe: true,
|
unsafe: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
function f0() {
|
function f0() {
|
||||||
var a = [1, 2, 3];
|
var a = [1, 2, 3];
|
||||||
|
|||||||
@@ -1,24 +1,24 @@
|
|||||||
asm_mixed: {
|
asm_mixed: {
|
||||||
options = {
|
options = {
|
||||||
sequences : true,
|
booleans: true,
|
||||||
properties : true,
|
comparisons: true,
|
||||||
dead_code : true,
|
conditionals: true,
|
||||||
drop_debugger : true,
|
dead_code: true,
|
||||||
conditionals : true,
|
drop_debugger: true,
|
||||||
comparisons : true,
|
evaluate: true,
|
||||||
evaluate : true,
|
hoist_funs: true,
|
||||||
booleans : true,
|
hoist_vars: true,
|
||||||
loops : true,
|
if_return: true,
|
||||||
unused : true,
|
join_vars: true,
|
||||||
hoist_funs : true,
|
keep_fargs: true,
|
||||||
keep_fargs : true,
|
keep_fnames: false,
|
||||||
keep_fnames : false,
|
loops: true,
|
||||||
hoist_vars : true,
|
negate_iife: true,
|
||||||
if_return : true,
|
properties: true,
|
||||||
join_vars : true,
|
sequences: true,
|
||||||
side_effects : true,
|
side_effects: true,
|
||||||
negate_iife : true
|
unused: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
// adapted from http://asmjs.org/spec/latest/
|
// adapted from http://asmjs.org/spec/latest/
|
||||||
function asm_GeometricMean(stdlib, foreign, buffer) {
|
function asm_GeometricMean(stdlib, foreign, buffer) {
|
||||||
|
|||||||
@@ -1,9 +1,22 @@
|
|||||||
collapse_vars_side_effects_1: {
|
collapse_vars_side_effects_1: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true,
|
booleans: true,
|
||||||
comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true,
|
collapse_vars: true,
|
||||||
keep_fargs:true, if_return:true, join_vars:true, side_effects:true,
|
comparisons: true,
|
||||||
reduce_funcs: true, reduce_vars:true
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
hoist_funs: true,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
loops: true,
|
||||||
|
properties: true,
|
||||||
|
reduce_funcs: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f1() {
|
function f1() {
|
||||||
@@ -76,9 +89,21 @@ collapse_vars_side_effects_1: {
|
|||||||
|
|
||||||
collapse_vars_side_effects_2: {
|
collapse_vars_side_effects_2: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true,
|
booleans: true,
|
||||||
comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true,
|
collapse_vars: true,
|
||||||
keep_fargs:true, if_return:true, join_vars:true, side_effects:true
|
comparisons: true,
|
||||||
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
hoist_funs: true,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
loops: true,
|
||||||
|
properties: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function fn(x) { return console.log(x), x; }
|
function fn(x) { return console.log(x), x; }
|
||||||
@@ -144,10 +169,24 @@ collapse_vars_side_effects_2: {
|
|||||||
|
|
||||||
collapse_vars_issue_721: {
|
collapse_vars_issue_721: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true,
|
booleans: true,
|
||||||
comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true,
|
collapse_vars: true,
|
||||||
keep_fargs:true, if_return:true, join_vars:true, side_effects:true,
|
comparisons: true,
|
||||||
reduce_funcs: true, reduce_vars:true, passes:2
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
hoist_funs: true,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
loops: true,
|
||||||
|
passes: 2,
|
||||||
|
properties: true,
|
||||||
|
reduce_funcs: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
define(["require", "exports", 'handlebars'], function(require, exports, hb) {
|
define(["require", "exports", 'handlebars'], function(require, exports, hb) {
|
||||||
@@ -211,10 +250,23 @@ collapse_vars_issue_721: {
|
|||||||
|
|
||||||
collapse_vars_properties: {
|
collapse_vars_properties: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true,
|
booleans: true,
|
||||||
comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true,
|
collapse_vars: true,
|
||||||
keep_fargs:true, if_return:true, join_vars:true, side_effects:true,
|
comparisons: true,
|
||||||
reduce_funcs: true, reduce_vars:true
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
hoist_funs: true,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
loops: true,
|
||||||
|
properties: true,
|
||||||
|
reduce_funcs: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f1(obj) {
|
function f1(obj) {
|
||||||
@@ -239,10 +291,23 @@ collapse_vars_properties: {
|
|||||||
|
|
||||||
collapse_vars_if: {
|
collapse_vars_if: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true,
|
booleans: true,
|
||||||
comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true,
|
collapse_vars: true,
|
||||||
keep_fargs:true, if_return:true, join_vars:true, side_effects:true,
|
comparisons: true,
|
||||||
reduce_funcs: true, reduce_vars:true
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
hoist_funs: true,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
loops: true,
|
||||||
|
properties: true,
|
||||||
|
reduce_funcs: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f1() {
|
function f1() {
|
||||||
@@ -290,10 +355,23 @@ collapse_vars_if: {
|
|||||||
|
|
||||||
collapse_vars_while: {
|
collapse_vars_while: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true,
|
booleans: true,
|
||||||
comparisons:true, evaluate:true, booleans:true, loops:false, unused:true, hoist_funs:true,
|
collapse_vars: true,
|
||||||
keep_fargs:true, if_return:true, join_vars:true, side_effects:true,
|
comparisons: true,
|
||||||
reduce_funcs: true, reduce_vars:true
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
hoist_funs: true,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
loops: false,
|
||||||
|
properties: true,
|
||||||
|
reduce_funcs: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f1(y) {
|
function f1(y) {
|
||||||
@@ -339,10 +417,21 @@ collapse_vars_while: {
|
|||||||
|
|
||||||
collapse_vars_do_while: {
|
collapse_vars_do_while: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true,
|
booleans: false,
|
||||||
comparisons:true, evaluate:true, booleans:false, loops:false, unused:"keep_assign",
|
collapse_vars: true,
|
||||||
hoist_funs:true, keep_fargs:true, if_return:true, join_vars:true,
|
comparisons: true,
|
||||||
side_effects:true
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
hoist_funs: true,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
loops: false,
|
||||||
|
properties: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: "keep_assign",
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f1(y) {
|
function f1(y) {
|
||||||
@@ -415,9 +504,21 @@ collapse_vars_do_while: {
|
|||||||
|
|
||||||
collapse_vars_do_while_drop_assign: {
|
collapse_vars_do_while_drop_assign: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true,
|
booleans: false,
|
||||||
comparisons:true, evaluate:true, booleans:false, loops:false, unused:true, hoist_funs:true,
|
collapse_vars: true,
|
||||||
keep_fargs:true, if_return:true, join_vars:true, side_effects:true
|
comparisons: true,
|
||||||
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
hoist_funs: true,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
loops: false,
|
||||||
|
properties: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f1(y) {
|
function f1(y) {
|
||||||
@@ -490,9 +591,21 @@ collapse_vars_do_while_drop_assign: {
|
|||||||
|
|
||||||
collapse_vars_seq: {
|
collapse_vars_seq: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true,
|
booleans: true,
|
||||||
comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true,
|
collapse_vars: true,
|
||||||
keep_fargs:true, if_return:true, join_vars:true, side_effects:true
|
comparisons: true,
|
||||||
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
hoist_funs: true,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
loops: true,
|
||||||
|
properties: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
var f1 = function(x, y) {
|
var f1 = function(x, y) {
|
||||||
@@ -514,9 +627,21 @@ collapse_vars_seq: {
|
|||||||
|
|
||||||
collapse_vars_throw: {
|
collapse_vars_throw: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true,
|
booleans: true,
|
||||||
comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true,
|
collapse_vars: true,
|
||||||
keep_fargs:true, if_return:true, join_vars:true, side_effects:true
|
comparisons: true,
|
||||||
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
hoist_funs: true,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
loops: true,
|
||||||
|
properties: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
var f1 = function(x, y) {
|
var f1 = function(x, y) {
|
||||||
@@ -546,9 +671,21 @@ collapse_vars_throw: {
|
|||||||
|
|
||||||
collapse_vars_switch: {
|
collapse_vars_switch: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true,
|
booleans: true,
|
||||||
comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true,
|
collapse_vars: true,
|
||||||
keep_fargs:true, if_return:true, join_vars:true, side_effects:true
|
comparisons: true,
|
||||||
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
hoist_funs: true,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
loops: true,
|
||||||
|
properties: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f1() {
|
function f1() {
|
||||||
@@ -586,9 +723,20 @@ collapse_vars_switch: {
|
|||||||
|
|
||||||
collapse_vars_assignment: {
|
collapse_vars_assignment: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars:true, sequences:true, properties:true, conditionals:true,
|
booleans: true,
|
||||||
comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true,
|
collapse_vars: true,
|
||||||
keep_fargs:true, if_return:true, join_vars:true, side_effects:true
|
comparisons: true,
|
||||||
|
conditionals: true,
|
||||||
|
evaluate: true,
|
||||||
|
hoist_funs: true,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
loops: true,
|
||||||
|
properties: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function log(x) { return console.log(x), x; }
|
function log(x) { return console.log(x), x; }
|
||||||
@@ -659,10 +807,20 @@ collapse_vars_assignment: {
|
|||||||
|
|
||||||
collapse_vars_lvalues: {
|
collapse_vars_lvalues: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars:true, sequences:true, properties:true, conditionals:true,
|
booleans: true,
|
||||||
comparisons:true, evaluate:true, booleans:true, loops:true, unused:"keep_assign",
|
collapse_vars: true,
|
||||||
hoist_funs:true, keep_fargs:true, if_return:true, join_vars:true,
|
comparisons: true,
|
||||||
side_effects:true
|
conditionals: true,
|
||||||
|
evaluate: true,
|
||||||
|
hoist_funs: true,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
loops: true,
|
||||||
|
properties: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: "keep_assign",
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f0(x) { var i = ++x; return x += i; }
|
function f0(x) { var i = ++x; return x += i; }
|
||||||
@@ -692,9 +850,21 @@ collapse_vars_lvalues: {
|
|||||||
|
|
||||||
collapse_vars_lvalues_drop_assign: {
|
collapse_vars_lvalues_drop_assign: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars:true, sequences:true, properties:true, conditionals:true,
|
booleans: true,
|
||||||
comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true,
|
collapse_vars: true,
|
||||||
keep_fargs:true, if_return:true, join_vars:true, side_effects:true, passes:3
|
comparisons: true,
|
||||||
|
conditionals: true,
|
||||||
|
evaluate: true,
|
||||||
|
hoist_funs: true,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
loops: true,
|
||||||
|
passes: 3,
|
||||||
|
properties: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f0(x) { var i = ++x; return x += i; }
|
function f0(x) { var i = ++x; return x += i; }
|
||||||
@@ -724,10 +894,22 @@ collapse_vars_lvalues_drop_assign: {
|
|||||||
|
|
||||||
collapse_vars_misc1: {
|
collapse_vars_misc1: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars:true, sequences:true, properties:true, conditionals:true,
|
booleans: true,
|
||||||
comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true,
|
collapse_vars: true,
|
||||||
keep_fargs:true, if_return:true, join_vars:true, side_effects:true,
|
comparisons: true,
|
||||||
reduce_funcs: true, reduce_vars:true
|
conditionals: true,
|
||||||
|
evaluate: true,
|
||||||
|
hoist_funs: true,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
loops: true,
|
||||||
|
properties: true,
|
||||||
|
reduce_funcs: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f0(o, a, h) {
|
function f0(o, a, h) {
|
||||||
@@ -771,10 +953,21 @@ collapse_vars_misc1: {
|
|||||||
|
|
||||||
collapse_vars_self_reference: {
|
collapse_vars_self_reference: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars:true, unused:false,
|
booleans: true,
|
||||||
sequences:true, properties:true, dead_code:true, conditionals:true,
|
collapse_vars: true,
|
||||||
comparisons:true, evaluate:true, booleans:true, loops:true, hoist_funs:true,
|
comparisons: true,
|
||||||
keep_fargs:true, if_return:true, join_vars:true, side_effects:true
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
hoist_funs: true,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
loops: true,
|
||||||
|
properties: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: false,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
// avoid bug in self-referential declaration.
|
// avoid bug in self-referential declaration.
|
||||||
@@ -802,10 +995,23 @@ collapse_vars_self_reference: {
|
|||||||
|
|
||||||
collapse_vars_repeated: {
|
collapse_vars_repeated: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true,
|
booleans: true,
|
||||||
comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true,
|
collapse_vars: true,
|
||||||
keep_fargs:true, if_return:true, join_vars:true, side_effects:true,
|
comparisons: true,
|
||||||
reduce_funcs: true, reduce_vars:true
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
hoist_funs: true,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
loops: true,
|
||||||
|
properties: true,
|
||||||
|
reduce_funcs: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f1() {
|
function f1() {
|
||||||
@@ -845,10 +1051,23 @@ collapse_vars_repeated: {
|
|||||||
|
|
||||||
collapse_vars_closures: {
|
collapse_vars_closures: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true,
|
booleans: true,
|
||||||
comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true,
|
collapse_vars: true,
|
||||||
keep_fargs:true, if_return:true, join_vars:true, side_effects:true,
|
comparisons: true,
|
||||||
reduce_funcs: true, reduce_vars:true
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
hoist_funs: true,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
loops: true,
|
||||||
|
properties: true,
|
||||||
|
reduce_funcs: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function constant_vars_can_be_replaced_in_any_scope() {
|
function constant_vars_can_be_replaced_in_any_scope() {
|
||||||
@@ -873,9 +1092,21 @@ collapse_vars_closures: {
|
|||||||
|
|
||||||
collapse_vars_unary: {
|
collapse_vars_unary: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true,
|
booleans: true,
|
||||||
comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true,
|
collapse_vars: true,
|
||||||
keep_fargs:true, if_return:true, join_vars:true, side_effects:true
|
comparisons: true,
|
||||||
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
hoist_funs: true,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
loops: true,
|
||||||
|
properties: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f0(o, p) {
|
function f0(o, p) {
|
||||||
@@ -936,10 +1167,23 @@ collapse_vars_unary: {
|
|||||||
|
|
||||||
collapse_vars_try: {
|
collapse_vars_try: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true,
|
booleans: true,
|
||||||
comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true,
|
collapse_vars: true,
|
||||||
keep_fargs:true, if_return:true, join_vars:true, side_effects:true,
|
comparisons: true,
|
||||||
reduce_funcs: true, reduce_vars:true
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
hoist_funs: true,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
loops: true,
|
||||||
|
properties: true,
|
||||||
|
reduce_funcs: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f1() {
|
function f1() {
|
||||||
@@ -992,9 +1236,21 @@ collapse_vars_try: {
|
|||||||
|
|
||||||
collapse_vars_array: {
|
collapse_vars_array: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true,
|
booleans: true,
|
||||||
comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true,
|
collapse_vars: true,
|
||||||
keep_fargs:true, if_return:true, join_vars:true, side_effects:true
|
comparisons: true,
|
||||||
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
hoist_funs: true,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
loops: true,
|
||||||
|
properties: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f1(x, y) {
|
function f1(x, y) {
|
||||||
@@ -1026,9 +1282,21 @@ collapse_vars_array: {
|
|||||||
|
|
||||||
collapse_vars_object: {
|
collapse_vars_object: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true,
|
booleans: true,
|
||||||
comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true,
|
collapse_vars: true,
|
||||||
keep_fargs:true, if_return:true, join_vars:true, side_effects:true
|
comparisons: true,
|
||||||
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
hoist_funs: true,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
loops: true,
|
||||||
|
properties: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f0(x, y) {
|
function f0(x, y) {
|
||||||
@@ -1094,9 +1362,21 @@ collapse_vars_object: {
|
|||||||
|
|
||||||
collapse_vars_eval_and_with: {
|
collapse_vars_eval_and_with: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars:true, sequences:false, properties:true, dead_code:true, conditionals:true,
|
booleans: true,
|
||||||
comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true,
|
collapse_vars: true,
|
||||||
keep_fargs:true, if_return:true, join_vars:true, side_effects:true
|
comparisons: true,
|
||||||
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
hoist_funs: true,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
loops: true,
|
||||||
|
properties: true,
|
||||||
|
sequences: false,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
// Don't attempt to collapse vars in presence of eval() or with statement.
|
// Don't attempt to collapse vars in presence of eval() or with statement.
|
||||||
@@ -1134,10 +1414,23 @@ collapse_vars_eval_and_with: {
|
|||||||
|
|
||||||
collapse_vars_constants: {
|
collapse_vars_constants: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true,
|
booleans: true,
|
||||||
comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true,
|
collapse_vars: true,
|
||||||
keep_fargs:true, if_return:true, join_vars:true, side_effects:true,
|
comparisons: true,
|
||||||
reduce_funcs: true, reduce_vars:true
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
hoist_funs: true,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
loops: true,
|
||||||
|
properties: true,
|
||||||
|
reduce_funcs: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f1(x) {
|
function f1(x) {
|
||||||
@@ -1172,10 +1465,24 @@ collapse_vars_constants: {
|
|||||||
|
|
||||||
collapse_vars_arguments: {
|
collapse_vars_arguments: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true,
|
booleans: true,
|
||||||
comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true,
|
collapse_vars: true,
|
||||||
keep_fargs:true, if_return:true, join_vars:true, side_effects:true,
|
comparisons: true,
|
||||||
toplevel:true, reduce_funcs: true, reduce_vars:true
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
hoist_funs: true,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
loops: true,
|
||||||
|
properties: true,
|
||||||
|
reduce_funcs: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
var outer = function() {
|
var outer = function() {
|
||||||
@@ -1195,9 +1502,21 @@ collapse_vars_arguments: {
|
|||||||
|
|
||||||
collapse_vars_short_circuit: {
|
collapse_vars_short_circuit: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true,
|
booleans: true,
|
||||||
comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true,
|
collapse_vars: true,
|
||||||
keep_fargs:true, if_return:true, join_vars:true, side_effects:true
|
comparisons: true,
|
||||||
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
hoist_funs: true,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
loops: true,
|
||||||
|
properties: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f0(x) { var a = foo(), b = bar(); return b || x; }
|
function f0(x) { var a = foo(), b = bar(); return b || x; }
|
||||||
@@ -1237,20 +1556,20 @@ collapse_vars_short_circuit: {
|
|||||||
|
|
||||||
collapse_vars_short_circuited_conditions: {
|
collapse_vars_short_circuited_conditions: {
|
||||||
options = {
|
options = {
|
||||||
|
booleans: true,
|
||||||
collapse_vars: true,
|
collapse_vars: true,
|
||||||
sequences: false,
|
comparisons: false,
|
||||||
dead_code: true,
|
conditionals: false,
|
||||||
conditionals: false,
|
dead_code: true,
|
||||||
comparisons: false,
|
evaluate: true,
|
||||||
evaluate: true,
|
hoist_funs: true,
|
||||||
booleans: true,
|
if_return: false,
|
||||||
loops: true,
|
join_vars: true,
|
||||||
unused: true,
|
keep_fargs: true,
|
||||||
hoist_funs: true,
|
loops: true,
|
||||||
keep_fargs: true,
|
sequences: false,
|
||||||
if_return: false,
|
side_effects: true,
|
||||||
join_vars: true,
|
unused: true,
|
||||||
side_effects: true,
|
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function c1(x) { var a = foo(), b = bar(), c = baz(); return a ? b : c; }
|
function c1(x) { var a = foo(), b = bar(), c = baz(); return a ? b : c; }
|
||||||
@@ -1286,21 +1605,21 @@ collapse_vars_short_circuited_conditions: {
|
|||||||
|
|
||||||
collapse_vars_regexp: {
|
collapse_vars_regexp: {
|
||||||
options = {
|
options = {
|
||||||
booleans: true,
|
booleans: true,
|
||||||
collapse_vars: true,
|
collapse_vars: true,
|
||||||
comparisons: true,
|
comparisons: true,
|
||||||
conditionals: true,
|
conditionals: true,
|
||||||
dead_code: true,
|
dead_code: true,
|
||||||
evaluate: true,
|
evaluate: true,
|
||||||
if_return: true,
|
hoist_funs: true,
|
||||||
join_vars: true,
|
if_return: true,
|
||||||
hoist_funs: true,
|
join_vars: true,
|
||||||
keep_fargs: true,
|
keep_fargs: true,
|
||||||
loops: false,
|
loops: false,
|
||||||
reduce_funcs: true,
|
reduce_funcs: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
side_effects: true,
|
side_effects: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f1() {
|
function f1() {
|
||||||
@@ -1692,9 +2011,21 @@ iife_2: {
|
|||||||
|
|
||||||
var_defs: {
|
var_defs: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true,
|
booleans: true,
|
||||||
comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true,
|
collapse_vars: true,
|
||||||
keep_fargs:true, if_return:true, join_vars:true, side_effects:true
|
comparisons: true,
|
||||||
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
hoist_funs: true,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
loops: true,
|
||||||
|
properties: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
var f1 = function(x, y) {
|
var f1 = function(x, y) {
|
||||||
@@ -2825,8 +3156,8 @@ issue_2364_5: {
|
|||||||
options = {
|
options = {
|
||||||
collapse_vars: true,
|
collapse_vars: true,
|
||||||
evaluate: true,
|
evaluate: true,
|
||||||
pure_getters: true,
|
|
||||||
properties: true,
|
properties: true,
|
||||||
|
pure_getters: true,
|
||||||
reduce_funcs: true,
|
reduce_funcs: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
@@ -3133,8 +3464,8 @@ issue_2437_1: {
|
|||||||
passes: 2,
|
passes: 2,
|
||||||
reduce_funcs: true,
|
reduce_funcs: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
side_effects: true,
|
|
||||||
sequences: true,
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
toplevel: true,
|
toplevel: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
@@ -3183,8 +3514,8 @@ issue_2437_2: {
|
|||||||
passes: 2,
|
passes: 2,
|
||||||
reduce_funcs: true,
|
reduce_funcs: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
side_effects: true,
|
|
||||||
sequences: true,
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
toplevel: true,
|
toplevel: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
@@ -3417,8 +3748,8 @@ issue_2436_6: {
|
|||||||
pure_getters: "strict",
|
pure_getters: "strict",
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
toplevel: true,
|
toplevel: true,
|
||||||
unused: true,
|
|
||||||
unsafe: true,
|
unsafe: true,
|
||||||
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
var o = {
|
var o = {
|
||||||
|
|||||||
@@ -295,3 +295,31 @@ issue_2857_6: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "true"
|
expect_stdout: "true"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
is_boolean_unsafe: {
|
||||||
|
options = {
|
||||||
|
comparisons: true,
|
||||||
|
unsafe: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(/foo/.test("bar") === [].isPrototypeOf({}));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(/foo/.test("bar") == [].isPrototypeOf({}));
|
||||||
|
}
|
||||||
|
expect_stdout: "true"
|
||||||
|
}
|
||||||
|
|
||||||
|
is_number_unsafe: {
|
||||||
|
options = {
|
||||||
|
comparisons: true,
|
||||||
|
unsafe: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(Math.acos(42) !== "foo".charCodeAt(4));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(Math.acos(42) != "foo".charCodeAt(4));
|
||||||
|
}
|
||||||
|
expect_stdout: "true"
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
concat_1: {
|
concat_1: {
|
||||||
options = {
|
options = {
|
||||||
evaluate: true
|
evaluate: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
var a = "foo" + "bar" + x() + "moo" + "foo" + y() + "x" + "y" + "z" + q();
|
var a = "foo" + "bar" + x() + "moo" + "foo" + y() + "x" + "y" + "z" + q();
|
||||||
var b = "foo" + 1 + x() + 2 + "boo";
|
var b = "foo" + 1 + x() + 2 + "boo";
|
||||||
@@ -26,7 +26,7 @@ concat_1: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
concat_2: {
|
concat_2: {
|
||||||
options = {};
|
options = {}
|
||||||
input: {
|
input: {
|
||||||
console.log(
|
console.log(
|
||||||
1 + (2 + 3),
|
1 + (2 + 3),
|
||||||
@@ -55,7 +55,7 @@ concat_2: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
concat_3: {
|
concat_3: {
|
||||||
options = {};
|
options = {}
|
||||||
input: {
|
input: {
|
||||||
console.log(
|
console.log(
|
||||||
1 + 2 + (3 + 4 + 5),
|
1 + 2 + (3 + 4 + 5),
|
||||||
@@ -84,7 +84,7 @@ concat_3: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
concat_4: {
|
concat_4: {
|
||||||
options = {};
|
options = {}
|
||||||
input: {
|
input: {
|
||||||
console.log(
|
console.log(
|
||||||
1 + "2" + (3 + 4 + 5),
|
1 + "2" + (3 + 4 + 5),
|
||||||
@@ -113,7 +113,7 @@ concat_4: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
concat_5: {
|
concat_5: {
|
||||||
options = {};
|
options = {}
|
||||||
input: {
|
input: {
|
||||||
console.log(
|
console.log(
|
||||||
"1" + 2 + (3 + 4 + 5),
|
"1" + 2 + (3 + 4 + 5),
|
||||||
@@ -142,7 +142,7 @@ concat_5: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
concat_6: {
|
concat_6: {
|
||||||
options = {};
|
options = {}
|
||||||
input: {
|
input: {
|
||||||
console.log(
|
console.log(
|
||||||
"1" + "2" + (3 + 4 + 5),
|
"1" + "2" + (3 + 4 + 5),
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
ifs_1: {
|
ifs_1: {
|
||||||
options = {
|
options = {
|
||||||
conditionals: true
|
conditionals: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
if (foo) bar();
|
if (foo) bar();
|
||||||
if (!foo); else bar();
|
if (!foo); else bar();
|
||||||
@@ -18,8 +18,8 @@ ifs_1: {
|
|||||||
|
|
||||||
ifs_2: {
|
ifs_2: {
|
||||||
options = {
|
options = {
|
||||||
conditionals: true
|
conditionals: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
if (foo) {
|
if (foo) {
|
||||||
x();
|
x();
|
||||||
@@ -47,12 +47,12 @@ ifs_2: {
|
|||||||
|
|
||||||
ifs_3_should_warn: {
|
ifs_3_should_warn: {
|
||||||
options = {
|
options = {
|
||||||
conditionals : true,
|
booleans: true,
|
||||||
dead_code : true,
|
conditionals: true,
|
||||||
evaluate : true,
|
dead_code: true,
|
||||||
booleans : true,
|
evaluate: true,
|
||||||
side_effects : true,
|
side_effects: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
var x, y;
|
var x, y;
|
||||||
if (x && !(x + "1") && y) { // 1
|
if (x && !(x + "1") && y) { // 1
|
||||||
@@ -78,8 +78,8 @@ ifs_3_should_warn: {
|
|||||||
|
|
||||||
ifs_4: {
|
ifs_4: {
|
||||||
options = {
|
options = {
|
||||||
conditionals: true
|
conditionals: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
if (foo && bar) {
|
if (foo && bar) {
|
||||||
x(foo)[10].bar.baz = something();
|
x(foo)[10].bar.baz = something();
|
||||||
@@ -95,10 +95,10 @@ ifs_4: {
|
|||||||
|
|
||||||
ifs_5: {
|
ifs_5: {
|
||||||
options = {
|
options = {
|
||||||
if_return: true,
|
|
||||||
conditionals: true,
|
|
||||||
comparisons: true,
|
comparisons: true,
|
||||||
};
|
conditionals: true,
|
||||||
|
if_return: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
function f() {
|
function f() {
|
||||||
if (foo) return;
|
if (foo) return;
|
||||||
@@ -132,9 +132,9 @@ ifs_5: {
|
|||||||
|
|
||||||
ifs_6: {
|
ifs_6: {
|
||||||
options = {
|
options = {
|
||||||
|
comparisons: true,
|
||||||
conditionals: true,
|
conditionals: true,
|
||||||
comparisons: true
|
}
|
||||||
};
|
|
||||||
input: {
|
input: {
|
||||||
var x, y;
|
var x, y;
|
||||||
if (!foo && !bar && !baz && !boo) {
|
if (!foo && !bar && !baz && !boo) {
|
||||||
@@ -163,8 +163,8 @@ ifs_6: {
|
|||||||
|
|
||||||
cond_1: {
|
cond_1: {
|
||||||
options = {
|
options = {
|
||||||
conditionals: true
|
conditionals: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
function foo(do_something, some_condition) {
|
function foo(do_something, some_condition) {
|
||||||
if (some_condition) {
|
if (some_condition) {
|
||||||
@@ -189,8 +189,8 @@ cond_1: {
|
|||||||
|
|
||||||
cond_2: {
|
cond_2: {
|
||||||
options = {
|
options = {
|
||||||
conditionals: true
|
conditionals: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
function foo(x, FooBar, some_condition) {
|
function foo(x, FooBar, some_condition) {
|
||||||
if (some_condition) {
|
if (some_condition) {
|
||||||
@@ -209,8 +209,8 @@ cond_2: {
|
|||||||
|
|
||||||
cond_3: {
|
cond_3: {
|
||||||
options = {
|
options = {
|
||||||
conditionals: true
|
conditionals: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
var FooBar;
|
var FooBar;
|
||||||
if (some_condition()) {
|
if (some_condition()) {
|
||||||
@@ -227,8 +227,8 @@ cond_3: {
|
|||||||
|
|
||||||
cond_4: {
|
cond_4: {
|
||||||
options = {
|
options = {
|
||||||
conditionals: true
|
conditionals: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
var do_something;
|
var do_something;
|
||||||
if (some_condition()) {
|
if (some_condition()) {
|
||||||
@@ -251,8 +251,8 @@ cond_4: {
|
|||||||
|
|
||||||
cond_5: {
|
cond_5: {
|
||||||
options = {
|
options = {
|
||||||
conditionals: true
|
conditionals: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
if (some_condition()) {
|
if (some_condition()) {
|
||||||
if (some_other_condition()) {
|
if (some_other_condition()) {
|
||||||
@@ -279,9 +279,9 @@ cond_5: {
|
|||||||
cond_7: {
|
cond_7: {
|
||||||
options = {
|
options = {
|
||||||
conditionals: true,
|
conditionals: true,
|
||||||
evaluate : true,
|
evaluate: true,
|
||||||
side_effects: true,
|
side_effects: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
var x, y, z, a, b;
|
var x, y, z, a, b;
|
||||||
// compress these
|
// compress these
|
||||||
@@ -342,8 +342,8 @@ cond_7: {
|
|||||||
cond_7_1: {
|
cond_7_1: {
|
||||||
options = {
|
options = {
|
||||||
conditionals: true,
|
conditionals: true,
|
||||||
evaluate : true
|
evaluate: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
var x;
|
var x;
|
||||||
// access to global should be assumed to have side effects
|
// access to global should be assumed to have side effects
|
||||||
@@ -361,10 +361,10 @@ cond_7_1: {
|
|||||||
|
|
||||||
cond_8: {
|
cond_8: {
|
||||||
options = {
|
options = {
|
||||||
|
booleans: false,
|
||||||
conditionals: true,
|
conditionals: true,
|
||||||
evaluate : true,
|
evaluate: true,
|
||||||
booleans : false
|
}
|
||||||
};
|
|
||||||
input: {
|
input: {
|
||||||
var a;
|
var a;
|
||||||
// compress these
|
// compress these
|
||||||
@@ -445,10 +445,10 @@ cond_8: {
|
|||||||
|
|
||||||
cond_8b: {
|
cond_8b: {
|
||||||
options = {
|
options = {
|
||||||
|
booleans: true,
|
||||||
conditionals: true,
|
conditionals: true,
|
||||||
evaluate : true,
|
evaluate: true,
|
||||||
booleans : true
|
}
|
||||||
};
|
|
||||||
input: {
|
input: {
|
||||||
var a;
|
var a;
|
||||||
// compress these
|
// compress these
|
||||||
@@ -528,10 +528,10 @@ cond_8b: {
|
|||||||
|
|
||||||
cond_8c: {
|
cond_8c: {
|
||||||
options = {
|
options = {
|
||||||
|
booleans: false,
|
||||||
conditionals: true,
|
conditionals: true,
|
||||||
evaluate : false,
|
evaluate: false,
|
||||||
booleans : false
|
}
|
||||||
};
|
|
||||||
input: {
|
input: {
|
||||||
var a;
|
var a;
|
||||||
// compress these
|
// compress these
|
||||||
@@ -647,9 +647,21 @@ cond_9: {
|
|||||||
|
|
||||||
ternary_boolean_consequent: {
|
ternary_boolean_consequent: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true,
|
booleans: true,
|
||||||
comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true,
|
collapse_vars: true,
|
||||||
keep_fargs:true, if_return:true, join_vars:true, side_effects:true
|
comparisons: true,
|
||||||
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
hoist_funs: true,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
loops: true,
|
||||||
|
properties: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f1() { return a == b ? true : x; }
|
function f1() { return a == b ? true : x; }
|
||||||
@@ -675,9 +687,21 @@ ternary_boolean_consequent: {
|
|||||||
|
|
||||||
ternary_boolean_alternative: {
|
ternary_boolean_alternative: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars:true, sequences:true, properties:true, dead_code:true, conditionals:true,
|
booleans: true,
|
||||||
comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true,
|
collapse_vars: true,
|
||||||
keep_fargs:true, if_return:true, join_vars:true, side_effects:true
|
comparisons: true,
|
||||||
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
hoist_funs: true,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
loops: true,
|
||||||
|
properties: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f1() { return a == b ? x : true; }
|
function f1() { return a == b ? x : true; }
|
||||||
@@ -778,11 +802,11 @@ trivial_boolean_ternary_expressions : {
|
|||||||
|
|
||||||
issue_1154: {
|
issue_1154: {
|
||||||
options = {
|
options = {
|
||||||
|
booleans: true,
|
||||||
conditionals: true,
|
conditionals: true,
|
||||||
evaluate : true,
|
evaluate: true,
|
||||||
booleans : true,
|
|
||||||
side_effects: true,
|
side_effects: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
function f1(x) { return x ? -1 : -1; }
|
function f1(x) { return x ? -1 : -1; }
|
||||||
function f2(x) { return x ? +2 : +2; }
|
function f2(x) { return x ? +2 : +2; }
|
||||||
@@ -818,7 +842,7 @@ issue_1154: {
|
|||||||
no_evaluate: {
|
no_evaluate: {
|
||||||
options = {
|
options = {
|
||||||
conditionals: true,
|
conditionals: true,
|
||||||
evaluate : false,
|
evaluate: false,
|
||||||
side_effects: true,
|
side_effects: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
dead_code_1: {
|
dead_code_1: {
|
||||||
options = {
|
options = {
|
||||||
dead_code: true
|
dead_code: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
function f() {
|
function f() {
|
||||||
a();
|
a();
|
||||||
@@ -25,8 +25,8 @@ dead_code_1: {
|
|||||||
|
|
||||||
dead_code_2_should_warn: {
|
dead_code_2_should_warn: {
|
||||||
options = {
|
options = {
|
||||||
dead_code: true
|
dead_code: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
function f() {
|
function f() {
|
||||||
g();
|
g();
|
||||||
@@ -64,13 +64,13 @@ dead_code_2_should_warn: {
|
|||||||
|
|
||||||
dead_code_constant_boolean_should_warn_more: {
|
dead_code_constant_boolean_should_warn_more: {
|
||||||
options = {
|
options = {
|
||||||
dead_code : true,
|
booleans: true,
|
||||||
loops : true,
|
conditionals: true,
|
||||||
booleans : true,
|
dead_code: true,
|
||||||
conditionals : true,
|
evaluate: true,
|
||||||
evaluate : true,
|
loops: true,
|
||||||
side_effects : true,
|
side_effects: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
while (!((foo && bar) || (x + "0"))) {
|
while (!((foo && bar) || (x + "0"))) {
|
||||||
console.log("unreachable");
|
console.log("unreachable");
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
keep_debugger: {
|
keep_debugger: {
|
||||||
options = {
|
options = {
|
||||||
drop_debugger: false
|
drop_debugger: false,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
debugger;
|
debugger;
|
||||||
}
|
}
|
||||||
@@ -12,8 +12,8 @@ keep_debugger: {
|
|||||||
|
|
||||||
drop_debugger: {
|
drop_debugger: {
|
||||||
options = {
|
options = {
|
||||||
drop_debugger: true
|
drop_debugger: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
debugger;
|
debugger;
|
||||||
if (foo) debugger;
|
if (foo) debugger;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
drop_console_1: {
|
drop_console_1: {
|
||||||
options = {};
|
options = {}
|
||||||
input: {
|
input: {
|
||||||
console.log('foo');
|
console.log('foo');
|
||||||
console.log.apply(console, arguments);
|
console.log.apply(console, arguments);
|
||||||
@@ -11,7 +11,9 @@ drop_console_1: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
drop_console_2: {
|
drop_console_2: {
|
||||||
options = { drop_console: true };
|
options = {
|
||||||
|
drop_console: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
console.log('foo');
|
console.log('foo');
|
||||||
console.log.apply(console, arguments);
|
console.log.apply(console, arguments);
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
unused_funarg_1: {
|
unused_funarg_1: {
|
||||||
options = { unused: true, keep_fargs: false };
|
options = {
|
||||||
|
keep_fargs: false,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
function f(a, b, c, d, e) {
|
function f(a, b, c, d, e) {
|
||||||
return a + b;
|
return a + b;
|
||||||
@@ -13,7 +16,10 @@ unused_funarg_1: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unused_funarg_2: {
|
unused_funarg_2: {
|
||||||
options = { unused: true, keep_fargs: false };
|
options = {
|
||||||
|
keep_fargs: false,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
function f(a, b, c, d, e) {
|
function f(a, b, c, d, e) {
|
||||||
return a + c;
|
return a + c;
|
||||||
@@ -27,7 +33,9 @@ unused_funarg_2: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unused_nested_function: {
|
unused_nested_function: {
|
||||||
options = { unused: true };
|
options = {
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
function f(x, y) {
|
function f(x, y) {
|
||||||
function g() {
|
function g() {
|
||||||
@@ -44,7 +52,9 @@ unused_nested_function: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unused_circular_references_1: {
|
unused_circular_references_1: {
|
||||||
options = { unused: true };
|
options = {
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
function f(x, y) {
|
function f(x, y) {
|
||||||
// circular reference
|
// circular reference
|
||||||
@@ -65,7 +75,9 @@ unused_circular_references_1: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unused_circular_references_2: {
|
unused_circular_references_2: {
|
||||||
options = { unused: true };
|
options = {
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
function f(x, y) {
|
function f(x, y) {
|
||||||
var foo = 1, bar = baz, baz = foo + bar, qwe = moo();
|
var foo = 1, bar = baz, baz = foo + bar, qwe = moo();
|
||||||
@@ -81,7 +93,9 @@ unused_circular_references_2: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unused_circular_references_3: {
|
unused_circular_references_3: {
|
||||||
options = { unused: true };
|
options = {
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
function f(x, y) {
|
function f(x, y) {
|
||||||
var g = function() { return h() };
|
var g = function() { return h() };
|
||||||
@@ -97,7 +111,9 @@ unused_circular_references_3: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unused_keep_setter_arg: {
|
unused_keep_setter_arg: {
|
||||||
options = { unused: true };
|
options = {
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
var x = {
|
var x = {
|
||||||
_foo: null,
|
_foo: null,
|
||||||
@@ -121,7 +137,9 @@ unused_keep_setter_arg: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unused_var_in_catch: {
|
unused_var_in_catch: {
|
||||||
options = { unused: true };
|
options = {
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
function foo() {
|
function foo() {
|
||||||
try {
|
try {
|
||||||
@@ -141,7 +159,9 @@ unused_var_in_catch: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
used_var_in_catch: {
|
used_var_in_catch: {
|
||||||
options = { unused: true };
|
options = {
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
function foo() {
|
function foo() {
|
||||||
try {
|
try {
|
||||||
@@ -165,7 +185,11 @@ used_var_in_catch: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
keep_fnames: {
|
keep_fnames: {
|
||||||
options = { unused: true, keep_fnames: true, unsafe: true };
|
options = {
|
||||||
|
keep_fnames: true,
|
||||||
|
unsafe: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
function foo() {
|
function foo() {
|
||||||
return function bar(baz) {};
|
return function bar(baz) {};
|
||||||
@@ -367,7 +391,7 @@ drop_toplevel_vars_fargs: {
|
|||||||
drop_toplevel_all: {
|
drop_toplevel_all: {
|
||||||
options = {
|
options = {
|
||||||
toplevel: true,
|
toplevel: true,
|
||||||
unused: true
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
var a, b = 1, c = g;
|
var a, b = 1, c = g;
|
||||||
@@ -418,7 +442,11 @@ drop_toplevel_retain: {
|
|||||||
|
|
||||||
drop_toplevel_retain_array: {
|
drop_toplevel_retain_array: {
|
||||||
options = {
|
options = {
|
||||||
top_retain: [ "f", "a", "o" ],
|
top_retain: [
|
||||||
|
"f",
|
||||||
|
"a",
|
||||||
|
"o"
|
||||||
|
],
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
@@ -476,8 +504,8 @@ drop_toplevel_retain_regex: {
|
|||||||
|
|
||||||
drop_toplevel_all_retain: {
|
drop_toplevel_all_retain: {
|
||||||
options = {
|
options = {
|
||||||
toplevel: true,
|
|
||||||
top_retain: "f,a,o",
|
top_retain: "f,a,o",
|
||||||
|
toplevel: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
@@ -506,8 +534,8 @@ drop_toplevel_all_retain: {
|
|||||||
|
|
||||||
drop_toplevel_funcs_retain: {
|
drop_toplevel_funcs_retain: {
|
||||||
options = {
|
options = {
|
||||||
toplevel: "funcs",
|
|
||||||
top_retain: "f,a,o",
|
top_retain: "f,a,o",
|
||||||
|
toplevel: "funcs",
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
@@ -537,8 +565,8 @@ drop_toplevel_funcs_retain: {
|
|||||||
|
|
||||||
drop_toplevel_vars_retain: {
|
drop_toplevel_vars_retain: {
|
||||||
options = {
|
options = {
|
||||||
toplevel: "vars",
|
|
||||||
top_retain: "f,a,o",
|
top_retain: "f,a,o",
|
||||||
|
toplevel: "vars",
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
@@ -1377,9 +1405,9 @@ issue_2516_1: {
|
|||||||
issue_2516_2: {
|
issue_2516_2: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars: true,
|
collapse_vars: true,
|
||||||
|
passes: 2,
|
||||||
reduce_funcs: true,
|
reduce_funcs: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
passes: 2,
|
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
|
|||||||
@@ -186,7 +186,9 @@ unary_prefix: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
negative_zero: {
|
negative_zero: {
|
||||||
options = { evaluate: true }
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
console.log(
|
console.log(
|
||||||
-"",
|
-"",
|
||||||
@@ -207,7 +209,9 @@ negative_zero: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
positive_zero: {
|
positive_zero: {
|
||||||
options = { evaluate: true }
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
console.log(
|
console.log(
|
||||||
+"",
|
+"",
|
||||||
@@ -229,8 +233,8 @@ positive_zero: {
|
|||||||
|
|
||||||
unsafe_constant: {
|
unsafe_constant: {
|
||||||
options = {
|
options = {
|
||||||
evaluate : true,
|
evaluate: true,
|
||||||
unsafe : true
|
unsafe: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
console.log(
|
console.log(
|
||||||
@@ -421,8 +425,8 @@ prop_function: {
|
|||||||
|
|
||||||
unsafe_integer_key: {
|
unsafe_integer_key: {
|
||||||
options = {
|
options = {
|
||||||
evaluate : true,
|
evaluate: true,
|
||||||
unsafe : true
|
unsafe: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
console.log(
|
console.log(
|
||||||
@@ -449,8 +453,8 @@ unsafe_integer_key: {
|
|||||||
|
|
||||||
unsafe_integer_key_complex: {
|
unsafe_integer_key_complex: {
|
||||||
options = {
|
options = {
|
||||||
evaluate : true,
|
evaluate: true,
|
||||||
unsafe : true
|
unsafe: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
console.log(
|
console.log(
|
||||||
@@ -477,8 +481,8 @@ unsafe_integer_key_complex: {
|
|||||||
|
|
||||||
unsafe_float_key: {
|
unsafe_float_key: {
|
||||||
options = {
|
options = {
|
||||||
evaluate : true,
|
evaluate: true,
|
||||||
unsafe : true
|
unsafe: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
console.log(
|
console.log(
|
||||||
@@ -505,8 +509,8 @@ unsafe_float_key: {
|
|||||||
|
|
||||||
unsafe_float_key_complex: {
|
unsafe_float_key_complex: {
|
||||||
options = {
|
options = {
|
||||||
evaluate : true,
|
evaluate: true,
|
||||||
unsafe : true
|
unsafe: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
console.log(
|
console.log(
|
||||||
@@ -533,8 +537,8 @@ unsafe_float_key_complex: {
|
|||||||
|
|
||||||
unsafe_array: {
|
unsafe_array: {
|
||||||
options = {
|
options = {
|
||||||
evaluate : true,
|
evaluate: true,
|
||||||
unsafe : true
|
unsafe: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
console.log(
|
console.log(
|
||||||
@@ -569,8 +573,8 @@ unsafe_array: {
|
|||||||
|
|
||||||
unsafe_string: {
|
unsafe_string: {
|
||||||
options = {
|
options = {
|
||||||
evaluate : true,
|
evaluate: true,
|
||||||
unsafe : true
|
unsafe: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
console.log(
|
console.log(
|
||||||
@@ -597,8 +601,8 @@ unsafe_string: {
|
|||||||
|
|
||||||
unsafe_array_bad_index: {
|
unsafe_array_bad_index: {
|
||||||
options = {
|
options = {
|
||||||
evaluate : true,
|
evaluate: true,
|
||||||
unsafe : true
|
unsafe: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
console.log(
|
console.log(
|
||||||
@@ -619,8 +623,8 @@ unsafe_array_bad_index: {
|
|||||||
|
|
||||||
unsafe_string_bad_index: {
|
unsafe_string_bad_index: {
|
||||||
options = {
|
options = {
|
||||||
evaluate : true,
|
evaluate: true,
|
||||||
unsafe : true
|
unsafe: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
console.log(
|
console.log(
|
||||||
@@ -754,8 +758,8 @@ in_boolean_context: {
|
|||||||
|
|
||||||
unsafe_charAt: {
|
unsafe_charAt: {
|
||||||
options = {
|
options = {
|
||||||
evaluate : true,
|
evaluate: true,
|
||||||
unsafe : true
|
unsafe: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
console.log(
|
console.log(
|
||||||
@@ -782,8 +786,8 @@ unsafe_charAt: {
|
|||||||
|
|
||||||
unsafe_charAt_bad_index: {
|
unsafe_charAt_bad_index: {
|
||||||
options = {
|
options = {
|
||||||
evaluate : true,
|
evaluate: true,
|
||||||
unsafe : true
|
unsafe: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
console.log(
|
console.log(
|
||||||
@@ -804,8 +808,8 @@ unsafe_charAt_bad_index: {
|
|||||||
|
|
||||||
unsafe_charAt_noop: {
|
unsafe_charAt_noop: {
|
||||||
options = {
|
options = {
|
||||||
evaluate : true,
|
evaluate: true,
|
||||||
unsafe : true
|
unsafe: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
console.log(
|
console.log(
|
||||||
@@ -1195,7 +1199,7 @@ issue_2231_1: {
|
|||||||
}
|
}
|
||||||
expect_stdout: true
|
expect_stdout: true
|
||||||
expect_warnings: [
|
expect_warnings: [
|
||||||
"WARN: Error evaluating Object.keys(void 0) [test/compress/evaluate.js:1191,20]",
|
"WARN: Error evaluating Object.keys(void 0) [test/compress/evaluate.js:1195,20]",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1212,7 +1216,7 @@ issue_2231_2: {
|
|||||||
}
|
}
|
||||||
expect_stdout: true
|
expect_stdout: true
|
||||||
expect_warnings: [
|
expect_warnings: [
|
||||||
"WARN: Error evaluating Object.getOwnPropertyNames(null) [test/compress/evaluate.js:1208,20]",
|
"WARN: Error evaluating Object.getOwnPropertyNames(null) [test/compress/evaluate.js:1212,20]",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1350,14 +1354,14 @@ issue_2535_3: {
|
|||||||
}
|
}
|
||||||
expect_stdout: true
|
expect_stdout: true
|
||||||
expect_warnings: [
|
expect_warnings: [
|
||||||
"WARN: Dropping side-effect-free && [test/compress/evaluate.js:1336,20]",
|
"WARN: Dropping side-effect-free && [test/compress/evaluate.js:1340,20]",
|
||||||
"WARN: Dropping side-effect-free && [test/compress/evaluate.js:1337,20]",
|
"WARN: Dropping side-effect-free && [test/compress/evaluate.js:1341,20]",
|
||||||
"WARN: Dropping side-effect-free && [test/compress/evaluate.js:1338,20]",
|
"WARN: Dropping side-effect-free && [test/compress/evaluate.js:1342,20]",
|
||||||
"WARN: Condition left of && always false [test/compress/evaluate.js:1338,20]",
|
"WARN: Condition left of && always false [test/compress/evaluate.js:1342,20]",
|
||||||
"WARN: Dropping side-effect-free || [test/compress/evaluate.js:1339,20]",
|
"WARN: Dropping side-effect-free || [test/compress/evaluate.js:1343,20]",
|
||||||
"WARN: Dropping side-effect-free || [test/compress/evaluate.js:1340,20]",
|
"WARN: Dropping side-effect-free || [test/compress/evaluate.js:1344,20]",
|
||||||
"WARN: Dropping side-effect-free || [test/compress/evaluate.js:1341,20]",
|
"WARN: Dropping side-effect-free || [test/compress/evaluate.js:1345,20]",
|
||||||
"WARN: Condition left of || always true [test/compress/evaluate.js:1341,20]",
|
"WARN: Condition left of || always true [test/compress/evaluate.js:1345,20]",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,20 +9,20 @@ non_ascii_function_identifier_name: {
|
|||||||
|
|
||||||
iifes_returning_constants_keep_fargs_true: {
|
iifes_returning_constants_keep_fargs_true: {
|
||||||
options = {
|
options = {
|
||||||
keep_fargs : true,
|
booleans: true,
|
||||||
side_effects : true,
|
collapse_vars: true,
|
||||||
evaluate : true,
|
comparisons: true,
|
||||||
unused : true,
|
conditionals: true,
|
||||||
dead_code : true,
|
dead_code: true,
|
||||||
conditionals : true,
|
evaluate: true,
|
||||||
comparisons : true,
|
if_return: true,
|
||||||
booleans : true,
|
inline: true,
|
||||||
if_return : true,
|
join_vars: true,
|
||||||
join_vars : true,
|
keep_fargs: true,
|
||||||
reduce_funcs : true,
|
reduce_funcs: true,
|
||||||
reduce_vars : true,
|
reduce_vars: true,
|
||||||
collapse_vars : true,
|
side_effects: true,
|
||||||
inline : true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
(function(){ return -1.23; }());
|
(function(){ return -1.23; }());
|
||||||
@@ -46,20 +46,20 @@ iifes_returning_constants_keep_fargs_true: {
|
|||||||
|
|
||||||
iifes_returning_constants_keep_fargs_false: {
|
iifes_returning_constants_keep_fargs_false: {
|
||||||
options = {
|
options = {
|
||||||
keep_fargs : false,
|
booleans: true,
|
||||||
side_effects : true,
|
collapse_vars: true,
|
||||||
evaluate : true,
|
comparisons: true,
|
||||||
unused : true,
|
conditionals: true,
|
||||||
dead_code : true,
|
dead_code: true,
|
||||||
conditionals : true,
|
evaluate: true,
|
||||||
comparisons : true,
|
if_return: true,
|
||||||
booleans : true,
|
inline: true,
|
||||||
if_return : true,
|
join_vars: true,
|
||||||
join_vars : true,
|
keep_fargs: false,
|
||||||
reduce_funcs : true,
|
reduce_funcs: true,
|
||||||
reduce_vars : true,
|
reduce_vars: true,
|
||||||
collapse_vars : true,
|
side_effects: true,
|
||||||
inline : true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
(function(){ return -1.23; }());
|
(function(){ return -1.23; }());
|
||||||
@@ -1175,8 +1175,8 @@ issue_2620_3: {
|
|||||||
issue_2620_4: {
|
issue_2620_4: {
|
||||||
rename = true,
|
rename = true,
|
||||||
options = {
|
options = {
|
||||||
evaluate: true,
|
|
||||||
dead_code: true,
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
inline: true,
|
inline: true,
|
||||||
passes: 2,
|
passes: 2,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
@@ -2025,6 +2025,7 @@ deduplicate_parenthesis: {
|
|||||||
|
|
||||||
drop_lone_use_strict: {
|
drop_lone_use_strict: {
|
||||||
options = {
|
options = {
|
||||||
|
directives: true,
|
||||||
side_effects: true,
|
side_effects: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
@@ -2052,6 +2053,27 @@ drop_lone_use_strict: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_3166: {
|
||||||
|
options = {
|
||||||
|
directives: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"foo";
|
||||||
|
"use strict";
|
||||||
|
function f() {
|
||||||
|
"use strict";
|
||||||
|
"bar";
|
||||||
|
"use asm";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
function f() {
|
||||||
|
"use asm";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
issue_3016_1: {
|
issue_3016_1: {
|
||||||
options = {
|
options = {
|
||||||
inline: true,
|
inline: true,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ must_replace: {
|
|||||||
options = {
|
options = {
|
||||||
global_defs: {
|
global_defs: {
|
||||||
D: "foo bar",
|
D: "foo bar",
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
console.log(D);
|
console.log(D);
|
||||||
@@ -141,9 +141,9 @@ mixed: {
|
|||||||
console.log(CONFIG);
|
console.log(CONFIG);
|
||||||
}
|
}
|
||||||
expect_warnings: [
|
expect_warnings: [
|
||||||
'WARN: global_defs CONFIG.VALUE redefined [test/compress/global_defs.js:127,22]',
|
"WARN: global_defs CONFIG.VALUE redefined [test/compress/global_defs.js:127,22]",
|
||||||
'WARN: global_defs CONFIG.VALUE redefined [test/compress/global_defs.js:128,22]',
|
"WARN: global_defs CONFIG.VALUE redefined [test/compress/global_defs.js:128,22]",
|
||||||
'WARN: global_defs CONFIG.VALUE redefined [test/compress/global_defs.js:130,8]',
|
"WARN: global_defs CONFIG.VALUE redefined [test/compress/global_defs.js:130,8]",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
issue_2377_1: {
|
issue_2377_1: {
|
||||||
options = {
|
options = {
|
||||||
evaluate: true,
|
evaluate: true,
|
||||||
inline: true,
|
|
||||||
hoist_props: true,
|
hoist_props: true,
|
||||||
|
inline: true,
|
||||||
reduce_funcs: true,
|
reduce_funcs: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
toplevel: true,
|
toplevel: true,
|
||||||
@@ -33,8 +33,8 @@ issue_2377_1: {
|
|||||||
issue_2377_2: {
|
issue_2377_2: {
|
||||||
options = {
|
options = {
|
||||||
evaluate: true,
|
evaluate: true,
|
||||||
inline: true,
|
|
||||||
hoist_props: true,
|
hoist_props: true,
|
||||||
|
inline: true,
|
||||||
passes: 2,
|
passes: 2,
|
||||||
reduce_funcs: true,
|
reduce_funcs: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
@@ -64,8 +64,8 @@ issue_2377_2: {
|
|||||||
issue_2377_3: {
|
issue_2377_3: {
|
||||||
options = {
|
options = {
|
||||||
evaluate: true,
|
evaluate: true,
|
||||||
inline: true,
|
|
||||||
hoist_props: true,
|
hoist_props: true,
|
||||||
|
inline: true,
|
||||||
passes: 4,
|
passes: 4,
|
||||||
reduce_funcs: true,
|
reduce_funcs: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
@@ -416,7 +416,10 @@ issue_2473_1: {
|
|||||||
options = {
|
options = {
|
||||||
hoist_props: false,
|
hoist_props: false,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
top_retain: [ "x", "y" ],
|
top_retain: [
|
||||||
|
"x",
|
||||||
|
"y"
|
||||||
|
],
|
||||||
toplevel: true,
|
toplevel: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
@@ -435,7 +438,10 @@ issue_2473_2: {
|
|||||||
options = {
|
options = {
|
||||||
hoist_props: true,
|
hoist_props: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
top_retain: [ "x", "y" ],
|
top_retain: [
|
||||||
|
"x",
|
||||||
|
"y"
|
||||||
|
],
|
||||||
toplevel: true,
|
toplevel: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
@@ -746,9 +752,9 @@ issue_3046: {
|
|||||||
issue_3071_1: {
|
issue_3071_1: {
|
||||||
options = {
|
options = {
|
||||||
evaluate: true,
|
evaluate: true,
|
||||||
|
hoist_props: true,
|
||||||
inline: true,
|
inline: true,
|
||||||
join_vars: true,
|
join_vars: true,
|
||||||
hoist_props: true,
|
|
||||||
passes: 3,
|
passes: 3,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
sequences: true,
|
sequences: true,
|
||||||
@@ -773,9 +779,9 @@ issue_3071_1: {
|
|||||||
issue_3071_2: {
|
issue_3071_2: {
|
||||||
options = {
|
options = {
|
||||||
evaluate: true,
|
evaluate: true,
|
||||||
|
hoist_props: true,
|
||||||
inline: true,
|
inline: true,
|
||||||
join_vars: true,
|
join_vars: true,
|
||||||
hoist_props: true,
|
|
||||||
passes: 3,
|
passes: 3,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
sequences: true,
|
sequences: true,
|
||||||
@@ -800,9 +806,9 @@ issue_3071_2: {
|
|||||||
issue_3071_2_toplevel: {
|
issue_3071_2_toplevel: {
|
||||||
options = {
|
options = {
|
||||||
evaluate: true,
|
evaluate: true,
|
||||||
|
hoist_props: true,
|
||||||
inline: true,
|
inline: true,
|
||||||
join_vars: true,
|
join_vars: true,
|
||||||
hoist_props: true,
|
|
||||||
passes: 3,
|
passes: 3,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
sequences: true,
|
sequences: true,
|
||||||
|
|||||||
@@ -187,9 +187,9 @@ dont_screw_try_catch_undefined: {
|
|||||||
reduce_vars: {
|
reduce_vars: {
|
||||||
options = {
|
options = {
|
||||||
evaluate: true,
|
evaluate: true,
|
||||||
|
ie8: true,
|
||||||
reduce_funcs: true,
|
reduce_funcs: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
ie8: true,
|
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
mangle = {
|
mangle = {
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
if_return_1: {
|
if_return_1: {
|
||||||
options = {
|
options = {
|
||||||
if_return : true,
|
booleans: true,
|
||||||
sequences : true,
|
comparisons: true,
|
||||||
conditionals : true,
|
conditionals: true,
|
||||||
comparisons : true,
|
dead_code: true,
|
||||||
evaluate : true,
|
evaluate: true,
|
||||||
booleans : true,
|
if_return: true,
|
||||||
unused : true,
|
sequences: true,
|
||||||
side_effects : true,
|
side_effects: true,
|
||||||
dead_code : true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f(x) {
|
function f(x) {
|
||||||
@@ -24,15 +24,15 @@ if_return_1: {
|
|||||||
|
|
||||||
if_return_2: {
|
if_return_2: {
|
||||||
options = {
|
options = {
|
||||||
if_return : true,
|
booleans: true,
|
||||||
sequences : true,
|
comparisons: true,
|
||||||
conditionals : true,
|
conditionals: true,
|
||||||
comparisons : true,
|
dead_code: true,
|
||||||
evaluate : true,
|
evaluate: true,
|
||||||
booleans : true,
|
if_return: true,
|
||||||
unused : true,
|
sequences: true,
|
||||||
side_effects : true,
|
side_effects: true,
|
||||||
dead_code : true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f(x, y) {
|
function f(x, y) {
|
||||||
@@ -49,15 +49,15 @@ if_return_2: {
|
|||||||
|
|
||||||
if_return_3: {
|
if_return_3: {
|
||||||
options = {
|
options = {
|
||||||
if_return : true,
|
booleans: true,
|
||||||
sequences : true,
|
comparisons: true,
|
||||||
conditionals : true,
|
conditionals: true,
|
||||||
comparisons : true,
|
dead_code: true,
|
||||||
evaluate : true,
|
evaluate: true,
|
||||||
booleans : true,
|
if_return: true,
|
||||||
unused : true,
|
sequences: true,
|
||||||
side_effects : true,
|
side_effects: true,
|
||||||
dead_code : true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f(x) {
|
function f(x) {
|
||||||
@@ -75,15 +75,15 @@ if_return_3: {
|
|||||||
|
|
||||||
if_return_4: {
|
if_return_4: {
|
||||||
options = {
|
options = {
|
||||||
if_return : true,
|
booleans: true,
|
||||||
sequences : true,
|
comparisons: true,
|
||||||
conditionals : true,
|
conditionals: true,
|
||||||
comparisons : true,
|
dead_code: true,
|
||||||
evaluate : true,
|
evaluate: true,
|
||||||
booleans : true,
|
if_return: true,
|
||||||
unused : true,
|
sequences: true,
|
||||||
side_effects : true,
|
side_effects: true,
|
||||||
dead_code : true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f(x, y) {
|
function f(x, y) {
|
||||||
@@ -100,15 +100,15 @@ if_return_4: {
|
|||||||
|
|
||||||
if_return_5: {
|
if_return_5: {
|
||||||
options = {
|
options = {
|
||||||
if_return : true,
|
booleans: true,
|
||||||
sequences : true,
|
comparisons: true,
|
||||||
conditionals : true,
|
conditionals: true,
|
||||||
comparisons : true,
|
dead_code: true,
|
||||||
evaluate : true,
|
evaluate: true,
|
||||||
booleans : true,
|
if_return: true,
|
||||||
unused : true,
|
sequences: true,
|
||||||
side_effects : true,
|
side_effects: true,
|
||||||
dead_code : true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f() {
|
function f() {
|
||||||
@@ -126,15 +126,15 @@ if_return_5: {
|
|||||||
|
|
||||||
if_return_6: {
|
if_return_6: {
|
||||||
options = {
|
options = {
|
||||||
if_return : true,
|
booleans: true,
|
||||||
sequences : true,
|
comparisons: true,
|
||||||
conditionals : true,
|
conditionals: true,
|
||||||
comparisons : true,
|
dead_code: true,
|
||||||
evaluate : true,
|
evaluate: true,
|
||||||
booleans : true,
|
if_return: true,
|
||||||
unused : true,
|
sequences: true,
|
||||||
side_effects : true,
|
side_effects: true,
|
||||||
dead_code : true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f(x) {
|
function f(x) {
|
||||||
@@ -150,15 +150,15 @@ if_return_6: {
|
|||||||
|
|
||||||
if_return_7: {
|
if_return_7: {
|
||||||
options = {
|
options = {
|
||||||
if_return : true,
|
booleans: true,
|
||||||
sequences : true,
|
comparisons: true,
|
||||||
conditionals : true,
|
conditionals: true,
|
||||||
comparisons : true,
|
dead_code: true,
|
||||||
evaluate : true,
|
evaluate: true,
|
||||||
booleans : true,
|
if_return: true,
|
||||||
unused : true,
|
sequences: true,
|
||||||
side_effects : true,
|
side_effects: true,
|
||||||
dead_code : true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f(x) {
|
function f(x) {
|
||||||
@@ -176,10 +176,10 @@ if_return_7: {
|
|||||||
|
|
||||||
if_return_8: {
|
if_return_8: {
|
||||||
options = {
|
options = {
|
||||||
if_return: true,
|
conditionals: true,
|
||||||
sequences: true,
|
if_return: true,
|
||||||
conditionals: true,
|
sequences: true,
|
||||||
side_effects : true,
|
side_effects: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f(e) {
|
function f(e) {
|
||||||
@@ -220,15 +220,15 @@ if_return_8: {
|
|||||||
|
|
||||||
issue_1089: {
|
issue_1089: {
|
||||||
options = {
|
options = {
|
||||||
if_return : true,
|
booleans: true,
|
||||||
sequences : true,
|
comparisons: true,
|
||||||
conditionals : true,
|
conditionals: true,
|
||||||
comparisons : true,
|
dead_code: true,
|
||||||
evaluate : true,
|
evaluate: true,
|
||||||
booleans : true,
|
if_return: true,
|
||||||
unused : true,
|
sequences: true,
|
||||||
side_effects : true,
|
side_effects: true,
|
||||||
dead_code : true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function x() {
|
function x() {
|
||||||
@@ -251,9 +251,9 @@ issue_1089: {
|
|||||||
|
|
||||||
issue_1437: {
|
issue_1437: {
|
||||||
options = {
|
options = {
|
||||||
if_return : true,
|
conditionals: false,
|
||||||
sequences : true,
|
if_return: true,
|
||||||
conditionals : false
|
sequences: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function x() {
|
function x() {
|
||||||
@@ -281,9 +281,9 @@ issue_1437: {
|
|||||||
|
|
||||||
issue_1437_conditionals: {
|
issue_1437_conditionals: {
|
||||||
options = {
|
options = {
|
||||||
conditionals : true,
|
conditionals: true,
|
||||||
if_return : true,
|
if_return: true,
|
||||||
sequences : true
|
sequences: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function x() {
|
function x() {
|
||||||
|
|||||||
@@ -1,8 +1,17 @@
|
|||||||
non_hoisted_function_after_return: {
|
non_hoisted_function_after_return: {
|
||||||
options = {
|
options = {
|
||||||
hoist_funs: false, dead_code: true, conditionals: true, comparisons: true,
|
booleans: true,
|
||||||
evaluate: true, booleans: true, loops: true, unused: true, keep_fargs: true,
|
comparisons: true,
|
||||||
if_return: true, join_vars: true, side_effects: true
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
hoist_funs: false,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
loops: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function foo(x) {
|
function foo(x) {
|
||||||
@@ -27,19 +36,30 @@ non_hoisted_function_after_return: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
expect_warnings: [
|
expect_warnings: [
|
||||||
'WARN: Dropping unreachable code [test/compress/issue-1034.js:11,16]',
|
"WARN: Dropping unreachable code [test/compress/issue-1034.js:20,16]",
|
||||||
"WARN: Dropping unreachable code [test/compress/issue-1034.js:14,16]",
|
"WARN: Dropping unreachable code [test/compress/issue-1034.js:23,16]",
|
||||||
"WARN: Dropping unreachable code [test/compress/issue-1034.js:17,12]",
|
"WARN: Dropping unreachable code [test/compress/issue-1034.js:26,12]",
|
||||||
"WARN: Dropping unused function UnusedFunction [test/compress/issue-1034.js:18,21]"
|
"WARN: Dropping unused function UnusedFunction [test/compress/issue-1034.js:27,21]"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
non_hoisted_function_after_return_2a: {
|
non_hoisted_function_after_return_2a: {
|
||||||
options = {
|
options = {
|
||||||
hoist_funs: false, dead_code: true, conditionals: true, comparisons: true,
|
booleans: true,
|
||||||
evaluate: true, booleans: true, loops: true, unused: true, keep_fargs: true,
|
collapse_vars: false,
|
||||||
if_return: true, join_vars: true, side_effects: true,
|
comparisons: true,
|
||||||
collapse_vars: false, passes: 2, warnings: "verbose"
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
hoist_funs: false,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
loops: true,
|
||||||
|
passes: 2,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
|
warnings: "verbose",
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function foo(x) {
|
function foo(x) {
|
||||||
@@ -65,28 +85,37 @@ non_hoisted_function_after_return_2a: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
expect_warnings: [
|
expect_warnings: [
|
||||||
"WARN: Dropping unreachable code [test/compress/issue-1034.js:48,16]",
|
"WARN: Dropping unreachable code [test/compress/issue-1034.js:68,16]",
|
||||||
"WARN: Declarations in unreachable code! [test/compress/issue-1034.js:48,16]",
|
"WARN: Declarations in unreachable code! [test/compress/issue-1034.js:68,16]",
|
||||||
"WARN: Dropping unreachable code [test/compress/issue-1034.js:51,16]",
|
"WARN: Dropping unreachable code [test/compress/issue-1034.js:71,16]",
|
||||||
"WARN: Declarations in unreachable code! [test/compress/issue-1034.js:51,16]",
|
"WARN: Declarations in unreachable code! [test/compress/issue-1034.js:71,16]",
|
||||||
"WARN: Dropping unused variable a [test/compress/issue-1034.js:48,20]",
|
"WARN: Dropping unused variable a [test/compress/issue-1034.js:68,20]",
|
||||||
"WARN: Dropping unused function nope [test/compress/issue-1034.js:55,21]",
|
"WARN: Dropping unused function nope [test/compress/issue-1034.js:75,21]",
|
||||||
"WARN: pass 0: last_count: Infinity, count: 37",
|
"WARN: pass 0: last_count: Infinity, count: 37",
|
||||||
"WARN: Dropping unreachable code [test/compress/issue-1034.js:53,12]",
|
"WARN: Dropping unreachable code [test/compress/issue-1034.js:73,12]",
|
||||||
"WARN: Declarations in unreachable code! [test/compress/issue-1034.js:53,12]",
|
"WARN: Declarations in unreachable code! [test/compress/issue-1034.js:73,12]",
|
||||||
"WARN: Dropping unreachable code [test/compress/issue-1034.js:56,12]",
|
"WARN: Dropping unreachable code [test/compress/issue-1034.js:76,12]",
|
||||||
"WARN: Dropping unused variable b [test/compress/issue-1034.js:51,20]",
|
"WARN: Dropping unused variable b [test/compress/issue-1034.js:71,20]",
|
||||||
"WARN: Dropping unused variable c [test/compress/issue-1034.js:53,16]",
|
"WARN: Dropping unused variable c [test/compress/issue-1034.js:73,16]",
|
||||||
"WARN: pass 1: last_count: 37, count: 18",
|
"WARN: pass 1: last_count: 37, count: 18",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
non_hoisted_function_after_return_2b: {
|
non_hoisted_function_after_return_2b: {
|
||||||
options = {
|
options = {
|
||||||
hoist_funs: false, dead_code: true, conditionals: true, comparisons: true,
|
booleans: true,
|
||||||
evaluate: true, booleans: true, loops: true, unused: true, keep_fargs: true,
|
collapse_vars: false,
|
||||||
if_return: true, join_vars: true, side_effects: true,
|
comparisons: true,
|
||||||
collapse_vars: false
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
hoist_funs: false,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
loops: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function foo(x) {
|
function foo(x) {
|
||||||
@@ -111,19 +140,28 @@ non_hoisted_function_after_return_2b: {
|
|||||||
}
|
}
|
||||||
expect_warnings: [
|
expect_warnings: [
|
||||||
// duplicate warnings no longer emitted
|
// duplicate warnings no longer emitted
|
||||||
"WARN: Dropping unreachable code [test/compress/issue-1034.js:97,16]",
|
"WARN: Dropping unreachable code [test/compress/issue-1034.js:126,16]",
|
||||||
"WARN: Declarations in unreachable code! [test/compress/issue-1034.js:97,16]",
|
"WARN: Declarations in unreachable code! [test/compress/issue-1034.js:126,16]",
|
||||||
"WARN: Dropping unreachable code [test/compress/issue-1034.js:99,12]",
|
"WARN: Dropping unreachable code [test/compress/issue-1034.js:128,12]",
|
||||||
"WARN: Declarations in unreachable code! [test/compress/issue-1034.js:99,12]",
|
"WARN: Declarations in unreachable code! [test/compress/issue-1034.js:128,12]",
|
||||||
"WARN: Dropping unreachable code [test/compress/issue-1034.js:103,12]",
|
"WARN: Dropping unreachable code [test/compress/issue-1034.js:132,12]",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
non_hoisted_function_after_return_strict: {
|
non_hoisted_function_after_return_strict: {
|
||||||
options = {
|
options = {
|
||||||
hoist_funs: false, dead_code: true, conditionals: true, comparisons: true,
|
booleans: true,
|
||||||
evaluate: true, booleans: true, loops: true, unused: true, keep_fargs: true,
|
comparisons: true,
|
||||||
if_return: true, join_vars: true, side_effects: true
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
hoist_funs: false,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
loops: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
"use strict";
|
"use strict";
|
||||||
@@ -153,19 +191,30 @@ non_hoisted_function_after_return_strict: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "8 7"
|
expect_stdout: "8 7"
|
||||||
expect_warnings: [
|
expect_warnings: [
|
||||||
"WARN: Dropping unreachable code [test/compress/issue-1034.js:133,16]",
|
"WARN: Dropping unreachable code [test/compress/issue-1034.js:171,16]",
|
||||||
"WARN: Dropping unreachable code [test/compress/issue-1034.js:136,16]",
|
"WARN: Dropping unreachable code [test/compress/issue-1034.js:174,16]",
|
||||||
"WARN: Dropping unreachable code [test/compress/issue-1034.js:139,12]",
|
"WARN: Dropping unreachable code [test/compress/issue-1034.js:177,12]",
|
||||||
"WARN: Dropping unused function UnusedFunction [test/compress/issue-1034.js:140,21]",
|
"WARN: Dropping unused function UnusedFunction [test/compress/issue-1034.js:178,21]",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
non_hoisted_function_after_return_2a_strict: {
|
non_hoisted_function_after_return_2a_strict: {
|
||||||
options = {
|
options = {
|
||||||
hoist_funs: false, dead_code: true, conditionals: true, comparisons: true,
|
booleans: true,
|
||||||
evaluate: true, booleans: true, loops: true, unused: true, keep_fargs: true,
|
collapse_vars: false,
|
||||||
if_return: true, join_vars: true, side_effects: true,
|
comparisons: true,
|
||||||
collapse_vars: false, passes: 2, warnings: "verbose"
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
hoist_funs: false,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
loops: true,
|
||||||
|
passes: 2,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
|
warnings: "verbose",
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
"use strict";
|
"use strict";
|
||||||
@@ -196,28 +245,37 @@ non_hoisted_function_after_return_2a_strict: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "5 6"
|
expect_stdout: "5 6"
|
||||||
expect_warnings: [
|
expect_warnings: [
|
||||||
"WARN: Dropping unreachable code [test/compress/issue-1034.js:175,16]",
|
"WARN: Dropping unreachable code [test/compress/issue-1034.js:224,16]",
|
||||||
"WARN: Declarations in unreachable code! [test/compress/issue-1034.js:175,16]",
|
"WARN: Declarations in unreachable code! [test/compress/issue-1034.js:224,16]",
|
||||||
"WARN: Dropping unreachable code [test/compress/issue-1034.js:178,16]",
|
"WARN: Dropping unreachable code [test/compress/issue-1034.js:227,16]",
|
||||||
"WARN: Declarations in unreachable code! [test/compress/issue-1034.js:178,16]",
|
"WARN: Declarations in unreachable code! [test/compress/issue-1034.js:227,16]",
|
||||||
"WARN: Dropping unused variable a [test/compress/issue-1034.js:175,20]",
|
"WARN: Dropping unused variable a [test/compress/issue-1034.js:224,20]",
|
||||||
"WARN: Dropping unused function nope [test/compress/issue-1034.js:182,21]",
|
"WARN: Dropping unused function nope [test/compress/issue-1034.js:231,21]",
|
||||||
"WARN: pass 0: last_count: Infinity, count: 48",
|
"WARN: pass 0: last_count: Infinity, count: 48",
|
||||||
"WARN: Dropping unreachable code [test/compress/issue-1034.js:180,12]",
|
"WARN: Dropping unreachable code [test/compress/issue-1034.js:229,12]",
|
||||||
"WARN: Declarations in unreachable code! [test/compress/issue-1034.js:180,12]",
|
"WARN: Declarations in unreachable code! [test/compress/issue-1034.js:229,12]",
|
||||||
"WARN: Dropping unreachable code [test/compress/issue-1034.js:183,12]",
|
"WARN: Dropping unreachable code [test/compress/issue-1034.js:232,12]",
|
||||||
"WARN: Dropping unused variable b [test/compress/issue-1034.js:178,20]",
|
"WARN: Dropping unused variable b [test/compress/issue-1034.js:227,20]",
|
||||||
"WARN: Dropping unused variable c [test/compress/issue-1034.js:180,16]",
|
"WARN: Dropping unused variable c [test/compress/issue-1034.js:229,16]",
|
||||||
"WARN: pass 1: last_count: 48, count: 29",
|
"WARN: pass 1: last_count: 48, count: 29",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
non_hoisted_function_after_return_2b_strict: {
|
non_hoisted_function_after_return_2b_strict: {
|
||||||
options = {
|
options = {
|
||||||
hoist_funs: false, dead_code: true, conditionals: true, comparisons: true,
|
booleans: true,
|
||||||
evaluate: true, booleans: true, loops: true, unused: true, keep_fargs: true,
|
collapse_vars: false,
|
||||||
if_return: true, join_vars: true, side_effects: true,
|
comparisons: true,
|
||||||
collapse_vars: false
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
hoist_funs: false,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
loops: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
"use strict";
|
"use strict";
|
||||||
@@ -247,10 +305,10 @@ non_hoisted_function_after_return_2b_strict: {
|
|||||||
expect_stdout: "5 6"
|
expect_stdout: "5 6"
|
||||||
expect_warnings: [
|
expect_warnings: [
|
||||||
// duplicate warnings no longer emitted
|
// duplicate warnings no longer emitted
|
||||||
"WARN: Dropping unreachable code [test/compress/issue-1034.js:229,16]",
|
"WARN: Dropping unreachable code [test/compress/issue-1034.js:287,16]",
|
||||||
"WARN: Declarations in unreachable code! [test/compress/issue-1034.js:229,16]",
|
"WARN: Declarations in unreachable code! [test/compress/issue-1034.js:287,16]",
|
||||||
"WARN: Dropping unreachable code [test/compress/issue-1034.js:231,12]",
|
"WARN: Dropping unreachable code [test/compress/issue-1034.js:289,12]",
|
||||||
"WARN: Declarations in unreachable code! [test/compress/issue-1034.js:231,12]",
|
"WARN: Declarations in unreachable code! [test/compress/issue-1034.js:289,12]",
|
||||||
"WARN: Dropping unreachable code [test/compress/issue-1034.js:235,12]",
|
"WARN: Dropping unreachable code [test/compress/issue-1034.js:293,12]",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ const_pragma: {
|
|||||||
evaluate: true,
|
evaluate: true,
|
||||||
reduce_funcs: true,
|
reduce_funcs: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
};
|
}
|
||||||
|
|
||||||
input: {
|
input: {
|
||||||
/** @const */ var goog = goog || {};
|
/** @const */ var goog = goog || {};
|
||||||
@@ -19,7 +19,7 @@ not_const: {
|
|||||||
evaluate: true,
|
evaluate: true,
|
||||||
reduce_funcs: true,
|
reduce_funcs: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
};
|
}
|
||||||
|
|
||||||
input: {
|
input: {
|
||||||
var goog = goog || {};
|
var goog = goog || {};
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
with_in_global_scope: {
|
with_in_global_scope: {
|
||||||
options = {
|
options = {
|
||||||
unused: true
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
var o = 42;
|
var o = 42;
|
||||||
@@ -18,7 +18,7 @@ with_in_global_scope: {
|
|||||||
}
|
}
|
||||||
with_in_function_scope: {
|
with_in_function_scope: {
|
||||||
options = {
|
options = {
|
||||||
unused: true
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function foo() {
|
function foo() {
|
||||||
@@ -40,7 +40,7 @@ with_in_function_scope: {
|
|||||||
}
|
}
|
||||||
compress_with_with_in_other_scope: {
|
compress_with_with_in_other_scope: {
|
||||||
options = {
|
options = {
|
||||||
unused: true
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function foo() {
|
function foo() {
|
||||||
@@ -69,7 +69,7 @@ compress_with_with_in_other_scope: {
|
|||||||
}
|
}
|
||||||
with_using_existing_variable_outside_scope: {
|
with_using_existing_variable_outside_scope: {
|
||||||
options = {
|
options = {
|
||||||
unused: true
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f() {
|
function f() {
|
||||||
@@ -99,7 +99,7 @@ with_using_existing_variable_outside_scope: {
|
|||||||
}
|
}
|
||||||
check_drop_unused_in_peer_function: {
|
check_drop_unused_in_peer_function: {
|
||||||
options = {
|
options = {
|
||||||
unused: true
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function outer() {
|
function outer() {
|
||||||
@@ -148,7 +148,7 @@ check_drop_unused_in_peer_function: {
|
|||||||
|
|
||||||
Infinity_not_in_with_scope: {
|
Infinity_not_in_with_scope: {
|
||||||
options = {
|
options = {
|
||||||
unused: true
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
var o = { Infinity: 'oInfinity' };
|
var o = { Infinity: 'oInfinity' };
|
||||||
@@ -164,7 +164,7 @@ Infinity_not_in_with_scope: {
|
|||||||
|
|
||||||
Infinity_in_with_scope: {
|
Infinity_in_with_scope: {
|
||||||
options = {
|
options = {
|
||||||
unused: true
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
var o = { Infinity: 'oInfinity' };
|
var o = { Infinity: 'oInfinity' };
|
||||||
@@ -180,19 +180,19 @@ Infinity_in_with_scope: {
|
|||||||
|
|
||||||
assorted_Infinity_NaN_undefined_in_with_scope: {
|
assorted_Infinity_NaN_undefined_in_with_scope: {
|
||||||
options = {
|
options = {
|
||||||
unused: true,
|
booleans: true,
|
||||||
evaluate: true,
|
comparisons: true,
|
||||||
dead_code: true,
|
conditionals: true,
|
||||||
conditionals: true,
|
dead_code: true,
|
||||||
comparisons: true,
|
evaluate: true,
|
||||||
booleans: true,
|
hoist_funs: true,
|
||||||
hoist_funs: true,
|
if_return: true,
|
||||||
keep_fargs: true,
|
join_vars: true,
|
||||||
if_return: true,
|
keep_fargs: true,
|
||||||
join_vars: true,
|
|
||||||
side_effects: true,
|
|
||||||
sequences: false,
|
|
||||||
keep_infinity: false,
|
keep_infinity: false,
|
||||||
|
sequences: false,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
var f = console.log;
|
var f = console.log;
|
||||||
@@ -242,19 +242,19 @@ assorted_Infinity_NaN_undefined_in_with_scope: {
|
|||||||
|
|
||||||
assorted_Infinity_NaN_undefined_in_with_scope_keep_infinity: {
|
assorted_Infinity_NaN_undefined_in_with_scope_keep_infinity: {
|
||||||
options = {
|
options = {
|
||||||
unused: true,
|
booleans: true,
|
||||||
evaluate: true,
|
comparisons: true,
|
||||||
dead_code: true,
|
conditionals: true,
|
||||||
conditionals: true,
|
dead_code: true,
|
||||||
comparisons: true,
|
evaluate: true,
|
||||||
booleans: true,
|
hoist_funs: true,
|
||||||
hoist_funs: true,
|
if_return: true,
|
||||||
keep_fargs: true,
|
join_vars: true,
|
||||||
if_return: true,
|
keep_fargs: true,
|
||||||
join_vars: true,
|
|
||||||
side_effects: true,
|
|
||||||
sequences: false,
|
|
||||||
keep_infinity: true,
|
keep_infinity: true,
|
||||||
|
sequences: false,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
var f = console.log;
|
var f = console.log;
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
keep_name_of_getter: {
|
keep_name_of_getter: {
|
||||||
options = { unused: true };
|
options = {
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
input: { a = { get foo () {} } }
|
input: { a = { get foo () {} } }
|
||||||
expect: { a = { get foo () {} } }
|
expect: { a = { get foo () {} } }
|
||||||
}
|
}
|
||||||
|
|
||||||
keep_name_of_setter: {
|
keep_name_of_setter: {
|
||||||
options = { unused: true };
|
options = {
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
input: { a = { set foo () {} } }
|
input: { a = { set foo () {} } }
|
||||||
expect: { a = { set foo () {} } }
|
expect: { a = { set foo () {} } }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
mangle_keep_fnames_false: {
|
mangle_keep_fnames_false: {
|
||||||
options = {
|
options = {
|
||||||
keep_fnames : true,
|
keep_fargs: true,
|
||||||
keep_fargs : true,
|
keep_fnames: true,
|
||||||
}
|
}
|
||||||
mangle = {
|
mangle = {
|
||||||
keep_fnames : false,
|
keep_fnames : false,
|
||||||
@@ -26,8 +26,8 @@ mangle_keep_fnames_false: {
|
|||||||
|
|
||||||
mangle_keep_fnames_true: {
|
mangle_keep_fnames_true: {
|
||||||
options = {
|
options = {
|
||||||
keep_fnames : true,
|
keep_fargs: true,
|
||||||
keep_fargs : true,
|
keep_fnames: true,
|
||||||
}
|
}
|
||||||
mangle = {
|
mangle = {
|
||||||
keep_fnames : true,
|
keep_fnames : true,
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
pure_function_calls: {
|
pure_function_calls: {
|
||||||
options = {
|
options = {
|
||||||
evaluate : true,
|
booleans: true,
|
||||||
conditionals : true,
|
comparisons: true,
|
||||||
comparisons : true,
|
conditionals: true,
|
||||||
side_effects : true,
|
evaluate: true,
|
||||||
booleans : true,
|
if_return: true,
|
||||||
unused : true,
|
join_vars: true,
|
||||||
if_return : true,
|
negate_iife: true,
|
||||||
join_vars : true,
|
side_effects: true,
|
||||||
negate_iife : true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
// pure top-level IIFE will be dropped
|
// pure top-level IIFE will be dropped
|
||||||
@@ -60,16 +60,16 @@ pure_function_calls: {
|
|||||||
|
|
||||||
pure_function_calls_toplevel: {
|
pure_function_calls_toplevel: {
|
||||||
options = {
|
options = {
|
||||||
evaluate : true,
|
booleans: true,
|
||||||
conditionals : true,
|
comparisons: true,
|
||||||
comparisons : true,
|
conditionals: true,
|
||||||
side_effects : true,
|
evaluate: true,
|
||||||
booleans : true,
|
if_return: true,
|
||||||
unused : true,
|
join_vars: true,
|
||||||
if_return : true,
|
negate_iife: true,
|
||||||
join_vars : true,
|
side_effects: true,
|
||||||
negate_iife : true,
|
toplevel: true,
|
||||||
toplevel : true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
// pure top-level IIFE will be dropped
|
// pure top-level IIFE will be dropped
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
string_plus_optimization: {
|
string_plus_optimization: {
|
||||||
options = {
|
options = {
|
||||||
side_effects : true,
|
booleans: true,
|
||||||
evaluate : true,
|
comparisons: true,
|
||||||
conditionals : true,
|
conditionals: true,
|
||||||
comparisons : true,
|
dead_code: true,
|
||||||
dead_code : true,
|
evaluate: true,
|
||||||
booleans : true,
|
hoist_funs: true,
|
||||||
unused : true,
|
if_return: true,
|
||||||
if_return : true,
|
join_vars: true,
|
||||||
join_vars : true,
|
side_effects: true,
|
||||||
hoist_funs : true,
|
unused: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
function foo(anything) {
|
function foo(anything) {
|
||||||
function throwing_function() {
|
function throwing_function() {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
tranformation_sort_order_equal: {
|
tranformation_sort_order_equal: {
|
||||||
options = {
|
options = {
|
||||||
comparisons: true,
|
comparisons: true,
|
||||||
};
|
}
|
||||||
|
|
||||||
input: { (a = parseInt('100')) == a }
|
input: { (a = parseInt('100')) == a }
|
||||||
expect: { (a = parseInt('100')) == a }
|
expect: { (a = parseInt('100')) == a }
|
||||||
@@ -24,7 +24,7 @@ tranformation_sort_order_equal: {
|
|||||||
tranformation_sort_order_unequal: {
|
tranformation_sort_order_unequal: {
|
||||||
options = {
|
options = {
|
||||||
comparisons: true,
|
comparisons: true,
|
||||||
};
|
}
|
||||||
|
|
||||||
input: { (a = parseInt('100')) != a }
|
input: { (a = parseInt('100')) != a }
|
||||||
expect: { (a = parseInt('100')) != a }
|
expect: { (a = parseInt('100')) != a }
|
||||||
@@ -33,7 +33,7 @@ tranformation_sort_order_unequal: {
|
|||||||
tranformation_sort_order_lesser_or_equal: {
|
tranformation_sort_order_lesser_or_equal: {
|
||||||
options = {
|
options = {
|
||||||
comparisons: true,
|
comparisons: true,
|
||||||
};
|
}
|
||||||
|
|
||||||
input: { (a = parseInt('100')) <= a }
|
input: { (a = parseInt('100')) <= a }
|
||||||
expect: { (a = parseInt('100')) <= a }
|
expect: { (a = parseInt('100')) <= a }
|
||||||
@@ -41,7 +41,7 @@ tranformation_sort_order_lesser_or_equal: {
|
|||||||
tranformation_sort_order_greater_or_equal: {
|
tranformation_sort_order_greater_or_equal: {
|
||||||
options = {
|
options = {
|
||||||
comparisons: true,
|
comparisons: true,
|
||||||
};
|
}
|
||||||
|
|
||||||
input: { (a = parseInt('100')) >= a }
|
input: { (a = parseInt('100')) >= a }
|
||||||
expect: { (a = parseInt('100')) >= a }
|
expect: { (a = parseInt('100')) >= a }
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
level_zero: {
|
level_zero: {
|
||||||
options = {
|
options = {
|
||||||
keep_fnames: true
|
keep_fnames: true,
|
||||||
}
|
}
|
||||||
mangle = {
|
mangle = {
|
||||||
keep_fnames: true
|
keep_fnames: true
|
||||||
@@ -29,7 +29,7 @@ level_zero: {
|
|||||||
|
|
||||||
level_one: {
|
level_one: {
|
||||||
options = {
|
options = {
|
||||||
keep_fnames: true
|
keep_fnames: true,
|
||||||
}
|
}
|
||||||
mangle = {
|
mangle = {
|
||||||
keep_fnames: true
|
keep_fnames: true
|
||||||
@@ -58,7 +58,7 @@ level_one: {
|
|||||||
|
|
||||||
level_two: {
|
level_two: {
|
||||||
options = {
|
options = {
|
||||||
keep_fnames: true
|
keep_fnames: true,
|
||||||
}
|
}
|
||||||
mangle = {
|
mangle = {
|
||||||
keep_fnames: true
|
keep_fnames: true
|
||||||
@@ -97,7 +97,7 @@ level_two: {
|
|||||||
|
|
||||||
level_three: {
|
level_three: {
|
||||||
options = {
|
options = {
|
||||||
keep_fnames: true
|
keep_fnames: true,
|
||||||
}
|
}
|
||||||
mangle = {
|
mangle = {
|
||||||
keep_fnames: true
|
keep_fnames: true
|
||||||
|
|||||||
@@ -22,17 +22,17 @@ else_with_empty_statement: {
|
|||||||
|
|
||||||
conditional_false_stray_else_in_loop: {
|
conditional_false_stray_else_in_loop: {
|
||||||
options = {
|
options = {
|
||||||
evaluate : true,
|
booleans: true,
|
||||||
comparisons : true,
|
comparisons: true,
|
||||||
booleans : true,
|
conditionals: false,
|
||||||
unused : true,
|
dead_code: true,
|
||||||
loops : true,
|
evaluate: true,
|
||||||
side_effects : true,
|
hoist_vars: true,
|
||||||
dead_code : true,
|
if_return: true,
|
||||||
hoist_vars : true,
|
join_vars: true,
|
||||||
join_vars : true,
|
loops: true,
|
||||||
if_return : true,
|
side_effects: true,
|
||||||
conditionals : false,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
for (var i = 1; i <= 4; ++i) {
|
for (var i = 1; i <= 4; ++i) {
|
||||||
|
|||||||
@@ -125,8 +125,8 @@ label_do: {
|
|||||||
|
|
||||||
label_while: {
|
label_while: {
|
||||||
options = {
|
options = {
|
||||||
evaluate: true,
|
|
||||||
dead_code: true,
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
loops: true,
|
loops: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
do_not_update_lhs: {
|
do_not_update_lhs: {
|
||||||
options = {
|
options = {
|
||||||
global_defs: { DEBUG: 0 }
|
global_defs: {
|
||||||
|
DEBUG: 0,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
DEBUG++;
|
DEBUG++;
|
||||||
@@ -16,7 +18,9 @@ do_not_update_lhs: {
|
|||||||
|
|
||||||
do_update_rhs: {
|
do_update_rhs: {
|
||||||
options = {
|
options = {
|
||||||
global_defs: { DEBUG: 0 }
|
global_defs: {
|
||||||
|
DEBUG: 0,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
MY_DEBUG = DEBUG;
|
MY_DEBUG = DEBUG;
|
||||||
@@ -35,7 +39,7 @@ mixed: {
|
|||||||
DEBUG: 0,
|
DEBUG: 0,
|
||||||
ENV: 1,
|
ENV: 1,
|
||||||
FOO: 2,
|
FOO: 2,
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
var ENV = 3;
|
var ENV = 3;
|
||||||
@@ -60,11 +64,11 @@ mixed: {
|
|||||||
x = 0;
|
x = 0;
|
||||||
}
|
}
|
||||||
expect_warnings: [
|
expect_warnings: [
|
||||||
'WARN: global_defs ENV redefined [test/compress/issue-208.js:41,12]',
|
"WARN: global_defs ENV redefined [test/compress/issue-208.js:45,12]",
|
||||||
'WARN: global_defs FOO redefined [test/compress/issue-208.js:42,12]',
|
"WARN: global_defs FOO redefined [test/compress/issue-208.js:46,12]",
|
||||||
'WARN: global_defs FOO redefined [test/compress/issue-208.js:44,10]',
|
"WARN: global_defs FOO redefined [test/compress/issue-208.js:48,10]",
|
||||||
'WARN: global_defs DEBUG redefined [test/compress/issue-208.js:45,8]',
|
"WARN: global_defs DEBUG redefined [test/compress/issue-208.js:49,8]",
|
||||||
'WARN: global_defs DEBUG redefined [test/compress/issue-208.js:46,8]',
|
"WARN: global_defs DEBUG redefined [test/compress/issue-208.js:50,8]",
|
||||||
'WARN: global_defs DEBUG redefined [test/compress/issue-208.js:47,8]',
|
"WARN: global_defs DEBUG redefined [test/compress/issue-208.js:51,8]",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
return_with_no_value_in_if_body: {
|
return_with_no_value_in_if_body: {
|
||||||
options = { conditionals: true };
|
options = {
|
||||||
|
conditionals: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
function foo(bar) {
|
function foo(bar) {
|
||||||
if (bar) {
|
if (bar) {
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
issue_267: {
|
issue_267: {
|
||||||
options = { comparisons: true };
|
options = {
|
||||||
|
comparisons: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
x = a % b / b * c * 2;
|
x = a % b / b * c * 2;
|
||||||
x = a % b * 2
|
x = a % b * 2
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
issue_269_1: {
|
issue_269_1: {
|
||||||
options = {unsafe: true};
|
options = {
|
||||||
|
unsafe: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
f(
|
f(
|
||||||
String(x),
|
String(x),
|
||||||
@@ -20,7 +22,9 @@ issue_269_1: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
issue_269_dangers: {
|
issue_269_dangers: {
|
||||||
options = {unsafe: true};
|
options = {
|
||||||
|
unsafe: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
f(
|
f(
|
||||||
String(x, x),
|
String(x, x),
|
||||||
@@ -34,7 +38,9 @@ issue_269_dangers: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
issue_269_in_scope: {
|
issue_269_in_scope: {
|
||||||
options = {unsafe: true};
|
options = {
|
||||||
|
unsafe: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
var String, Number, Boolean;
|
var String, Number, Boolean;
|
||||||
f(
|
f(
|
||||||
@@ -50,7 +56,9 @@ issue_269_in_scope: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
strings_concat: {
|
strings_concat: {
|
||||||
options = {unsafe: true};
|
options = {
|
||||||
|
unsafe: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
f(
|
f(
|
||||||
String(x + 'str'),
|
String(x + 'str'),
|
||||||
@@ -67,9 +75,9 @@ strings_concat: {
|
|||||||
|
|
||||||
regexp: {
|
regexp: {
|
||||||
options = {
|
options = {
|
||||||
evaluate: true,
|
evaluate: true,
|
||||||
unsafe: true,
|
unsafe: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
RegExp("foo");
|
RegExp("foo");
|
||||||
RegExp("bar", "ig");
|
RegExp("bar", "ig");
|
||||||
@@ -85,6 +93,6 @@ regexp: {
|
|||||||
RegExp("should", "fail");
|
RegExp("should", "fail");
|
||||||
}
|
}
|
||||||
expect_warnings: [
|
expect_warnings: [
|
||||||
'WARN: Error converting RegExp("should","fail") [test/compress/issue-269.js:78,2]',
|
'WARN: Error converting RegExp("should","fail") [test/compress/issue-269.js:86,2]',
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ negate_iife_5_off: {
|
|||||||
inline: true,
|
inline: true,
|
||||||
negate_iife: false,
|
negate_iife: false,
|
||||||
sequences: true,
|
sequences: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
if ((function(){ return t })()) {
|
if ((function(){ return t })()) {
|
||||||
foo(true);
|
foo(true);
|
||||||
@@ -245,7 +245,7 @@ negate_iife_issue_1073: {
|
|||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
sequences: true,
|
sequences: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
new (function(a) {
|
new (function(a) {
|
||||||
return function Foo() {
|
return function Foo() {
|
||||||
@@ -273,7 +273,7 @@ issue_1288_side_effects: {
|
|||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
side_effects: true,
|
side_effects: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
if (w) ;
|
if (w) ;
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
issue_44_valid_ast_1: {
|
issue_44_valid_ast_1: {
|
||||||
options = { unused: true };
|
options = {
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
function a(b) {
|
function a(b) {
|
||||||
for (var i = 0, e = b.qoo(); ; i++) {}
|
for (var i = 0, e = b.qoo(); ; i++) {}
|
||||||
@@ -14,7 +16,9 @@ issue_44_valid_ast_1: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
issue_44_valid_ast_2: {
|
issue_44_valid_ast_2: {
|
||||||
options = { unused: true };
|
options = {
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
function a(b) {
|
function a(b) {
|
||||||
if (foo) for (var i = 0, e = b.qoo(); ; i++) {}
|
if (foo) for (var i = 0, e = b.qoo(); ; i++) {}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
keep_continue: {
|
keep_continue: {
|
||||||
options = {
|
options = {
|
||||||
dead_code: true,
|
dead_code: true,
|
||||||
evaluate: true
|
evaluate: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
while (a) {
|
while (a) {
|
||||||
if (b) {
|
if (b) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
NaN_and_Infinity_must_have_parens: {
|
NaN_and_Infinity_must_have_parens: {
|
||||||
options = {};
|
options = {}
|
||||||
input: {
|
input: {
|
||||||
Infinity.toString();
|
Infinity.toString();
|
||||||
NaN.toString();
|
NaN.toString();
|
||||||
@@ -11,7 +11,7 @@ NaN_and_Infinity_must_have_parens: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NaN_and_Infinity_should_not_be_replaced_when_they_are_redefined: {
|
NaN_and_Infinity_should_not_be_replaced_when_they_are_redefined: {
|
||||||
options = {};
|
options = {}
|
||||||
input: {
|
input: {
|
||||||
var Infinity, NaN;
|
var Infinity, NaN;
|
||||||
Infinity.toString();
|
Infinity.toString();
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
issue_611: {
|
issue_611: {
|
||||||
options = {
|
options = {
|
||||||
sequences: true,
|
sequences: true,
|
||||||
side_effects: true
|
side_effects: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
define(function() {
|
define(function() {
|
||||||
function fn() {}
|
function fn() {}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
wrongly_optimized: {
|
wrongly_optimized: {
|
||||||
options = {
|
options = {
|
||||||
conditionals: true,
|
|
||||||
booleans: true,
|
booleans: true,
|
||||||
evaluate: true
|
conditionals: true,
|
||||||
};
|
evaluate: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
function func() {
|
function func() {
|
||||||
foo();
|
foo();
|
||||||
|
|||||||
@@ -28,12 +28,12 @@ cond_5: {
|
|||||||
|
|
||||||
dead_code_const_annotation_regex: {
|
dead_code_const_annotation_regex: {
|
||||||
options = {
|
options = {
|
||||||
booleans : true,
|
booleans: true,
|
||||||
conditionals : true,
|
conditionals: true,
|
||||||
dead_code : true,
|
dead_code: true,
|
||||||
evaluate : true,
|
evaluate: true,
|
||||||
expression : true,
|
expression: true,
|
||||||
loops : true,
|
loops: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
var unused;
|
var unused;
|
||||||
@@ -82,8 +82,8 @@ drop_value: {
|
|||||||
|
|
||||||
wrongly_optimized: {
|
wrongly_optimized: {
|
||||||
options = {
|
options = {
|
||||||
conditionals: true,
|
|
||||||
booleans: true,
|
booleans: true,
|
||||||
|
conditionals: true,
|
||||||
evaluate: true,
|
evaluate: true,
|
||||||
expression: true,
|
expression: true,
|
||||||
}
|
}
|
||||||
@@ -195,7 +195,7 @@ negate_iife_5_off: {
|
|||||||
expression: true,
|
expression: true,
|
||||||
negate_iife: false,
|
negate_iife: false,
|
||||||
sequences: true,
|
sequences: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
if ((function(){ return t })()) {
|
if ((function(){ return t })()) {
|
||||||
foo(true);
|
foo(true);
|
||||||
@@ -248,7 +248,9 @@ issue_1254_negate_iife_nested: {
|
|||||||
conditional: {
|
conditional: {
|
||||||
options = {
|
options = {
|
||||||
expression: true,
|
expression: true,
|
||||||
pure_funcs: [ "pure" ],
|
pure_funcs: [
|
||||||
|
"pure"
|
||||||
|
],
|
||||||
side_effects: true,
|
side_effects: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
negate_booleans_1: {
|
negate_booleans_1: {
|
||||||
options = {
|
options = {
|
||||||
comparisons: true
|
comparisons: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
var a = !a || !b || !c || !d || !e || !f;
|
var a = !a || !b || !c || !d || !e || !f;
|
||||||
}
|
}
|
||||||
@@ -12,8 +12,8 @@ negate_booleans_1: {
|
|||||||
|
|
||||||
negate_booleans_2: {
|
negate_booleans_2: {
|
||||||
options = {
|
options = {
|
||||||
comparisons: true
|
comparisons: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
var match = !x && // should not touch this one
|
var match = !x && // should not touch this one
|
||||||
(!z || c) &&
|
(!z || c) &&
|
||||||
|
|||||||
@@ -2,25 +2,25 @@ dont_mangle_arguments: {
|
|||||||
mangle = {
|
mangle = {
|
||||||
};
|
};
|
||||||
options = {
|
options = {
|
||||||
sequences : true,
|
booleans: true,
|
||||||
properties : true,
|
comparisons: true,
|
||||||
dead_code : true,
|
conditionals: true,
|
||||||
drop_debugger : true,
|
dead_code: true,
|
||||||
conditionals : true,
|
drop_debugger: true,
|
||||||
comparisons : true,
|
evaluate: true,
|
||||||
evaluate : true,
|
hoist_funs: true,
|
||||||
booleans : true,
|
hoist_vars: true,
|
||||||
loops : true,
|
if_return: true,
|
||||||
unused : true,
|
join_vars: true,
|
||||||
hoist_funs : true,
|
keep_fargs: true,
|
||||||
keep_fargs : true,
|
keep_fnames: false,
|
||||||
keep_fnames : false,
|
loops: true,
|
||||||
hoist_vars : true,
|
negate_iife: false,
|
||||||
if_return : true,
|
properties: true,
|
||||||
join_vars : true,
|
sequences: true,
|
||||||
side_effects : true,
|
side_effects: true,
|
||||||
negate_iife : false
|
unused: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
(function(){
|
(function(){
|
||||||
var arguments = arguments, not_arguments = 9;
|
var arguments = arguments, not_arguments = 9;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
keep_var_for_in: {
|
keep_var_for_in: {
|
||||||
options = {
|
options = {
|
||||||
hoist_vars: true,
|
hoist_vars: true,
|
||||||
unused: true
|
unused: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
(function(obj){
|
(function(obj){
|
||||||
var foo = 5;
|
var foo = 5;
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ this_binding_collapse_vars: {
|
|||||||
|
|
||||||
this_binding_side_effects: {
|
this_binding_side_effects: {
|
||||||
options = {
|
options = {
|
||||||
side_effects : true
|
side_effects: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
(function(foo) {
|
(function(foo) {
|
||||||
|
|||||||
@@ -1,9 +1,21 @@
|
|||||||
eval_collapse_vars: {
|
eval_collapse_vars: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars:true, sequences:false, properties:true, dead_code:true, conditionals:true,
|
booleans: true,
|
||||||
comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true,
|
collapse_vars: true,
|
||||||
keep_fargs:true, if_return:true, join_vars:true, side_effects:true
|
comparisons: true,
|
||||||
};
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
hoist_funs: true,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
loops: true,
|
||||||
|
properties: true,
|
||||||
|
sequences: false,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
function f1() {
|
function f1() {
|
||||||
var e = 7;
|
var e = 7;
|
||||||
@@ -46,7 +58,10 @@ eval_collapse_vars: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
eval_unused: {
|
eval_unused: {
|
||||||
options = { unused: true, keep_fargs: false };
|
options = {
|
||||||
|
keep_fargs: false,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
function f1(a, eval, c, d, e) {
|
function f1(a, eval, c, d, e) {
|
||||||
return a('c') + eval;
|
return a('c') + eval;
|
||||||
|
|||||||
@@ -1,8 +1,19 @@
|
|||||||
issue979_reported: {
|
issue979_reported: {
|
||||||
options = {
|
options = {
|
||||||
sequences:true, properties:true, dead_code:true, conditionals:true,
|
booleans: true,
|
||||||
comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true,
|
comparisons: true,
|
||||||
keep_fargs:true, if_return:true, join_vars:true, side_effects:true
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
hoist_funs: true,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
loops: true,
|
||||||
|
properties: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f1() {
|
function f1() {
|
||||||
@@ -30,9 +41,20 @@ issue979_reported: {
|
|||||||
|
|
||||||
issue979_test_negated_is_best: {
|
issue979_test_negated_is_best: {
|
||||||
options = {
|
options = {
|
||||||
sequences:true, properties:true, dead_code:true, conditionals:true,
|
booleans: true,
|
||||||
comparisons:true, evaluate:true, booleans:true, loops:true, unused:true, hoist_funs:true,
|
comparisons: true,
|
||||||
keep_fargs:true, if_return:true, join_vars:true, side_effects:true
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
hoist_funs: true,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
keep_fargs: true,
|
||||||
|
loops: true,
|
||||||
|
properties: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f3() {
|
function f3() {
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
labels_1: {
|
labels_1: {
|
||||||
options = { if_return: true, conditionals: true, dead_code: true };
|
options = {
|
||||||
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
if_return: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
out: {
|
out: {
|
||||||
if (foo) break out;
|
if (foo) break out;
|
||||||
@@ -13,7 +17,11 @@ labels_1: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
labels_2: {
|
labels_2: {
|
||||||
options = { if_return: true, conditionals: true, dead_code: true };
|
options = {
|
||||||
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
if_return: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
out: {
|
out: {
|
||||||
if (foo) print("stuff");
|
if (foo) print("stuff");
|
||||||
@@ -30,7 +38,11 @@ labels_2: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
labels_3: {
|
labels_3: {
|
||||||
options = { if_return: true, conditionals: true, dead_code: true };
|
options = {
|
||||||
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
if_return: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
for (var i = 0; i < 5; ++i) {
|
for (var i = 0; i < 5; ++i) {
|
||||||
if (i < 3) continue;
|
if (i < 3) continue;
|
||||||
@@ -45,7 +57,11 @@ labels_3: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
labels_4: {
|
labels_4: {
|
||||||
options = { if_return: true, conditionals: true, dead_code: true };
|
options = {
|
||||||
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
if_return: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
out: for (var i = 0; i < 5; ++i) {
|
out: for (var i = 0; i < 5; ++i) {
|
||||||
if (i < 3) continue out;
|
if (i < 3) continue out;
|
||||||
@@ -60,7 +76,11 @@ labels_4: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
labels_5: {
|
labels_5: {
|
||||||
options = { if_return: true, conditionals: true, dead_code: true };
|
options = {
|
||||||
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
if_return: true,
|
||||||
|
}
|
||||||
// should keep the break-s in the following
|
// should keep the break-s in the following
|
||||||
input: {
|
input: {
|
||||||
while (foo) {
|
while (foo) {
|
||||||
@@ -92,7 +112,11 @@ labels_6: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
labels_7: {
|
labels_7: {
|
||||||
options = { if_return: true, conditionals: true, dead_code: true };
|
options = {
|
||||||
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
if_return: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
while (foo) {
|
while (foo) {
|
||||||
x();
|
x();
|
||||||
@@ -109,7 +133,11 @@ labels_7: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
labels_8: {
|
labels_8: {
|
||||||
options = { if_return: true, conditionals: true, dead_code: true };
|
options = {
|
||||||
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
if_return: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
while (foo) {
|
while (foo) {
|
||||||
x();
|
x();
|
||||||
@@ -127,7 +155,11 @@ labels_8: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
labels_9: {
|
labels_9: {
|
||||||
options = { if_return: true, conditionals: true, dead_code: true };
|
options = {
|
||||||
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
if_return: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
out: while (foo) {
|
out: while (foo) {
|
||||||
x();
|
x();
|
||||||
@@ -146,7 +178,11 @@ labels_9: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
labels_10: {
|
labels_10: {
|
||||||
options = { if_return: true, conditionals: true, dead_code: true };
|
options = {
|
||||||
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
if_return: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
out: while (foo) {
|
out: while (foo) {
|
||||||
x();
|
x();
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
while_becomes_for: {
|
while_becomes_for: {
|
||||||
options = { loops: true };
|
options = {
|
||||||
|
loops: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
while (foo()) bar();
|
while (foo()) bar();
|
||||||
}
|
}
|
||||||
@@ -9,7 +11,9 @@ while_becomes_for: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
drop_if_break_1: {
|
drop_if_break_1: {
|
||||||
options = { loops: true };
|
options = {
|
||||||
|
loops: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
for (;;)
|
for (;;)
|
||||||
if (foo()) break;
|
if (foo()) break;
|
||||||
@@ -20,7 +24,9 @@ drop_if_break_1: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
drop_if_break_2: {
|
drop_if_break_2: {
|
||||||
options = { loops: true };
|
options = {
|
||||||
|
loops: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
for (;bar();)
|
for (;bar();)
|
||||||
if (foo()) break;
|
if (foo()) break;
|
||||||
@@ -31,7 +37,9 @@ drop_if_break_2: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
drop_if_break_3: {
|
drop_if_break_3: {
|
||||||
options = { loops: true };
|
options = {
|
||||||
|
loops: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
for (;bar();) {
|
for (;bar();) {
|
||||||
if (foo()) break;
|
if (foo()) break;
|
||||||
@@ -48,7 +56,10 @@ drop_if_break_3: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
drop_if_break_4: {
|
drop_if_break_4: {
|
||||||
options = { loops: true, sequences: true };
|
options = {
|
||||||
|
loops: true,
|
||||||
|
sequences: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
for (;bar();) {
|
for (;bar();) {
|
||||||
x();
|
x();
|
||||||
@@ -64,7 +75,9 @@ drop_if_break_4: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
drop_if_else_break_1: {
|
drop_if_else_break_1: {
|
||||||
options = { loops: true };
|
options = {
|
||||||
|
loops: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
for (;;) if (foo()) bar(); else break;
|
for (;;) if (foo()) bar(); else break;
|
||||||
}
|
}
|
||||||
@@ -74,7 +87,9 @@ drop_if_else_break_1: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
drop_if_else_break_2: {
|
drop_if_else_break_2: {
|
||||||
options = { loops: true };
|
options = {
|
||||||
|
loops: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
for (;bar();) {
|
for (;bar();) {
|
||||||
if (foo()) baz();
|
if (foo()) baz();
|
||||||
@@ -87,7 +102,9 @@ drop_if_else_break_2: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
drop_if_else_break_3: {
|
drop_if_else_break_3: {
|
||||||
options = { loops: true };
|
options = {
|
||||||
|
loops: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
for (;bar();) {
|
for (;bar();) {
|
||||||
if (foo()) baz();
|
if (foo()) baz();
|
||||||
@@ -106,7 +123,10 @@ drop_if_else_break_3: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
drop_if_else_break_4: {
|
drop_if_else_break_4: {
|
||||||
options = { loops: true, sequences: true };
|
options = {
|
||||||
|
loops: true,
|
||||||
|
sequences: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
for (;bar();) {
|
for (;bar();) {
|
||||||
x();
|
x();
|
||||||
@@ -123,7 +143,9 @@ drop_if_else_break_4: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
parse_do_while_with_semicolon: {
|
parse_do_while_with_semicolon: {
|
||||||
options = { loops: false };
|
options = {
|
||||||
|
loops: false,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
do {
|
do {
|
||||||
x();
|
x();
|
||||||
@@ -135,7 +157,9 @@ parse_do_while_with_semicolon: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
parse_do_while_without_semicolon: {
|
parse_do_while_without_semicolon: {
|
||||||
options = { loops: false };
|
options = {
|
||||||
|
loops: false,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
do {
|
do {
|
||||||
x();
|
x();
|
||||||
@@ -153,7 +177,7 @@ evaluate: {
|
|||||||
loops: true,
|
loops: true,
|
||||||
passes: 2,
|
passes: 2,
|
||||||
side_effects: true,
|
side_effects: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
while (true) {
|
while (true) {
|
||||||
a();
|
a();
|
||||||
@@ -457,7 +481,7 @@ init_side_effects: {
|
|||||||
options = {
|
options = {
|
||||||
loops: true,
|
loops: true,
|
||||||
side_effects: true,
|
side_effects: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
for (function() {}(), i = 0; i < 5; i++) console.log(i);
|
for (function() {}(), i = 0; i < 5; i++) console.log(i);
|
||||||
for (function() {}(); i < 10; i++) console.log(i);
|
for (function() {}(); i < 10; i++) console.log(i);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
negate_iife_1: {
|
negate_iife_1: {
|
||||||
options = {
|
options = {
|
||||||
negate_iife: true
|
negate_iife: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
(function(){ stuff() })();
|
(function(){ stuff() })();
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,7 @@ negate_iife_1: {
|
|||||||
negate_iife_1_off: {
|
negate_iife_1_off: {
|
||||||
options = {
|
options = {
|
||||||
negate_iife: false,
|
negate_iife: false,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
(function(){ stuff() })();
|
(function(){ stuff() })();
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,7 @@ negate_iife_2: {
|
|||||||
options = {
|
options = {
|
||||||
inline: true,
|
inline: true,
|
||||||
negate_iife: true,
|
negate_iife: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
(function(){ return {} })().x = 10;
|
(function(){ return {} })().x = 10;
|
||||||
}
|
}
|
||||||
@@ -45,9 +45,9 @@ negate_iife_2_side_effects: {
|
|||||||
|
|
||||||
negate_iife_3: {
|
negate_iife_3: {
|
||||||
options = {
|
options = {
|
||||||
|
conditionals: true,
|
||||||
negate_iife: true,
|
negate_iife: true,
|
||||||
conditionals: true
|
}
|
||||||
};
|
|
||||||
input: {
|
input: {
|
||||||
(function(){ return t })() ? console.log(true) : console.log(false);
|
(function(){ return t })() ? console.log(true) : console.log(false);
|
||||||
}
|
}
|
||||||
@@ -88,9 +88,9 @@ negate_iife_3_side_effects: {
|
|||||||
|
|
||||||
negate_iife_3_off: {
|
negate_iife_3_off: {
|
||||||
options = {
|
options = {
|
||||||
negate_iife: false,
|
|
||||||
conditionals: true,
|
conditionals: true,
|
||||||
};
|
negate_iife: false,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
(function(){ return t })() ? console.log(true) : console.log(false);
|
(function(){ return t })() ? console.log(true) : console.log(false);
|
||||||
}
|
}
|
||||||
@@ -117,10 +117,10 @@ negate_iife_3_off_evaluate: {
|
|||||||
|
|
||||||
negate_iife_4: {
|
negate_iife_4: {
|
||||||
options = {
|
options = {
|
||||||
negate_iife: true,
|
|
||||||
conditionals: true,
|
conditionals: true,
|
||||||
sequences: true
|
negate_iife: true,
|
||||||
};
|
sequences: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
(function(){ return t })() ? console.log(true) : console.log(false);
|
(function(){ return t })() ? console.log(true) : console.log(false);
|
||||||
(function(){
|
(function(){
|
||||||
@@ -136,11 +136,11 @@ negate_iife_4: {
|
|||||||
|
|
||||||
sequence_off: {
|
sequence_off: {
|
||||||
options = {
|
options = {
|
||||||
negate_iife: false,
|
|
||||||
conditionals: true,
|
conditionals: true,
|
||||||
sequences: true,
|
negate_iife: false,
|
||||||
passes: 2,
|
passes: 2,
|
||||||
};
|
sequences: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
function f() {
|
function f() {
|
||||||
(function(){ return t })() ? console.log(true) : console.log(false);
|
(function(){ return t })() ? console.log(true) : console.log(false);
|
||||||
@@ -171,10 +171,10 @@ sequence_off: {
|
|||||||
|
|
||||||
negate_iife_5: {
|
negate_iife_5: {
|
||||||
options = {
|
options = {
|
||||||
|
conditionals: true,
|
||||||
negate_iife: true,
|
negate_iife: true,
|
||||||
sequences: true,
|
sequences: true,
|
||||||
conditionals: true,
|
}
|
||||||
};
|
|
||||||
input: {
|
input: {
|
||||||
if ((function(){ return t })()) {
|
if ((function(){ return t })()) {
|
||||||
foo(true);
|
foo(true);
|
||||||
@@ -194,10 +194,10 @@ negate_iife_5: {
|
|||||||
|
|
||||||
negate_iife_5_off: {
|
negate_iife_5_off: {
|
||||||
options = {
|
options = {
|
||||||
|
conditionals: true,
|
||||||
negate_iife: false,
|
negate_iife: false,
|
||||||
sequences: true,
|
sequences: true,
|
||||||
conditionals: true,
|
}
|
||||||
};
|
|
||||||
input: {
|
input: {
|
||||||
if ((function(){ return t })()) {
|
if ((function(){ return t })()) {
|
||||||
foo(true);
|
foo(true);
|
||||||
@@ -217,10 +217,10 @@ negate_iife_5_off: {
|
|||||||
|
|
||||||
negate_iife_nested: {
|
negate_iife_nested: {
|
||||||
options = {
|
options = {
|
||||||
|
conditionals: true,
|
||||||
negate_iife: true,
|
negate_iife: true,
|
||||||
sequences: true,
|
sequences: true,
|
||||||
conditionals: true,
|
}
|
||||||
};
|
|
||||||
input: {
|
input: {
|
||||||
function Foo(f) {
|
function Foo(f) {
|
||||||
this.f = f;
|
this.f = f;
|
||||||
@@ -250,10 +250,10 @@ negate_iife_nested: {
|
|||||||
|
|
||||||
negate_iife_nested_off: {
|
negate_iife_nested_off: {
|
||||||
options = {
|
options = {
|
||||||
|
conditionals: true,
|
||||||
negate_iife: false,
|
negate_iife: false,
|
||||||
sequences: true,
|
sequences: true,
|
||||||
conditionals: true,
|
}
|
||||||
};
|
|
||||||
input: {
|
input: {
|
||||||
function Foo(f) {
|
function Foo(f) {
|
||||||
this.f = f;
|
this.f = f;
|
||||||
@@ -283,10 +283,10 @@ negate_iife_nested_off: {
|
|||||||
|
|
||||||
negate_iife_issue_1073: {
|
negate_iife_issue_1073: {
|
||||||
options = {
|
options = {
|
||||||
|
conditionals: true,
|
||||||
negate_iife: true,
|
negate_iife: true,
|
||||||
sequences: true,
|
sequences: true,
|
||||||
conditionals: true,
|
}
|
||||||
};
|
|
||||||
input: {
|
input: {
|
||||||
new (function(a) {
|
new (function(a) {
|
||||||
return function Foo() {
|
return function Foo() {
|
||||||
@@ -356,7 +356,7 @@ issue_1288: {
|
|||||||
conditionals: true,
|
conditionals: true,
|
||||||
negate_iife: true,
|
negate_iife: true,
|
||||||
side_effects: false,
|
side_effects: false,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
if (w) ;
|
if (w) ;
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -36,7 +36,9 @@ new_statements_3: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
new_with_rewritten_true_value: {
|
new_with_rewritten_true_value: {
|
||||||
options = { booleans: true }
|
options = {
|
||||||
|
booleans: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
new true;
|
new true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -187,10 +187,10 @@ issue_2110_1: {
|
|||||||
options = {
|
options = {
|
||||||
collapse_vars: true,
|
collapse_vars: true,
|
||||||
pure_getters: "strict",
|
pure_getters: "strict",
|
||||||
sequences: true,
|
|
||||||
side_effects: true,
|
|
||||||
reduce_funcs: true,
|
reduce_funcs: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
reduce_vars: {
|
reduce_vars: {
|
||||||
options = {
|
options = {
|
||||||
conditionals : true,
|
conditionals: true,
|
||||||
evaluate : true,
|
evaluate: true,
|
||||||
inline : true,
|
global_defs: {
|
||||||
global_defs : {
|
C: 0,
|
||||||
C : 0
|
|
||||||
},
|
},
|
||||||
reduce_funcs : true,
|
inline: true,
|
||||||
reduce_vars : true,
|
reduce_funcs: true,
|
||||||
toplevel : true,
|
reduce_vars: true,
|
||||||
unused : true
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
var A = 1;
|
var A = 1;
|
||||||
@@ -63,11 +63,11 @@ reduce_vars: {
|
|||||||
|
|
||||||
modified: {
|
modified: {
|
||||||
options = {
|
options = {
|
||||||
conditionals : true,
|
conditionals: true,
|
||||||
evaluate : true,
|
evaluate: true,
|
||||||
reduce_funcs : true,
|
reduce_funcs: true,
|
||||||
reduce_vars : true,
|
reduce_vars: true,
|
||||||
unused : true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f0() {
|
function f0() {
|
||||||
@@ -184,12 +184,12 @@ modified: {
|
|||||||
|
|
||||||
unsafe_evaluate: {
|
unsafe_evaluate: {
|
||||||
options = {
|
options = {
|
||||||
evaluate : true,
|
evaluate: true,
|
||||||
reduce_funcs : true,
|
reduce_funcs: true,
|
||||||
reduce_vars : true,
|
reduce_vars: true,
|
||||||
side_effects : true,
|
side_effects: true,
|
||||||
unsafe : true,
|
unsafe: true,
|
||||||
unused : true
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f0(){
|
function f0(){
|
||||||
@@ -344,10 +344,10 @@ unsafe_evaluate_unknown: {
|
|||||||
|
|
||||||
unsafe_evaluate_object_1: {
|
unsafe_evaluate_object_1: {
|
||||||
options = {
|
options = {
|
||||||
evaluate : true,
|
evaluate: true,
|
||||||
reduce_funcs : true,
|
reduce_funcs: true,
|
||||||
reduce_vars : true,
|
reduce_vars: true,
|
||||||
unsafe : true
|
unsafe: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f0(){
|
function f0(){
|
||||||
@@ -463,10 +463,10 @@ unsafe_evaluate_object_3: {
|
|||||||
|
|
||||||
unsafe_evaluate_array_1: {
|
unsafe_evaluate_array_1: {
|
||||||
options = {
|
options = {
|
||||||
evaluate : true,
|
evaluate: true,
|
||||||
reduce_funcs : true,
|
reduce_funcs: true,
|
||||||
reduce_vars : true,
|
reduce_vars: true,
|
||||||
unsafe : true
|
unsafe: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f0(){
|
function f0(){
|
||||||
@@ -642,11 +642,11 @@ unsafe_evaluate_array_5: {
|
|||||||
|
|
||||||
unsafe_evaluate_equality_1: {
|
unsafe_evaluate_equality_1: {
|
||||||
options = {
|
options = {
|
||||||
evaluate : true,
|
evaluate: true,
|
||||||
reduce_funcs : true,
|
reduce_funcs: true,
|
||||||
reduce_vars : true,
|
reduce_vars: true,
|
||||||
unsafe : true,
|
unsafe: true,
|
||||||
unused : true
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f0() {
|
function f0() {
|
||||||
@@ -674,12 +674,12 @@ unsafe_evaluate_equality_1: {
|
|||||||
unsafe_evaluate_equality_2: {
|
unsafe_evaluate_equality_2: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars: true,
|
collapse_vars: true,
|
||||||
evaluate : true,
|
evaluate: true,
|
||||||
passes : 2,
|
passes: 2,
|
||||||
reduce_funcs : true,
|
reduce_funcs: true,
|
||||||
reduce_vars : true,
|
reduce_vars: true,
|
||||||
unsafe : true,
|
unsafe: true,
|
||||||
unused : true
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f2() {
|
function f2() {
|
||||||
@@ -1130,7 +1130,7 @@ toplevel_on: {
|
|||||||
evaluate: true,
|
evaluate: true,
|
||||||
reduce_funcs: true,
|
reduce_funcs: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
toplevel:true,
|
toplevel: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
@@ -1148,7 +1148,7 @@ toplevel_off: {
|
|||||||
evaluate: true,
|
evaluate: true,
|
||||||
reduce_funcs: true,
|
reduce_funcs: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
toplevel:false,
|
toplevel: false,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
@@ -1168,7 +1168,7 @@ toplevel_on_loops_1: {
|
|||||||
loops: true,
|
loops: true,
|
||||||
reduce_funcs: true,
|
reduce_funcs: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
toplevel:true,
|
toplevel: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
@@ -1196,7 +1196,7 @@ toplevel_off_loops_1: {
|
|||||||
loops: true,
|
loops: true,
|
||||||
reduce_funcs: true,
|
reduce_funcs: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
toplevel:false,
|
toplevel: false,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
@@ -1225,7 +1225,7 @@ toplevel_on_loops_2: {
|
|||||||
reduce_funcs: true,
|
reduce_funcs: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
side_effects: true,
|
side_effects: true,
|
||||||
toplevel:true,
|
toplevel: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
@@ -1251,7 +1251,7 @@ toplevel_off_loops_2: {
|
|||||||
loops: true,
|
loops: true,
|
||||||
reduce_funcs: true,
|
reduce_funcs: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
toplevel:false,
|
toplevel: false,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
@@ -1278,7 +1278,7 @@ toplevel_on_loops_3: {
|
|||||||
loops: true,
|
loops: true,
|
||||||
reduce_funcs: true,
|
reduce_funcs: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
toplevel:true,
|
toplevel: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
@@ -1296,7 +1296,7 @@ toplevel_off_loops_3: {
|
|||||||
loops: true,
|
loops: true,
|
||||||
reduce_funcs: true,
|
reduce_funcs: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
toplevel:false,
|
toplevel: false,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
@@ -1560,6 +1560,32 @@ func_modified: {
|
|||||||
expect_stdout: "7"
|
expect_stdout: "7"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unused_modified: {
|
||||||
|
options = {
|
||||||
|
reduce_vars: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(function() {
|
||||||
|
var b = 1, c = "FAIL";
|
||||||
|
if (0 || b--)
|
||||||
|
c = "PASS";
|
||||||
|
b = 1;
|
||||||
|
return c;
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(function() {
|
||||||
|
var b = 1, c = "FAIL";
|
||||||
|
if (0 || b--)
|
||||||
|
c = "PASS";
|
||||||
|
b = 1;
|
||||||
|
return c;
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
defun_label: {
|
defun_label: {
|
||||||
options = {
|
options = {
|
||||||
passes: 2,
|
passes: 2,
|
||||||
@@ -1868,8 +1894,8 @@ issue_1670_1: {
|
|||||||
options = {
|
options = {
|
||||||
comparisons: true,
|
comparisons: true,
|
||||||
conditionals: true,
|
conditionals: true,
|
||||||
evaluate: true,
|
|
||||||
dead_code: true,
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
reduce_funcs: true,
|
reduce_funcs: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
side_effects: true,
|
side_effects: true,
|
||||||
@@ -1901,8 +1927,8 @@ issue_1670_1: {
|
|||||||
issue_1670_2: {
|
issue_1670_2: {
|
||||||
options = {
|
options = {
|
||||||
conditionals: true,
|
conditionals: true,
|
||||||
evaluate: true,
|
|
||||||
dead_code: true,
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
passes: 2,
|
passes: 2,
|
||||||
reduce_funcs: true,
|
reduce_funcs: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
@@ -1934,8 +1960,8 @@ issue_1670_3: {
|
|||||||
options = {
|
options = {
|
||||||
comparisons: true,
|
comparisons: true,
|
||||||
conditionals: true,
|
conditionals: true,
|
||||||
evaluate: true,
|
|
||||||
dead_code: true,
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
reduce_funcs: true,
|
reduce_funcs: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
side_effects: true,
|
side_effects: true,
|
||||||
@@ -1967,8 +1993,8 @@ issue_1670_3: {
|
|||||||
issue_1670_4: {
|
issue_1670_4: {
|
||||||
options = {
|
options = {
|
||||||
conditionals: true,
|
conditionals: true,
|
||||||
evaluate: true,
|
|
||||||
dead_code: true,
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
passes: 2,
|
passes: 2,
|
||||||
reduce_funcs: true,
|
reduce_funcs: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
|
|||||||
@@ -1,24 +1,24 @@
|
|||||||
return_undefined: {
|
return_undefined: {
|
||||||
options = {
|
options = {
|
||||||
sequences : false,
|
booleans: true,
|
||||||
if_return : true,
|
comparisons: true,
|
||||||
evaluate : true,
|
conditionals: true,
|
||||||
dead_code : true,
|
dead_code: true,
|
||||||
conditionals : true,
|
drop_debugger: true,
|
||||||
comparisons : true,
|
evaluate: true,
|
||||||
booleans : true,
|
hoist_funs: true,
|
||||||
unused : true,
|
hoist_vars: true,
|
||||||
side_effects : true,
|
if_return: true,
|
||||||
properties : true,
|
join_vars: true,
|
||||||
drop_debugger : true,
|
keep_fargs: true,
|
||||||
loops : true,
|
keep_fnames: false,
|
||||||
hoist_funs : true,
|
loops: true,
|
||||||
keep_fargs : true,
|
negate_iife: true,
|
||||||
keep_fnames : false,
|
properties: true,
|
||||||
hoist_vars : true,
|
sequences: false,
|
||||||
join_vars : true,
|
side_effects: true,
|
||||||
negate_iife : true
|
unused: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
function f0() {
|
function f0() {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
make_sequences_1: {
|
make_sequences_1: {
|
||||||
options = {
|
options = {
|
||||||
sequences: true
|
sequences: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
foo();
|
foo();
|
||||||
bar();
|
bar();
|
||||||
@@ -14,8 +14,8 @@ make_sequences_1: {
|
|||||||
|
|
||||||
make_sequences_2: {
|
make_sequences_2: {
|
||||||
options = {
|
options = {
|
||||||
sequences: true
|
sequences: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
if (boo) {
|
if (boo) {
|
||||||
foo();
|
foo();
|
||||||
@@ -35,8 +35,8 @@ make_sequences_2: {
|
|||||||
|
|
||||||
make_sequences_3: {
|
make_sequences_3: {
|
||||||
options = {
|
options = {
|
||||||
sequences: true
|
sequences: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
function f() {
|
function f() {
|
||||||
foo();
|
foo();
|
||||||
@@ -61,8 +61,8 @@ make_sequences_3: {
|
|||||||
|
|
||||||
make_sequences_4: {
|
make_sequences_4: {
|
||||||
options = {
|
options = {
|
||||||
sequences: true
|
sequences: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
x = 5;
|
x = 5;
|
||||||
if (y) z();
|
if (y) z();
|
||||||
@@ -90,7 +90,9 @@ make_sequences_4: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
lift_sequences_1: {
|
lift_sequences_1: {
|
||||||
options = { sequences: true };
|
options = {
|
||||||
|
sequences: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
var foo, x, y, bar;
|
var foo, x, y, bar;
|
||||||
foo = !(x(), y(), bar());
|
foo = !(x(), y(), bar());
|
||||||
@@ -102,7 +104,10 @@ lift_sequences_1: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
lift_sequences_2: {
|
lift_sequences_2: {
|
||||||
options = { sequences: true, evaluate: true };
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
sequences: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
var foo = 1, bar;
|
var foo = 1, bar;
|
||||||
foo.x = (foo = {}, 10);
|
foo.x = (foo = {}, 10);
|
||||||
@@ -119,7 +124,10 @@ lift_sequences_2: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
lift_sequences_3: {
|
lift_sequences_3: {
|
||||||
options = { sequences: true, conditionals: true };
|
options = {
|
||||||
|
conditionals: true,
|
||||||
|
sequences: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
var x, foo, bar, baz;
|
var x, foo, bar, baz;
|
||||||
x = (foo(), bar(), baz()) ? 10 : 20;
|
x = (foo(), bar(), baz()) ? 10 : 20;
|
||||||
@@ -131,7 +139,9 @@ lift_sequences_3: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
lift_sequences_4: {
|
lift_sequences_4: {
|
||||||
options = { side_effects: true };
|
options = {
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
var x, foo, bar, baz;
|
var x, foo, bar, baz;
|
||||||
x = (foo, bar, baz);
|
x = (foo, bar, baz);
|
||||||
@@ -160,7 +170,9 @@ lift_sequences_5: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for_sequences: {
|
for_sequences: {
|
||||||
options = { sequences: true };
|
options = {
|
||||||
|
sequences: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
// 1
|
// 1
|
||||||
foo();
|
foo();
|
||||||
@@ -203,7 +215,7 @@ for_sequences: {
|
|||||||
limit_1: {
|
limit_1: {
|
||||||
options = {
|
options = {
|
||||||
sequences: 3,
|
sequences: 3,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
a;
|
a;
|
||||||
b;
|
b;
|
||||||
@@ -228,7 +240,7 @@ limit_1: {
|
|||||||
limit_2: {
|
limit_2: {
|
||||||
options = {
|
options = {
|
||||||
sequences: 3,
|
sequences: 3,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
a, b;
|
a, b;
|
||||||
c, d;
|
c, d;
|
||||||
@@ -246,9 +258,9 @@ limit_2: {
|
|||||||
|
|
||||||
negate_iife_for: {
|
negate_iife_for: {
|
||||||
options = {
|
options = {
|
||||||
sequences: true,
|
|
||||||
negate_iife: true,
|
negate_iife: true,
|
||||||
};
|
sequences: true,
|
||||||
|
}
|
||||||
input: {
|
input: {
|
||||||
(function() {})();
|
(function() {})();
|
||||||
for (i = 0; i < 5; i++) console.log(i);
|
for (i = 0; i < 5; i++) console.log(i);
|
||||||
@@ -265,7 +277,7 @@ negate_iife_for: {
|
|||||||
iife: {
|
iife: {
|
||||||
options = {
|
options = {
|
||||||
sequences: true,
|
sequences: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
x = 42;
|
x = 42;
|
||||||
(function a() {})();
|
(function a() {})();
|
||||||
|
|||||||
@@ -820,8 +820,8 @@ issue_1758: {
|
|||||||
|
|
||||||
issue_2535: {
|
issue_2535: {
|
||||||
options = {
|
options = {
|
||||||
evaluate: true,
|
|
||||||
dead_code: true,
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
switches: true,
|
switches: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ typeof_evaluation: {
|
|||||||
options = {
|
options = {
|
||||||
evaluate: true,
|
evaluate: true,
|
||||||
typeofs: true,
|
typeofs: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
a = typeof 1;
|
a = typeof 1;
|
||||||
b = typeof 'test';
|
b = typeof 'test';
|
||||||
@@ -27,11 +27,11 @@ typeof_evaluation: {
|
|||||||
|
|
||||||
typeof_in_boolean_context: {
|
typeof_in_boolean_context: {
|
||||||
options = {
|
options = {
|
||||||
booleans : true,
|
booleans: true,
|
||||||
evaluate : true,
|
conditionals: true,
|
||||||
conditionals : true,
|
evaluate: true,
|
||||||
side_effects : true,
|
side_effects: true,
|
||||||
};
|
}
|
||||||
input: {
|
input: {
|
||||||
function f1(x) { return typeof x ? "yes" : "no"; }
|
function f1(x) { return typeof x ? "yes" : "no"; }
|
||||||
function f2() { return typeof g()? "Yes" : "No"; }
|
function f2() { return typeof g()? "Yes" : "No"; }
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
unicode_parse_variables: {
|
unicode_parse_variables: {
|
||||||
options = {};
|
options = {}
|
||||||
input: {
|
input: {
|
||||||
var a = {};
|
var a = {};
|
||||||
a.你好 = 456;
|
a.你好 = 456;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ function read(path) {
|
|||||||
|
|
||||||
describe("bin/uglifyjs", function() {
|
describe("bin/uglifyjs", function() {
|
||||||
var uglifyjscmd = '"' + process.argv[0] + '" bin/uglifyjs';
|
var uglifyjscmd = '"' + process.argv[0] + '" bin/uglifyjs';
|
||||||
it("should produce a functional build when using --self", function(done) {
|
it("Should produce a functional build when using --self", function(done) {
|
||||||
this.timeout(30000);
|
this.timeout(30000);
|
||||||
var command = uglifyjscmd + ' --self -cm --wrap WrappedUglifyJS';
|
var command = uglifyjscmd + ' --self -cm --wrap WrappedUglifyJS';
|
||||||
exec(command, function(err, stdout) {
|
exec(command, function(err, stdout) {
|
||||||
@@ -68,7 +68,7 @@ describe("bin/uglifyjs", function() {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it("should not append source map to output when not using --source-map url=inline", function(done) {
|
it("Should not append source map to output when not using --source-map url=inline", function(done) {
|
||||||
var command = uglifyjscmd + ' test/input/issue-1323/sample.js';
|
var command = uglifyjscmd + ' test/input/issue-1323/sample.js';
|
||||||
exec(command, function(err, stdout) {
|
exec(command, function(err, stdout) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
@@ -76,7 +76,7 @@ describe("bin/uglifyjs", function() {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it("should not consider source map file content as source map file name (issue #2082)", function(done) {
|
it("Should not consider source map file content as source map file name (issue #2082)", function(done) {
|
||||||
var command = [
|
var command = [
|
||||||
uglifyjscmd,
|
uglifyjscmd,
|
||||||
"test/input/issue-2082/sample.js",
|
"test/input/issue-2082/sample.js",
|
||||||
|
|||||||
@@ -2,14 +2,12 @@ var assert = require("assert");
|
|||||||
var UglifyJS = require("../node");
|
var UglifyJS = require("../node");
|
||||||
|
|
||||||
describe("Directives", function() {
|
describe("Directives", function() {
|
||||||
it ("Should allow tokenizer to store directives state", function() {
|
it("Should allow tokenizer to store directives state", function() {
|
||||||
var tokenizer = UglifyJS.tokenizer("", "foo.js");
|
var tokenizer = UglifyJS.tokenizer("", "foo.js");
|
||||||
|
|
||||||
// Stack level 0
|
// Stack level 0
|
||||||
assert.strictEqual(tokenizer.has_directive("use strict"), false);
|
assert.strictEqual(tokenizer.has_directive("use strict"), false);
|
||||||
assert.strictEqual(tokenizer.has_directive("use asm"), false);
|
assert.strictEqual(tokenizer.has_directive("use asm"), false);
|
||||||
assert.strictEqual(tokenizer.has_directive("use thing"), false);
|
assert.strictEqual(tokenizer.has_directive("use thing"), false);
|
||||||
|
|
||||||
// Stack level 2
|
// Stack level 2
|
||||||
tokenizer.push_directives_stack();
|
tokenizer.push_directives_stack();
|
||||||
tokenizer.push_directives_stack();
|
tokenizer.push_directives_stack();
|
||||||
@@ -17,7 +15,6 @@ describe("Directives", function() {
|
|||||||
assert.strictEqual(tokenizer.has_directive("use strict"), true);
|
assert.strictEqual(tokenizer.has_directive("use strict"), true);
|
||||||
assert.strictEqual(tokenizer.has_directive("use asm"), false);
|
assert.strictEqual(tokenizer.has_directive("use asm"), false);
|
||||||
assert.strictEqual(tokenizer.has_directive("use thing"), false);
|
assert.strictEqual(tokenizer.has_directive("use thing"), false);
|
||||||
|
|
||||||
// Stack level 3
|
// Stack level 3
|
||||||
tokenizer.push_directives_stack();
|
tokenizer.push_directives_stack();
|
||||||
tokenizer.add_directive("use strict");
|
tokenizer.add_directive("use strict");
|
||||||
@@ -25,13 +22,11 @@ describe("Directives", function() {
|
|||||||
assert.strictEqual(tokenizer.has_directive("use strict"), true);
|
assert.strictEqual(tokenizer.has_directive("use strict"), true);
|
||||||
assert.strictEqual(tokenizer.has_directive("use asm"), true);
|
assert.strictEqual(tokenizer.has_directive("use asm"), true);
|
||||||
assert.strictEqual(tokenizer.has_directive("use thing"), false);
|
assert.strictEqual(tokenizer.has_directive("use thing"), false);
|
||||||
|
|
||||||
// Stack level 2
|
// Stack level 2
|
||||||
tokenizer.pop_directives_stack();
|
tokenizer.pop_directives_stack();
|
||||||
assert.strictEqual(tokenizer.has_directive("use strict"), true);
|
assert.strictEqual(tokenizer.has_directive("use strict"), true);
|
||||||
assert.strictEqual(tokenizer.has_directive("use asm"), false);
|
assert.strictEqual(tokenizer.has_directive("use asm"), false);
|
||||||
assert.strictEqual(tokenizer.has_directive("use thing"), false);
|
assert.strictEqual(tokenizer.has_directive("use thing"), false);
|
||||||
|
|
||||||
// Stack level 3
|
// Stack level 3
|
||||||
tokenizer.push_directives_stack();
|
tokenizer.push_directives_stack();
|
||||||
tokenizer.add_directive("use thing");
|
tokenizer.add_directive("use thing");
|
||||||
@@ -39,152 +34,138 @@ describe("Directives", function() {
|
|||||||
assert.strictEqual(tokenizer.has_directive("use strict"), true);
|
assert.strictEqual(tokenizer.has_directive("use strict"), true);
|
||||||
assert.strictEqual(tokenizer.has_directive("use asm"), false); // Directives are strict!
|
assert.strictEqual(tokenizer.has_directive("use asm"), false); // Directives are strict!
|
||||||
assert.strictEqual(tokenizer.has_directive("use thing"), true);
|
assert.strictEqual(tokenizer.has_directive("use thing"), true);
|
||||||
|
|
||||||
// Stack level 2
|
// Stack level 2
|
||||||
tokenizer.pop_directives_stack();
|
tokenizer.pop_directives_stack();
|
||||||
assert.strictEqual(tokenizer.has_directive("use strict"), true);
|
assert.strictEqual(tokenizer.has_directive("use strict"), true);
|
||||||
assert.strictEqual(tokenizer.has_directive("use asm"), false);
|
assert.strictEqual(tokenizer.has_directive("use asm"), false);
|
||||||
assert.strictEqual(tokenizer.has_directive("use thing"), false);
|
assert.strictEqual(tokenizer.has_directive("use thing"), false);
|
||||||
|
|
||||||
// Stack level 1
|
// Stack level 1
|
||||||
tokenizer.pop_directives_stack();
|
tokenizer.pop_directives_stack();
|
||||||
assert.strictEqual(tokenizer.has_directive("use strict"), false);
|
assert.strictEqual(tokenizer.has_directive("use strict"), false);
|
||||||
assert.strictEqual(tokenizer.has_directive("use asm"), false);
|
assert.strictEqual(tokenizer.has_directive("use asm"), false);
|
||||||
assert.strictEqual(tokenizer.has_directive("use thing"), false);
|
assert.strictEqual(tokenizer.has_directive("use thing"), false);
|
||||||
|
|
||||||
// Stack level 0
|
// Stack level 0
|
||||||
tokenizer.pop_directives_stack();
|
tokenizer.pop_directives_stack();
|
||||||
assert.strictEqual(tokenizer.has_directive("use strict"), false);
|
assert.strictEqual(tokenizer.has_directive("use strict"), false);
|
||||||
assert.strictEqual(tokenizer.has_directive("use asm"), false);
|
assert.strictEqual(tokenizer.has_directive("use asm"), false);
|
||||||
assert.strictEqual(tokenizer.has_directive("use thing"), false);
|
assert.strictEqual(tokenizer.has_directive("use thing"), false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should know which strings are directive and which ones are not", function() {
|
it("Should know which strings are directive and which ones are not", function() {
|
||||||
var test_directive = function(tokenizer, test) {
|
[
|
||||||
test.directives.map(function(directive) {
|
[
|
||||||
assert.strictEqual(tokenizer.has_directive(directive), true, directive + " in " + test.input);
|
'"use strict"\n',
|
||||||
});
|
[ "use strict"],
|
||||||
test.non_directives.map(function(fake_directive) {
|
[ "use asm"]
|
||||||
assert.strictEqual(tokenizer.has_directive(fake_directive), false, fake_directive + " in " + test.input);
|
],
|
||||||
});
|
[
|
||||||
}
|
'"use\\\nstrict";',
|
||||||
|
[],
|
||||||
var tests = [
|
[ "use strict", "use\nstrict", "use \nstrict", "use asm" ]
|
||||||
{
|
],
|
||||||
input: '"use strict"\n',
|
[
|
||||||
directives: ["use strict"],
|
'"use strict"\n"use asm"\n"use bar"\n',
|
||||||
non_directives: ["use asm"]
|
[ "use strict", "use asm", "use bar" ],
|
||||||
},
|
[ "use foo", "use\\x20strict" ]
|
||||||
{
|
],
|
||||||
input: '"use\\\nstrict";',
|
[
|
||||||
directives: [],
|
'"use \\\nstrict";"use strict";',
|
||||||
non_directives: ["use strict", "use\nstrict", "use \nstrict", "use asm"]
|
[],
|
||||||
},
|
[ "use strict", "use\nstrict", "use \nstrict", "use asm" ]
|
||||||
{
|
],
|
||||||
input: '"use strict"\n"use asm"\n"use bar"\n',
|
[
|
||||||
directives: ["use strict", "use asm", "use bar"],
|
'"\\76";',
|
||||||
non_directives: ["use foo", "use\\x20strict"]
|
[],
|
||||||
},
|
[ ">", "\\76" ]
|
||||||
{
|
],
|
||||||
input: '"use \\\nstrict";"use strict";',
|
[
|
||||||
directives: [],
|
// no ; or newline
|
||||||
non_directives: ["use strict", "use\nstrict", "use \nstrict", "use asm"]
|
'"use strict"',
|
||||||
},
|
[],
|
||||||
{
|
[ "use strict", "use\nstrict", "use \nstrict", "use asm" ]
|
||||||
input: '"\\76";',
|
],
|
||||||
directives: [],
|
[
|
||||||
non_directives: [">", "\\76"]
|
';"use strict"',
|
||||||
},
|
[],
|
||||||
{
|
[ "use strict", "use\nstrict", "use \nstrict", "use asm" ]
|
||||||
input: '"use strict"', // no ; or newline
|
],
|
||||||
directives: [],
|
|
||||||
non_directives: ["use strict", "use\nstrict", "use \nstrict", "use asm"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
input: ';"use strict"',
|
|
||||||
directives: [],
|
|
||||||
non_directives: ["use strict", "use\nstrict", "use \nstrict", "use asm"]
|
|
||||||
},
|
|
||||||
// Duplicate above code but put it in a function
|
// Duplicate above code but put it in a function
|
||||||
{
|
[
|
||||||
input: 'function foo() {"use strict"\n',
|
'function foo() {"use strict"\n',
|
||||||
directives: ["use strict"],
|
[ "use strict" ],
|
||||||
non_directives: ["use asm"]
|
[ "use asm" ]
|
||||||
},
|
],
|
||||||
{
|
[
|
||||||
input: 'function foo() {"use\\\nstrict";',
|
'function foo() {"use\\\nstrict";',
|
||||||
directives: [],
|
[],
|
||||||
non_directives: ["use strict", "use\nstrict", "use \nstrict", "use asm"]
|
[ "use strict", "use\nstrict", "use \nstrict", "use asm" ]
|
||||||
},
|
],
|
||||||
{
|
[
|
||||||
input: 'function foo() {"use strict"\n"use asm"\n"use bar"\n',
|
'function foo() {"use strict"\n"use asm"\n"use bar"\n',
|
||||||
directives: ["use strict", "use asm", "use bar"],
|
[ "use strict", "use asm", "use bar" ],
|
||||||
non_directives: ["use foo", "use\\x20strict"]
|
[ "use foo", "use\\x20strict" ]
|
||||||
},
|
],
|
||||||
{
|
[
|
||||||
input: 'function foo() {"use \\\nstrict";"use strict";',
|
'function foo() {"use \\\nstrict";"use strict";',
|
||||||
directives: [],
|
[],
|
||||||
non_directives: ["use strict", "use\nstrict", "use \nstrict", "use asm"]
|
[ "use strict", "use\nstrict", "use \nstrict", "use asm" ]
|
||||||
},
|
],
|
||||||
{
|
[
|
||||||
input: 'var foo = function() {"\\76";',
|
'var foo = function() {"\\76";',
|
||||||
directives: [],
|
[],
|
||||||
non_directives: [">", "\\76"]
|
[ ">", "\\76" ]
|
||||||
},
|
],
|
||||||
{
|
[
|
||||||
input: 'var foo = function() {"use strict"', // no ; or newline
|
'var foo = function() {"use strict"', // no ; or newline
|
||||||
directives: [],
|
[],
|
||||||
non_directives: ["use strict", "use\nstrict", "use \nstrict", "use asm"]
|
[ "use strict", "use\nstrict", "use \nstrict", "use asm" ]
|
||||||
},
|
],
|
||||||
{
|
[
|
||||||
input: 'var foo = function() {;"use strict"',
|
'var foo = function() {;"use strict"',
|
||||||
directives: [],
|
[],
|
||||||
non_directives: ["use strict", "use\nstrict", "use \nstrict", "use asm"]
|
[ "use strict", "use\nstrict", "use \nstrict", "use asm" ]
|
||||||
},
|
],
|
||||||
// Special cases
|
// Special cases
|
||||||
{
|
[
|
||||||
input: '"1";"2";"3";"4";;"5"',
|
'"1";"2";"3";"4";;"5"',
|
||||||
directives: ["1", "2", "3", "4"],
|
[ "1", "2", "3", "4" ],
|
||||||
non_directives: ["5", "6", "use strict", "use asm"]
|
[ "5", "6", "use strict", "use asm" ]
|
||||||
},
|
],
|
||||||
{
|
[
|
||||||
input: 'if(1){"use strict";',
|
'if(1){"use strict";',
|
||||||
directives: [],
|
[],
|
||||||
non_directives: ["use strict", "use\nstrict", "use \nstrict", "use asm"]
|
[ "use strict", "use\nstrict", "use \nstrict", "use asm" ]
|
||||||
},
|
],
|
||||||
{
|
[
|
||||||
input: '"use strict";try{"use asm";',
|
'"use strict";try{"use asm";',
|
||||||
directives: ["use strict"],
|
[ "use strict" ],
|
||||||
non_directives: ["use\nstrict", "use \nstrict", "use asm"]
|
[ "use\nstrict", "use \nstrict", "use asm" ]
|
||||||
}
|
],
|
||||||
];
|
].forEach(function(test) {
|
||||||
|
var tokenizer = UglifyJS.tokenizer(test[0] + "]", "foo.js");
|
||||||
for (var i = 0; i < tests.length; i++) {
|
assert.throws(function() {
|
||||||
// Fail parser deliberately to get state at failure
|
UglifyJS.parse(tokenizer);
|
||||||
var tokenizer = UglifyJS.tokenizer(tests[i].input + "]", "foo.js");
|
}, function(e) {
|
||||||
|
return e instanceof UglifyJS.JS_Parse_Error
|
||||||
try {
|
&& e.message === "Unexpected token: punc (])"
|
||||||
var parser = UglifyJS.parse(tokenizer);
|
}, test[0]);
|
||||||
throw new Error("Expected parser to fail");
|
test[1].forEach(function(directive) {
|
||||||
} catch (e) {
|
assert.strictEqual(tokenizer.has_directive(directive), true, directive + " in " + test[0]);
|
||||||
assert.strictEqual(e instanceof UglifyJS.JS_Parse_Error, true);
|
});
|
||||||
assert.strictEqual(e.message, "Unexpected token: punc (])");
|
test[2].forEach(function(fake_directive) {
|
||||||
}
|
assert.strictEqual(tokenizer.has_directive(fake_directive), false, fake_directive + " in " + test[0]);
|
||||||
|
});
|
||||||
test_directive(tokenizer, tests[i]);
|
});
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should test EXPECT_DIRECTIVE RegExp", function() {
|
it("Should test EXPECT_DIRECTIVE RegExp", function() {
|
||||||
[
|
[
|
||||||
["", true],
|
[ "", true ],
|
||||||
["'test';", true],
|
[ "'test';", true ],
|
||||||
["'test';;", true],
|
[ "'test';;", true ],
|
||||||
["'tests';\n", true],
|
[ "'tests';\n", true ],
|
||||||
["'tests'", false],
|
[ "'tests'", false ],
|
||||||
["'tests'; \n\t", true],
|
[ "'tests'; \n\t", true ],
|
||||||
["'tests';\n\n", true],
|
[ "'tests';\n\n", true ],
|
||||||
["\n\n\"use strict\";\n\n", true]
|
[ "\n\n\"use strict\";\n\n", true ],
|
||||||
].forEach(function(test) {
|
].forEach(function(test) {
|
||||||
var out = UglifyJS.OutputStream();
|
var out = UglifyJS.OutputStream();
|
||||||
out.print(test[0]);
|
out.print(test[0]);
|
||||||
@@ -192,19 +173,33 @@ describe("Directives", function() {
|
|||||||
assert.strictEqual(out.get() === test[0] + ';""', test[1], test[0]);
|
assert.strictEqual(out.get() === test[0] + ';""', test[1], test[0]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should only print 2 semicolons spread over 2 lines in beautify mode", function() {
|
it("Should only print 2 semicolons spread over 2 lines in beautify mode", function() {
|
||||||
assert.strictEqual(
|
var result = UglifyJS.minify([
|
||||||
UglifyJS.minify(
|
'"use strict";',
|
||||||
'"use strict";\'use strict\';"use strict";"use strict";;\'use strict\';console.log(\'use strict\');',
|
"'use strict';",
|
||||||
{output: {beautify: true, quote_style: 3}, compress: false}
|
'"use strict";',
|
||||||
).code,
|
'"use strict";;',
|
||||||
'"use strict";\n\n\'use strict\';\n\n"use strict";\n\n"use strict";\n\n;\'use strict\';\n\nconsole.log(\'use strict\');'
|
"'use strict';",
|
||||||
);
|
"console.log('use strict');"
|
||||||
|
].join(""), {
|
||||||
|
compress: false,
|
||||||
|
output: {
|
||||||
|
beautify: true,
|
||||||
|
quote_style: 3
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (result.error) throw result.error;
|
||||||
|
assert.strictEqual(result.code, [
|
||||||
|
'"use strict";',
|
||||||
|
"'use strict';",
|
||||||
|
'"use strict";',
|
||||||
|
'"use strict";',
|
||||||
|
";'use strict';",
|
||||||
|
"console.log('use strict');"
|
||||||
|
].join("\n\n"));
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should not add double semicolons in non-scoped block statements to avoid strings becoming directives", function() {
|
it("Should not add double semicolons in non-scoped block statements to avoid strings becoming directives", function() {
|
||||||
var tests = [
|
[
|
||||||
[
|
[
|
||||||
'{"use\x20strict"}',
|
'{"use\x20strict"}',
|
||||||
'{"use strict"}'
|
'{"use strict"}'
|
||||||
@@ -221,26 +216,27 @@ describe("Directives", function() {
|
|||||||
'if(1){"use\x20strict"} else {"use strict"}',
|
'if(1){"use\x20strict"} else {"use strict"}',
|
||||||
'if(1){"use strict"}else{"use strict"}'
|
'if(1){"use strict"}else{"use strict"}'
|
||||||
]
|
]
|
||||||
];
|
].forEach(function(test) {
|
||||||
|
var result = UglifyJS.minify(test[0], {
|
||||||
for (var i = 0; i < tests.length; i++) {
|
compress: false,
|
||||||
assert.strictEqual(
|
mangle: false
|
||||||
UglifyJS.minify(tests[i][0], {compress: false, mangle: false}).code,
|
});
|
||||||
tests[i][1],
|
if (result.error) throw result.error;
|
||||||
tests[i][0]
|
assert.strictEqual(result.code, test[1], test[0]);
|
||||||
);
|
});
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should add double semicolon when relying on automatic semicolon insertion", function() {
|
it("Should add double semicolon when relying on automatic semicolon insertion", function() {
|
||||||
var code = UglifyJS.minify('"use strict";"use\\x20strict";',
|
var result = UglifyJS.minify('"use strict";"use\\x20strict";', {
|
||||||
{output: {semicolons: false}, compress: false}
|
compress: false,
|
||||||
).code;
|
output: {
|
||||||
assert.strictEqual(code, '"use strict";;"use strict"\n');
|
semicolons: false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (result.error) throw result.error;
|
||||||
|
assert.strictEqual(result.code, '"use strict";;"use strict"\n');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should check quote style of directives", function() {
|
it("Should check quote style of directives", function() {
|
||||||
var tests = [
|
[
|
||||||
// 0. Prefer double quotes, unless string contains more double quotes than single quotes
|
// 0. Prefer double quotes, unless string contains more double quotes than single quotes
|
||||||
[
|
[
|
||||||
'"testing something";',
|
'"testing something";',
|
||||||
@@ -337,45 +333,53 @@ describe("Directives", function() {
|
|||||||
3,
|
3,
|
||||||
"'\"use strict\"';",
|
"'\"use strict\"';",
|
||||||
],
|
],
|
||||||
];
|
].forEach(function(test) {
|
||||||
for (var i = 0; i < tests.length; i++) {
|
var result = UglifyJS.minify(test[0], {
|
||||||
assert.strictEqual(
|
compress: false,
|
||||||
UglifyJS.minify(tests[i][0], {output:{quote_style: tests[i][1]}, compress: false}).code,
|
output: {
|
||||||
tests[i][2],
|
quote_style: test[1]
|
||||||
tests[i][0] + " using mode " + tests[i][1]
|
}
|
||||||
);
|
});
|
||||||
}
|
if (result.error) throw result.error;
|
||||||
|
assert.strictEqual(result.code, test[2], test[0] + " using mode " + test[1]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
it("Should be able to compress without side effects", function() {
|
it("Should be able to compress without side effects", function() {
|
||||||
// NOTE: the "use asm" directive disables any optimisation after being defined
|
[
|
||||||
var tests = [
|
|
||||||
[
|
[
|
||||||
'"use strict";"use strict";"use strict";"use foo";"use strict";;"use sloppy";doSomething("foo");',
|
'"use strict";"use strict";"use strict";"use foo";"use strict";;"use sloppy";doSomething("foo");',
|
||||||
'"use strict";"use foo";doSomething("foo");',
|
'"use strict";doSomething("foo");'
|
||||||
'function f(){ "use strict" }',
|
|
||||||
'function f(){ "use asm" }',
|
|
||||||
'function f(){ "use nondirective" }',
|
|
||||||
'function f(){ ;"use strict" }',
|
|
||||||
'function f(){ "use \n"; }',
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
// Nothing gets optimised in the compressor because "use asm" is the first statement
|
// Nothing gets optimised in the compressor because "use asm" is the first statement
|
||||||
'"use asm";"use\\x20strict";1+1;',
|
'"use asm";"use\\x20strict";1+1;',
|
||||||
'"use asm";;"use strict";1+1;', // Yet, the parser noticed that "use strict" wasn't a directive
|
// Yet, the parser noticed that "use strict" wasn't a directive
|
||||||
'function f(){"use strict"}',
|
'"use asm";;"use strict";1+1;',
|
||||||
'function f(){"use asm"}',
|
],
|
||||||
'function f(){"use nondirective"}',
|
[
|
||||||
'function f(){}',
|
'function f(){ "use strict" }',
|
||||||
'function f(){}',
|
'function f(){}'
|
||||||
]
|
],
|
||||||
];
|
[
|
||||||
|
'function f(){ "use asm" }',
|
||||||
for (var i = 0; i < tests.length; i++) {
|
'function f(){"use asm"}'
|
||||||
assert.strictEqual(
|
],
|
||||||
UglifyJS.minify(tests[i][0]).code,
|
[
|
||||||
tests[i][1],
|
'function f(){ "use nondirective" }',
|
||||||
tests[i][0]
|
'function f(){}'
|
||||||
);
|
],
|
||||||
}
|
[
|
||||||
|
'function f(){ ;"use strict" }',
|
||||||
|
'function f(){}'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'function f(){ "use \\n"; }',
|
||||||
|
'function f(){}'
|
||||||
|
],
|
||||||
|
].forEach(function(test) {
|
||||||
|
var result = UglifyJS.minify(test[0]);
|
||||||
|
if (result.error) throw result.error;
|
||||||
|
assert.strictEqual(result.code, test[1], test[0]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ describe("bin/uglifyjs with input file globs", function() {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it("should throw with non-matching glob string", function(done) {
|
it("Should throw with non-matching glob string", function(done) {
|
||||||
var command = uglifyjscmd + ' "test/input/issue-1242/blah.*"';
|
var command = uglifyjscmd + ' "test/input/issue-1242/blah.*"';
|
||||||
|
|
||||||
exec(command, function(err, stdout, stderr) {
|
exec(command, function(err, stdout, stderr) {
|
||||||
@@ -53,7 +53,7 @@ describe("bin/uglifyjs with input file globs", function() {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it("should handle special characters in glob string", function(done) {
|
it("Should handle special characters in glob string", function(done) {
|
||||||
var command = uglifyjscmd + ' "test/input/issue-1632/^{*}[???](*)+$.??" -cm';
|
var command = uglifyjscmd + ' "test/input/issue-1632/^{*}[???](*)+$.??" -cm';
|
||||||
|
|
||||||
exec(command, function(err, stdout) {
|
exec(command, function(err, stdout) {
|
||||||
@@ -63,7 +63,7 @@ describe("bin/uglifyjs with input file globs", function() {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it("should handle array of glob strings - matching and otherwise", function(done) {
|
it("Should handle array of glob strings - matching and otherwise", function(done) {
|
||||||
var dir = "test/input/issue-1242";
|
var dir = "test/input/issue-1242";
|
||||||
var command = uglifyjscmd + ' "' + [
|
var command = uglifyjscmd + ' "' + [
|
||||||
path.join(dir, "b*.es5"),
|
path.join(dir, "b*.es5"),
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ describe("minify", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("#__PURE__", function() {
|
describe("#__PURE__", function() {
|
||||||
it("should drop #__PURE__ hint after use", function() {
|
it("Should drop #__PURE__ hint after use", function() {
|
||||||
var result = UglifyJS.minify('//@__PURE__ comment1 #__PURE__ comment2\n foo(), bar();', {
|
var result = UglifyJS.minify('//@__PURE__ comment1 #__PURE__ comment2\n foo(), bar();', {
|
||||||
output: {
|
output: {
|
||||||
comments: "all",
|
comments: "all",
|
||||||
@@ -197,7 +197,7 @@ describe("minify", function() {
|
|||||||
var code = result.code;
|
var code = result.code;
|
||||||
assert.strictEqual(code, "// comment1 comment2\nbar();");
|
assert.strictEqual(code, "// comment1 comment2\nbar();");
|
||||||
});
|
});
|
||||||
it("should drop #__PURE__ hint if function is retained", function() {
|
it("Should drop #__PURE__ hint if function is retained", function() {
|
||||||
var result = UglifyJS.minify("var a = /*#__PURE__*/(function(){ foo(); })();", {
|
var result = UglifyJS.minify("var a = /*#__PURE__*/(function(){ foo(); })();", {
|
||||||
output: {
|
output: {
|
||||||
comments: "all",
|
comments: "all",
|
||||||
@@ -210,7 +210,7 @@ describe("minify", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("JS_Parse_Error", function() {
|
describe("JS_Parse_Error", function() {
|
||||||
it("should return syntax error", function() {
|
it("Should return syntax error", function() {
|
||||||
var result = UglifyJS.minify("function f(a{}");
|
var result = UglifyJS.minify("function f(a{}");
|
||||||
var err = result.error;
|
var err = result.error;
|
||||||
assert.ok(err instanceof Error);
|
assert.ok(err instanceof Error);
|
||||||
@@ -219,7 +219,7 @@ describe("minify", function() {
|
|||||||
assert.strictEqual(err.line, 1);
|
assert.strictEqual(err.line, 1);
|
||||||
assert.strictEqual(err.col, 12);
|
assert.strictEqual(err.col, 12);
|
||||||
});
|
});
|
||||||
it("should reject duplicated label name", function() {
|
it("Should reject duplicated label name", function() {
|
||||||
var result = UglifyJS.minify("L:{L:{}}");
|
var result = UglifyJS.minify("L:{L:{}}");
|
||||||
var err = result.error;
|
var err = result.error;
|
||||||
assert.ok(err instanceof Error);
|
assert.ok(err instanceof Error);
|
||||||
@@ -231,7 +231,7 @@ describe("minify", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("global_defs", function() {
|
describe("global_defs", function() {
|
||||||
it("should throw for non-trivial expressions", function() {
|
it("Should throw for non-trivial expressions", function() {
|
||||||
var result = UglifyJS.minify("alert(42);", {
|
var result = UglifyJS.minify("alert(42);", {
|
||||||
compress: {
|
compress: {
|
||||||
global_defs: {
|
global_defs: {
|
||||||
@@ -243,7 +243,7 @@ describe("minify", function() {
|
|||||||
assert.ok(err instanceof Error);
|
assert.ok(err instanceof Error);
|
||||||
assert.strictEqual(err.stack.split(/\n/)[0], "SyntaxError: Unexpected token: keyword (debugger)");
|
assert.strictEqual(err.stack.split(/\n/)[0], "SyntaxError: Unexpected token: keyword (debugger)");
|
||||||
});
|
});
|
||||||
it("should skip inherited properties", function() {
|
it("Should skip inherited properties", function() {
|
||||||
var foo = Object.create({ skip: this });
|
var foo = Object.create({ skip: this });
|
||||||
foo.bar = 42;
|
foo.bar = 42;
|
||||||
var result = UglifyJS.minify("alert(FOO);", {
|
var result = UglifyJS.minify("alert(FOO);", {
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ describe("sourcemaps", function() {
|
|||||||
assert.strictEqual(map.version, 3);
|
assert.strictEqual(map.version, 3);
|
||||||
assert.deepEqual(map.names, [ "x" ]);
|
assert.deepEqual(map.names, [ "x" ]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should give correct names", function() {
|
it("Should give correct names", function() {
|
||||||
var map = source_map([
|
var map = source_map([
|
||||||
"({",
|
"({",
|
||||||
@@ -67,7 +66,6 @@ describe("sourcemaps", function() {
|
|||||||
].join("\n"));
|
].join("\n"));
|
||||||
assert.deepEqual(map.names, [ "enabled", "x" ]);
|
assert.deepEqual(map.names, [ "enabled", "x" ]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should mark array/object literals", function() {
|
it("Should mark array/object literals", function() {
|
||||||
var result = UglifyJS.minify([
|
var result = UglifyJS.minify([
|
||||||
"var obj = {};",
|
"var obj = {};",
|
||||||
@@ -80,7 +78,6 @@ describe("sourcemaps", function() {
|
|||||||
assert.strictEqual(result.code, "({}).wat([]);");
|
assert.strictEqual(result.code, "({}).wat([]);");
|
||||||
assert.strictEqual(result.map, '{"version":3,"sources":["0"],"names":["wat"],"mappings":"CAAU,IACNA,IAAI"}');
|
assert.strictEqual(result.map, '{"version":3,"sources":["0"],"names":["wat"],"mappings":"CAAU,IACNA,IAAI"}');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should give correct sourceRoot", function() {
|
it("Should give correct sourceRoot", function() {
|
||||||
var code = "console.log(42);";
|
var code = "console.log(42);";
|
||||||
var result = UglifyJS.minify(code, {
|
var result = UglifyJS.minify(code, {
|
||||||
@@ -212,6 +209,9 @@ describe("sourcemaps", function() {
|
|||||||
});
|
});
|
||||||
it("Should work with max_line_len", function() {
|
it("Should work with max_line_len", function() {
|
||||||
var result = UglifyJS.minify(read("./test/input/issue-505/input.js"), {
|
var result = UglifyJS.minify(read("./test/input/issue-505/input.js"), {
|
||||||
|
compress: {
|
||||||
|
directives: false,
|
||||||
|
},
|
||||||
output: {
|
output: {
|
||||||
max_line_len: 20
|
max_line_len: 20
|
||||||
},
|
},
|
||||||
@@ -261,7 +261,6 @@ describe("sourcemaps", function() {
|
|||||||
var map = prepare_map(orig);
|
var map = prepare_map(orig);
|
||||||
assert.equal(map.sourceContentFor("index.js"), orig.sourcesContent[0]);
|
assert.equal(map.sourceContentFor("index.js"), orig.sourcesContent[0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should copy sourcesContent if sources are relative", function() {
|
it("Should copy sourcesContent if sources are relative", function() {
|
||||||
var relativeMap = get_map();
|
var relativeMap = get_map();
|
||||||
relativeMap.sources = ['./index.js'];
|
relativeMap.sources = ['./index.js'];
|
||||||
@@ -270,7 +269,6 @@ describe("sourcemaps", function() {
|
|||||||
assert.equal(map.sourcesContent.length, 1);
|
assert.equal(map.sourcesContent.length, 1);
|
||||||
assert.equal(map.sourceContentFor("index.js"), relativeMap.sourcesContent[0]);
|
assert.equal(map.sourceContentFor("index.js"), relativeMap.sourcesContent[0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should not have invalid mappings from inputSourceMap", function() {
|
it("Should not have invalid mappings from inputSourceMap", function() {
|
||||||
var map = prepare_map(get_map());
|
var map = prepare_map(get_map());
|
||||||
// The original source has only 2 lines, check that mappings don't have more lines
|
// The original source has only 2 lines, check that mappings don't have more lines
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ var exec = require("child_process").exec;
|
|||||||
var UglifyJS = require("../..");
|
var UglifyJS = require("../..");
|
||||||
|
|
||||||
describe("spidermonkey export/import sanity test", function() {
|
describe("spidermonkey export/import sanity test", function() {
|
||||||
it("should produce a functional build when using --self with spidermonkey", function(done) {
|
it("Should produce a functional build when using --self with spidermonkey", function(done) {
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
|
|
||||||
var uglifyjs = '"' + process.argv[0] + '" bin/uglifyjs';
|
var uglifyjs = '"' + process.argv[0] + '" bin/uglifyjs';
|
||||||
@@ -23,7 +23,7 @@ describe("spidermonkey export/import sanity test", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should not add unnecessary escape slashes to regexps", function() {
|
it("Should not add unnecessary escape slashes to regexps", function() {
|
||||||
var input = "/[\\\\/]/;";
|
var input = "/[\\\\/]/;";
|
||||||
var ast = UglifyJS.parse(input).to_mozilla_ast();
|
var ast = UglifyJS.parse(input).to_mozilla_ast();
|
||||||
assert.equal(
|
assert.equal(
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ exports.run_code = function(code, reuse) {
|
|||||||
return ex;
|
return ex;
|
||||||
} finally {
|
} finally {
|
||||||
process.stdout.write = original_write;
|
process.stdout.write = original_write;
|
||||||
if (!reuse || /prototype/.test(code)) {
|
if (!reuse || code.indexOf(".prototype") >= 0) {
|
||||||
context = null;
|
context = null;
|
||||||
} else for (var key in context) {
|
} else for (var key in context) {
|
||||||
delete context[key];
|
delete context[key];
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
var fs = require("fs");
|
var fs = require("fs");
|
||||||
|
|
||||||
var UglifyJS = exports;
|
exports.FILES = [
|
||||||
var FILES = UglifyJS.FILES = [
|
|
||||||
"../lib/utils.js",
|
"../lib/utils.js",
|
||||||
"../lib/ast.js",
|
"../lib/ast.js",
|
||||||
"../lib/parse.js",
|
"../lib/parse.js",
|
||||||
@@ -19,15 +18,12 @@ var FILES = UglifyJS.FILES = [
|
|||||||
});
|
});
|
||||||
|
|
||||||
new Function("MOZ_SourceMap", "exports", function() {
|
new Function("MOZ_SourceMap", "exports", function() {
|
||||||
var code = FILES.map(function(file) {
|
var code = exports.FILES.map(function(file) {
|
||||||
return fs.readFileSync(file, "utf8");
|
return fs.readFileSync(file, "utf8");
|
||||||
});
|
});
|
||||||
code.push("exports.describe_ast = " + describe_ast.toString());
|
code.push("exports.describe_ast = " + describe_ast.toString());
|
||||||
return code.join("\n\n");
|
return code.join("\n\n");
|
||||||
}())(
|
}())(require("source-map"), exports);
|
||||||
require("source-map"),
|
|
||||||
UglifyJS
|
|
||||||
);
|
|
||||||
|
|
||||||
function describe_ast() {
|
function describe_ast() {
|
||||||
var out = OutputStream({ beautify: true });
|
var out = OutputStream({ beautify: true });
|
||||||
@@ -65,11 +61,11 @@ function describe_ast() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function infer_options(options) {
|
function infer_options(options) {
|
||||||
var result = UglifyJS.minify("", options);
|
var result = exports.minify("", options);
|
||||||
return result.error && result.error.defs;
|
return result.error && result.error.defs;
|
||||||
}
|
}
|
||||||
|
|
||||||
UglifyJS.default_options = function() {
|
exports.default_options = function() {
|
||||||
var defs = {};
|
var defs = {};
|
||||||
Object.keys(infer_options({ 0: 0 })).forEach(function(component) {
|
Object.keys(infer_options({ 0: 0 })).forEach(function(component) {
|
||||||
var options = {};
|
var options = {};
|
||||||
|
|||||||
Reference in New Issue
Block a user