Compare commits
67 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6de708af37 | ||
|
|
b9b2a4f7f8 | ||
|
|
b46c7944c6 | ||
|
|
866cd4a975 | ||
|
|
e24b255350 | ||
|
|
efed55f42d | ||
|
|
8c2b76eff9 | ||
|
|
b636e97e3b | ||
|
|
35d7f316ef | ||
|
|
43807c26fb | ||
|
|
774feeadb8 | ||
|
|
d96c59f9e6 | ||
|
|
dfd6418878 | ||
|
|
87e8aca245 | ||
|
|
14e1311bdf | ||
|
|
ff3c2ed7a2 | ||
|
|
f8602aca96 | ||
|
|
9a58270b70 | ||
|
|
f639a30bd2 | ||
|
|
082013c20f | ||
|
|
c7d2837184 | ||
|
|
caaa753861 | ||
|
|
4b949f6686 | ||
|
|
e9d9d5a9d2 | ||
|
|
f473b4db38 | ||
|
|
b0df5d7b55 | ||
|
|
be8c75bae1 | ||
|
|
58bea676ac | ||
|
|
9aab1f3661 | ||
|
|
10a1523ee6 | ||
|
|
d46eb69320 | ||
|
|
3a3666a94e | ||
|
|
2f568b9357 | ||
|
|
c94624f36c | ||
|
|
dec359ce58 | ||
|
|
1a054e869e | ||
|
|
7889192cae | ||
|
|
f7841bc8b8 | ||
|
|
aa6eb0d5be | ||
|
|
87a7426598 | ||
|
|
8d0422b6f3 | ||
|
|
e7ce1051fe | ||
|
|
80d5f23fee | ||
|
|
d51caaf358 | ||
|
|
835d130ccf | ||
|
|
e1013bd56d | ||
|
|
13d41778b3 | ||
|
|
bab416465f | ||
|
|
29a1e71705 | ||
|
|
7b2eb4b5ff | ||
|
|
343bf6d7a5 | ||
|
|
ba42cbad3f | ||
|
|
86406e71ec | ||
|
|
9e927ecc9a | ||
|
|
509896a410 | ||
|
|
7fe7c39a01 | ||
|
|
2c5e23506b | ||
|
|
07f35ea2c9 | ||
|
|
57a9519c3d | ||
|
|
9e4c4c995c | ||
|
|
d11c82f8ca | ||
|
|
bc27966a19 | ||
|
|
8f39491e96 | ||
|
|
065c50ebde | ||
|
|
d2e7c4af20 | ||
|
|
033d8d9405 | ||
|
|
b0799105c2 |
10
README.md
10
README.md
@@ -115,6 +115,7 @@ a double dash to prevent input files being used as option arguments:
|
|||||||
Equivalent to setting `ie: true` in `minify()`
|
Equivalent to setting `ie: true` in `minify()`
|
||||||
for `compress`, `mangle` and `output` options.
|
for `compress`, `mangle` and `output` options.
|
||||||
By default UglifyJS will not try to be IE-proof.
|
By default UglifyJS will not try to be IE-proof.
|
||||||
|
--keep-fargs Do not mangle/drop function arguments.
|
||||||
--keep-fnames Do not mangle/drop function names. Useful for
|
--keep-fnames Do not mangle/drop function names. Useful for
|
||||||
code relying on Function.prototype.name.
|
code relying on Function.prototype.name.
|
||||||
--name-cache <file> File to hold mangled name mappings.
|
--name-cache <file> File to hold mangled name mappings.
|
||||||
@@ -504,6 +505,9 @@ if (result.error) throw result.error;
|
|||||||
|
|
||||||
- `ie` (default: `false`) — enable workarounds for Internet Explorer bugs.
|
- `ie` (default: `false`) — enable workarounds for Internet Explorer bugs.
|
||||||
|
|
||||||
|
- `keep_fargs` (default: `false`) — pass `true` to prevent discarding or mangling
|
||||||
|
of function arguments.
|
||||||
|
|
||||||
- `keep_fnames` (default: `false`) — pass `true` to prevent discarding or mangling
|
- `keep_fnames` (default: `false`) — pass `true` to prevent discarding or mangling
|
||||||
of function names. Useful for code relying on `Function.prototype.name`.
|
of function names. Useful for code relying on `Function.prototype.name`.
|
||||||
|
|
||||||
@@ -707,7 +711,8 @@ to be `false` and all symbol names will be omitted.
|
|||||||
- `1` — inline simple functions
|
- `1` — inline simple functions
|
||||||
- `2` — inline functions with arguments
|
- `2` — inline functions with arguments
|
||||||
- `3` — inline functions with arguments and variables
|
- `3` — inline functions with arguments and variables
|
||||||
- `true` — same as `3`
|
- `4` — inline functions with arguments, variables and statements
|
||||||
|
- `true` — same as `4`
|
||||||
|
|
||||||
- `join_vars` (default: `true`) — join consecutive `var` statements
|
- `join_vars` (default: `true`) — join consecutive `var` statements
|
||||||
|
|
||||||
@@ -867,6 +872,9 @@ UglifyJS.minify(code, { mangle: { toplevel: true } }).code;
|
|||||||
- `debug` (default: `false`) — Mangle names with the original name still present.
|
- `debug` (default: `false`) — Mangle names with the original name still present.
|
||||||
Pass an empty string `""` to enable, or a non-empty string to set the debug suffix.
|
Pass an empty string `""` to enable, or a non-empty string to set the debug suffix.
|
||||||
|
|
||||||
|
- `keep_fargs` (default: `false`) — Use `true` to prevent mangling of function
|
||||||
|
arguments.
|
||||||
|
|
||||||
- `keep_quoted` (default: `false`) — Only mangle unquoted property names.
|
- `keep_quoted` (default: `false`) — Only mangle unquoted property names.
|
||||||
|
|
||||||
- `regex` (default: `null`) — Pass a RegExp literal to only mangle property
|
- `regex` (default: `null`) — Pass a RegExp literal to only mangle property
|
||||||
|
|||||||
19
bin/uglifyjs
19
bin/uglifyjs
@@ -10,7 +10,9 @@ var info = require("../package.json");
|
|||||||
var path = require("path");
|
var path = require("path");
|
||||||
var UglifyJS = require("../tools/node");
|
var UglifyJS = require("../tools/node");
|
||||||
|
|
||||||
var skip_keys = [ "cname", "fixed", "inlined", "parent_scope", "scope", "uses_eval", "uses_with" ];
|
var skip_keys = [ "cname", "fixed", "in_arg", "inlined", "length_read", "parent_scope", "redef", "scope", "unused" ];
|
||||||
|
var truthy_keys = [ "optional", "pure", "terminal", "uses_arguments", "uses_eval", "uses_with" ];
|
||||||
|
|
||||||
var files = {};
|
var files = {};
|
||||||
var options = {};
|
var options = {};
|
||||||
var short_forms = {
|
var short_forms = {
|
||||||
@@ -70,6 +72,7 @@ function process_option(name, no_value) {
|
|||||||
} else {
|
} else {
|
||||||
if (padding.length < name.length) padding = Array(name.length + 1).join(" ");
|
if (padding.length < name.length) padding = Array(name.length + 1).join(" ");
|
||||||
toplevels.push([ {
|
toplevels.push([ {
|
||||||
|
keep_fargs: "keep-fargs",
|
||||||
keep_fnames: "keep-fnames",
|
keep_fnames: "keep-fnames",
|
||||||
nameCache: "name-cache",
|
nameCache: "name-cache",
|
||||||
}[name] || name, option ]);
|
}[name] || name, option ]);
|
||||||
@@ -102,6 +105,7 @@ function process_option(name, no_value) {
|
|||||||
" -d, --define <expr>[=value] Global definitions.",
|
" -d, --define <expr>[=value] Global definitions.",
|
||||||
" -e, --enclose [arg[,...][:value[,...]]] Embed everything in a big function, with configurable argument(s) & value(s).",
|
" -e, --enclose [arg[,...][:value[,...]]] Embed everything in a big function, with configurable argument(s) & value(s).",
|
||||||
" --ie Support non-standard Internet Explorer.",
|
" --ie Support non-standard Internet Explorer.",
|
||||||
|
" --keep-fargs Do not mangle/drop function arguments.",
|
||||||
" --keep-fnames Do not mangle/drop function names. Useful for code relying on Function.prototype.name.",
|
" --keep-fnames Do not mangle/drop function names. Useful for code relying on Function.prototype.name.",
|
||||||
" --name-cache <file> File to hold mangled name mappings.",
|
" --name-cache <file> File to hold mangled name mappings.",
|
||||||
" --rename Force symbol expansion.",
|
" --rename Force symbol expansion.",
|
||||||
@@ -158,6 +162,9 @@ function process_option(name, no_value) {
|
|||||||
case "no-annotations":
|
case "no-annotations":
|
||||||
options.annotations = false;
|
options.annotations = false;
|
||||||
break;
|
break;
|
||||||
|
case "keep-fargs":
|
||||||
|
options.keep_fargs = true;
|
||||||
|
break;
|
||||||
case "keep-fnames":
|
case "keep-fnames":
|
||||||
options.keep_fnames = true;
|
options.keep_fnames = true;
|
||||||
break;
|
break;
|
||||||
@@ -430,7 +437,7 @@ function run() {
|
|||||||
case "thedef":
|
case "thedef":
|
||||||
return symdef(value);
|
return symdef(value);
|
||||||
}
|
}
|
||||||
if (skip_key(key)) return;
|
if (skip_property(key, value)) return;
|
||||||
if (value instanceof UglifyJS.AST_Token) return;
|
if (value instanceof UglifyJS.AST_Token) return;
|
||||||
if (value instanceof UglifyJS.Dictionary) return;
|
if (value instanceof UglifyJS.Dictionary) return;
|
||||||
if (value instanceof UglifyJS.AST_Node) {
|
if (value instanceof UglifyJS.AST_Node) {
|
||||||
@@ -519,7 +526,7 @@ function read_file(path, default_value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function parse_js(value, options, flag) {
|
function parse_js(value, options, flag) {
|
||||||
if (!options || typeof options != "object") options = {};
|
if (!options || typeof options != "object") options = Object.create(null);
|
||||||
if (typeof value == "string") try {
|
if (typeof value == "string") try {
|
||||||
UglifyJS.parse(value, {
|
UglifyJS.parse(value, {
|
||||||
expression: true
|
expression: true
|
||||||
@@ -559,8 +566,10 @@ function parse_js(value, options, flag) {
|
|||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
function skip_key(key) {
|
function skip_property(key, value) {
|
||||||
return skip_keys.indexOf(key) >= 0;
|
return skip_keys.indexOf(key) >= 0
|
||||||
|
// only skip truthy_keys if their value is falsy
|
||||||
|
|| truthy_keys.indexOf(key) >= 0 && !value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function symdef(def) {
|
function symdef(def) {
|
||||||
|
|||||||
81
lib/ast.js
81
lib/ast.js
@@ -50,6 +50,8 @@ function DEFNODE(type, props, methods, base) {
|
|||||||
if (base && base.PROPS) props = props.concat(base.PROPS);
|
if (base && base.PROPS) props = props.concat(base.PROPS);
|
||||||
var code = [
|
var code = [
|
||||||
"return function AST_", type, "(props){",
|
"return function AST_", type, "(props){",
|
||||||
|
// not essential, but speeds up compress by a few percent
|
||||||
|
"this._bits=0;",
|
||||||
"if(props){",
|
"if(props){",
|
||||||
];
|
];
|
||||||
props.forEach(function(prop) {
|
props.forEach(function(prop) {
|
||||||
@@ -135,6 +137,53 @@ var AST_Node = DEFNODE("Node", "start end", {
|
|||||||
},
|
},
|
||||||
}, null);
|
}, null);
|
||||||
|
|
||||||
|
DEF_BITPROPS(AST_Node, [
|
||||||
|
"_optimized",
|
||||||
|
"_squeezed",
|
||||||
|
// AST_Call
|
||||||
|
"call_only",
|
||||||
|
// AST_Lambda
|
||||||
|
"collapse_scanning",
|
||||||
|
// AST_SymbolRef
|
||||||
|
"defined",
|
||||||
|
"evaluating",
|
||||||
|
"falsy",
|
||||||
|
// AST_SymbolRef
|
||||||
|
"in_arg",
|
||||||
|
// AST_Return
|
||||||
|
"in_bool",
|
||||||
|
// AST_SymbolRef
|
||||||
|
"is_undefined",
|
||||||
|
// AST_LambdaExpression
|
||||||
|
// AST_LambdaDefinition
|
||||||
|
"inlined",
|
||||||
|
// AST_Lambda
|
||||||
|
"length_read",
|
||||||
|
// AST_Yield
|
||||||
|
"nested",
|
||||||
|
// AST_Lambda
|
||||||
|
"new",
|
||||||
|
// AST_Call
|
||||||
|
// AST_PropAccess
|
||||||
|
"optional",
|
||||||
|
// AST_ClassProperty
|
||||||
|
"private",
|
||||||
|
// AST_Call
|
||||||
|
"pure",
|
||||||
|
// AST_Assign
|
||||||
|
"redundant",
|
||||||
|
// AST_ClassProperty
|
||||||
|
"static",
|
||||||
|
// AST_Call
|
||||||
|
// AST_PropAccess
|
||||||
|
"terminal",
|
||||||
|
"truthy",
|
||||||
|
// AST_Scope
|
||||||
|
"uses_eval",
|
||||||
|
// AST_Scope
|
||||||
|
"uses_with",
|
||||||
|
]);
|
||||||
|
|
||||||
(AST_Node.log_function = function(fn, verbose) {
|
(AST_Node.log_function = function(fn, verbose) {
|
||||||
if (typeof fn != "function") {
|
if (typeof fn != "function") {
|
||||||
AST_Node.info = AST_Node.warn = noop;
|
AST_Node.info = AST_Node.warn = noop;
|
||||||
@@ -253,7 +302,7 @@ var AST_SimpleStatement = DEFNODE("SimpleStatement", "body", {
|
|||||||
},
|
},
|
||||||
}, AST_Statement);
|
}, AST_Statement);
|
||||||
|
|
||||||
var AST_BlockScope = DEFNODE("BlockScope", "enclosed functions make_def parent_scope variables", {
|
var AST_BlockScope = DEFNODE("BlockScope", "_var_names enclosed functions make_def parent_scope variables", {
|
||||||
$documentation: "Base class for all statements introducing a lexical scope",
|
$documentation: "Base class for all statements introducing a lexical scope",
|
||||||
$propdoc: {
|
$propdoc: {
|
||||||
enclosed: "[SymbolDef*/S] a list of all symbol definitions that are accessed from this scope or any subscopes",
|
enclosed: "[SymbolDef*/S] a list of all symbol definitions that are accessed from this scope or any subscopes",
|
||||||
@@ -484,7 +533,7 @@ var AST_With = DEFNODE("With", "expression", {
|
|||||||
|
|
||||||
/* -----[ scope and functions ]----- */
|
/* -----[ scope and functions ]----- */
|
||||||
|
|
||||||
var AST_Scope = DEFNODE("Scope", "uses_eval uses_with", {
|
var AST_Scope = DEFNODE("Scope", "fn_defs may_call_this uses_eval uses_with", {
|
||||||
$documentation: "Base class for all statements introducing a lexical scope",
|
$documentation: "Base class for all statements introducing a lexical scope",
|
||||||
$propdoc: {
|
$propdoc: {
|
||||||
uses_eval: "[boolean/S] tells whether this scope contains a direct call to the global `eval`",
|
uses_eval: "[boolean/S] tells whether this scope contains a direct call to the global `eval`",
|
||||||
@@ -543,13 +592,13 @@ var AST_Toplevel = DEFNODE("Toplevel", "globals", {
|
|||||||
}
|
}
|
||||||
}, AST_Scope);
|
}, AST_Scope);
|
||||||
|
|
||||||
var AST_Lambda = DEFNODE("Lambda", "argnames length_read rest uses_arguments", {
|
var AST_Lambda = DEFNODE("Lambda", "argnames length_read rest safe_ids uses_arguments", {
|
||||||
$documentation: "Base class for functions",
|
$documentation: "Base class for functions",
|
||||||
$propdoc: {
|
$propdoc: {
|
||||||
argnames: "[(AST_DefaultValue|AST_Destructured|AST_SymbolFunarg)*] array of function arguments and/or destructured literals",
|
argnames: "[(AST_DefaultValue|AST_Destructured|AST_SymbolFunarg)*] array of function arguments and/or destructured literals",
|
||||||
length_read: "[boolean/S] whether length property of this function is accessed",
|
length_read: "[boolean/S] whether length property of this function is accessed",
|
||||||
rest: "[(AST_Destructured|AST_SymbolFunarg)?] rest parameter, or null if absent",
|
rest: "[(AST_Destructured|AST_SymbolFunarg)?] rest parameter, or null if absent",
|
||||||
uses_arguments: "[boolean/S] whether this function accesses the arguments array",
|
uses_arguments: "[boolean|number/S] whether this function accesses the arguments array",
|
||||||
},
|
},
|
||||||
each_argname: function(visit) {
|
each_argname: function(visit) {
|
||||||
var tw = new TreeWalker(function(node) {
|
var tw = new TreeWalker(function(node) {
|
||||||
@@ -1295,7 +1344,7 @@ var AST_Call = DEFNODE("Call", "args expression optional pure terminal", {
|
|||||||
args: "[AST_Node*] array of arguments",
|
args: "[AST_Node*] array of arguments",
|
||||||
expression: "[AST_Node] expression to invoke as function",
|
expression: "[AST_Node] expression to invoke as function",
|
||||||
optional: "[boolean] whether the expression is optional chaining",
|
optional: "[boolean] whether the expression is optional chaining",
|
||||||
pure: "[string/S] marker for side-effect-free call expression",
|
pure: "[boolean/S] marker for side-effect-free call expression",
|
||||||
terminal: "[boolean] whether the chain has ended",
|
terminal: "[boolean] whether the chain has ended",
|
||||||
},
|
},
|
||||||
walk: function(visitor) {
|
walk: function(visitor) {
|
||||||
@@ -1489,6 +1538,12 @@ var AST_Assign = DEFNODE("Assign", null, {
|
|||||||
throw new Error("left must be assignable: " + node.TYPE);
|
throw new Error("left must be assignable: " + node.TYPE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else if (!(this.left instanceof AST_Infinity
|
||||||
|
|| this.left instanceof AST_NaN
|
||||||
|
|| this.left instanceof AST_PropAccess && !this.left.optional
|
||||||
|
|| this.left instanceof AST_SymbolRef
|
||||||
|
|| this.left instanceof AST_Undefined)) {
|
||||||
|
throw new Error("left must be assignable");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}, AST_Binary);
|
}, AST_Binary);
|
||||||
@@ -1747,7 +1802,7 @@ var AST_SymbolVar = DEFNODE("SymbolVar", null, {
|
|||||||
$documentation: "Symbol defining a variable",
|
$documentation: "Symbol defining a variable",
|
||||||
}, AST_SymbolDeclaration);
|
}, AST_SymbolDeclaration);
|
||||||
|
|
||||||
var AST_SymbolFunarg = DEFNODE("SymbolFunarg", null, {
|
var AST_SymbolFunarg = DEFNODE("SymbolFunarg", "unused", {
|
||||||
$documentation: "Symbol naming a function argument",
|
$documentation: "Symbol naming a function argument",
|
||||||
}, AST_SymbolVar);
|
}, AST_SymbolVar);
|
||||||
|
|
||||||
@@ -1923,27 +1978,27 @@ var AST_Atom = DEFNODE("Atom", null, {
|
|||||||
|
|
||||||
var AST_Null = DEFNODE("Null", null, {
|
var AST_Null = DEFNODE("Null", null, {
|
||||||
$documentation: "The `null` atom",
|
$documentation: "The `null` atom",
|
||||||
value: null
|
value: null,
|
||||||
}, AST_Atom);
|
}, AST_Atom);
|
||||||
|
|
||||||
var AST_NaN = DEFNODE("NaN", null, {
|
var AST_NaN = DEFNODE("NaN", null, {
|
||||||
$documentation: "The impossible value",
|
$documentation: "The impossible value",
|
||||||
value: 0/0
|
value: 0/0,
|
||||||
}, AST_Atom);
|
}, AST_Atom);
|
||||||
|
|
||||||
var AST_Undefined = DEFNODE("Undefined", null, {
|
var AST_Undefined = DEFNODE("Undefined", null, {
|
||||||
$documentation: "The `undefined` value",
|
$documentation: "The `undefined` value",
|
||||||
value: function(){}()
|
value: function(){}(),
|
||||||
}, AST_Atom);
|
}, AST_Atom);
|
||||||
|
|
||||||
var AST_Hole = DEFNODE("Hole", null, {
|
var AST_Hole = DEFNODE("Hole", null, {
|
||||||
$documentation: "A hole in an array",
|
$documentation: "A hole in an array",
|
||||||
value: function(){}()
|
value: function(){}(),
|
||||||
}, AST_Atom);
|
}, AST_Atom);
|
||||||
|
|
||||||
var AST_Infinity = DEFNODE("Infinity", null, {
|
var AST_Infinity = DEFNODE("Infinity", null, {
|
||||||
$documentation: "The `Infinity` value",
|
$documentation: "The `Infinity` value",
|
||||||
value: 1/0
|
value: 1/0,
|
||||||
}, AST_Atom);
|
}, AST_Atom);
|
||||||
|
|
||||||
var AST_Boolean = DEFNODE("Boolean", null, {
|
var AST_Boolean = DEFNODE("Boolean", null, {
|
||||||
@@ -1955,12 +2010,12 @@ var AST_Boolean = DEFNODE("Boolean", null, {
|
|||||||
|
|
||||||
var AST_False = DEFNODE("False", null, {
|
var AST_False = DEFNODE("False", null, {
|
||||||
$documentation: "The `false` atom",
|
$documentation: "The `false` atom",
|
||||||
value: false
|
value: false,
|
||||||
}, AST_Boolean);
|
}, AST_Boolean);
|
||||||
|
|
||||||
var AST_True = DEFNODE("True", null, {
|
var AST_True = DEFNODE("True", null, {
|
||||||
$documentation: "The `true` atom",
|
$documentation: "The `true` atom",
|
||||||
value: true
|
value: true,
|
||||||
}, AST_Boolean);
|
}, AST_Boolean);
|
||||||
|
|
||||||
/* -----[ TreeWalker ]----- */
|
/* -----[ TreeWalker ]----- */
|
||||||
|
|||||||
2342
lib/compress.js
2342
lib/compress.js
File diff suppressed because it is too large
Load Diff
@@ -28,7 +28,7 @@ function read_source_map(name, toplevel) {
|
|||||||
var match = /^# ([^\s=]+)=(\S+)\s*$/.exec(comment.value);
|
var match = /^# ([^\s=]+)=(\S+)\s*$/.exec(comment.value);
|
||||||
if (!match) break;
|
if (!match) break;
|
||||||
if (match[1] == "sourceMappingURL") {
|
if (match[1] == "sourceMappingURL") {
|
||||||
match = /^data:application\/json(;.*?)?;base64,(\S+)$/.exec(match[2]);
|
match = /^data:application\/json(;.*?)?;base64,([^,]+)$/.exec(match[2]);
|
||||||
if (!match) break;
|
if (!match) break;
|
||||||
return to_ascii(match[2]);
|
return to_ascii(match[2]);
|
||||||
}
|
}
|
||||||
@@ -78,6 +78,7 @@ function minify(files, options) {
|
|||||||
enclose: false,
|
enclose: false,
|
||||||
ie: false,
|
ie: false,
|
||||||
ie8: false,
|
ie8: false,
|
||||||
|
keep_fargs: false,
|
||||||
keep_fnames: false,
|
keep_fnames: false,
|
||||||
mangle: {},
|
mangle: {},
|
||||||
nameCache: null,
|
nameCache: null,
|
||||||
@@ -99,6 +100,7 @@ function minify(files, options) {
|
|||||||
if (options.annotations !== undefined) set_shorthand("annotations", options, [ "compress", "output" ]);
|
if (options.annotations !== undefined) set_shorthand("annotations", options, [ "compress", "output" ]);
|
||||||
if (options.ie8) options.ie = options.ie || options.ie8;
|
if (options.ie8) options.ie = options.ie || options.ie8;
|
||||||
if (options.ie) set_shorthand("ie", options, [ "compress", "mangle", "output" ]);
|
if (options.ie) set_shorthand("ie", options, [ "compress", "mangle", "output" ]);
|
||||||
|
if (options.keep_fargs) set_shorthand("keep_fargs", options, [ "compress", "mangle" ]);
|
||||||
if (options.keep_fnames) set_shorthand("keep_fnames", options, [ "compress", "mangle" ]);
|
if (options.keep_fnames) set_shorthand("keep_fnames", options, [ "compress", "mangle" ]);
|
||||||
if (options.toplevel) set_shorthand("toplevel", options, [ "compress", "mangle" ]);
|
if (options.toplevel) set_shorthand("toplevel", options, [ "compress", "mangle" ]);
|
||||||
if (options.v8) set_shorthand("v8", options, [ "mangle", "output" ]);
|
if (options.v8) set_shorthand("v8", options, [ "mangle", "output" ]);
|
||||||
@@ -109,6 +111,7 @@ function minify(files, options) {
|
|||||||
cache: options.nameCache && (options.nameCache.vars || {}),
|
cache: options.nameCache && (options.nameCache.vars || {}),
|
||||||
eval: false,
|
eval: false,
|
||||||
ie: false,
|
ie: false,
|
||||||
|
keep_fargs: false,
|
||||||
keep_fnames: false,
|
keep_fnames: false,
|
||||||
properties: false,
|
properties: false,
|
||||||
reserved: [],
|
reserved: [],
|
||||||
|
|||||||
@@ -1005,7 +1005,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
def_to_moz(AST_RegExp, function To_Moz_RegExpLiteral(M) {
|
def_to_moz(AST_RegExp, function To_Moz_RegExpLiteral(M) {
|
||||||
var flags = M.value.toString().match(/[gimuy]*$/)[0];
|
var flags = M.value.toString().match(/\/([gimuy]*)$/)[1];
|
||||||
var value = "/" + M.value.raw_source + "/" + flags;
|
var value = "/" + M.value.raw_source + "/" + flags;
|
||||||
return {
|
return {
|
||||||
type: "Literal",
|
type: "Literal",
|
||||||
@@ -1013,8 +1013,8 @@
|
|||||||
raw: value,
|
raw: value,
|
||||||
regex: {
|
regex: {
|
||||||
pattern: M.value.raw_source,
|
pattern: M.value.raw_source,
|
||||||
flags: flags
|
flags: flags,
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -521,9 +521,7 @@ function OutputStream(options) {
|
|||||||
indent();
|
indent();
|
||||||
}
|
}
|
||||||
var preamble = options.preamble;
|
var preamble = options.preamble;
|
||||||
if (preamble) {
|
if (preamble) print(preamble.replace(/\r\n?|\u2028|\u2029|(^|\S)\s*$/g, "$1\n"));
|
||||||
print(preamble.replace(/\r\n?|[\n\u2028\u2029]|\s*$/g, "\n"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
comments = comments.filter(comment_filter, node);
|
comments = comments.filter(comment_filter, node);
|
||||||
@@ -1465,7 +1463,7 @@ function OutputStream(options) {
|
|||||||
parent = output.parent(level++);
|
parent = output.parent(level++);
|
||||||
if (parent instanceof AST_Call && parent.expression === node) return;
|
if (parent instanceof AST_Call && parent.expression === node) return;
|
||||||
} while (parent instanceof AST_PropAccess && parent.expression === node);
|
} while (parent instanceof AST_PropAccess && parent.expression === node);
|
||||||
output.print(typeof self.pure == "string" ? "/*" + self.pure + "*/" : "/*@__PURE__*/");
|
output.print("/*@__PURE__*/");
|
||||||
}
|
}
|
||||||
function print_call_args(self, output) {
|
function print_call_args(self, output) {
|
||||||
if (self.expression instanceof AST_Call || self.expression instanceof AST_Lambda) {
|
if (self.expression instanceof AST_Call || self.expression instanceof AST_Lambda) {
|
||||||
@@ -1870,8 +1868,8 @@ function OutputStream(options) {
|
|||||||
len = match[0].length;
|
len = match[0].length;
|
||||||
digits = str.slice(len);
|
digits = str.slice(len);
|
||||||
candidates.push(digits + "e-" + (digits.length + len - 1));
|
candidates.push(digits + "e-" + (digits.length + len - 1));
|
||||||
} else if (match = /0+$/.exec(str)) {
|
} else if (match = /[^0]0+$/.exec(str)) {
|
||||||
len = match[0].length;
|
len = match[0].length - 1;
|
||||||
candidates.push(str.slice(0, -len) + "e" + len);
|
candidates.push(str.slice(0, -len) + "e" + len);
|
||||||
} else if (match = /^(\d)\.(\d+)e(-?\d+)$/.exec(str)) {
|
} else if (match = /^(\d)\.(\d+)e(-?\d+)$/.exec(str)) {
|
||||||
candidates.push(match[1] + match[2] + "e" + (match[3] - match[2].length));
|
candidates.push(match[1] + match[2] + "e" + (match[3] - match[2].length));
|
||||||
|
|||||||
@@ -2316,9 +2316,8 @@ function parse($TEXT, options) {
|
|||||||
var comments = start.comments_before;
|
var comments = start.comments_before;
|
||||||
var i = HOP(start, "comments_before_length") ? start.comments_before_length : comments.length;
|
var i = HOP(start, "comments_before_length") ? start.comments_before_length : comments.length;
|
||||||
while (--i >= 0) {
|
while (--i >= 0) {
|
||||||
var match = /[@#]__PURE__/.exec(comments[i].value);
|
if (/[@#]__PURE__/.test(comments[i].value)) {
|
||||||
if (match) {
|
expr.pure = true;
|
||||||
expr.pure = match[0];
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var builtins = function() {
|
var builtins = function() {
|
||||||
var names = [];
|
var names = new Dictionary();
|
||||||
// NaN will be included due to Number.NaN
|
// NaN will be included due to Number.NaN
|
||||||
[
|
[
|
||||||
"null",
|
"null",
|
||||||
@@ -72,10 +72,10 @@ var builtins = function() {
|
|||||||
Object.getOwnPropertyNames(ctor.prototype).map(add);
|
Object.getOwnPropertyNames(ctor.prototype).map(add);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return makePredicate(names);
|
return names;
|
||||||
|
|
||||||
function add(name) {
|
function add(name) {
|
||||||
names.push(name);
|
names.set(name, true);
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
|
|
||||||
@@ -116,9 +116,9 @@ function mangle_properties(ast, options) {
|
|||||||
reserved: null,
|
reserved: null,
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
var reserved = Object.create(options.builtins ? null : builtins);
|
var reserved = options.builtins ? new Dictionary() : builtins.clone();
|
||||||
if (Array.isArray(options.reserved)) options.reserved.forEach(function(name) {
|
if (Array.isArray(options.reserved)) options.reserved.forEach(function(name) {
|
||||||
reserved[name] = true;
|
reserved.set(name, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
var cname = -1;
|
var cname = -1;
|
||||||
@@ -126,7 +126,7 @@ function mangle_properties(ast, options) {
|
|||||||
if (options.cache) {
|
if (options.cache) {
|
||||||
cache = options.cache.props;
|
cache = options.cache.props;
|
||||||
cache.each(function(name) {
|
cache.each(function(name) {
|
||||||
reserved[name] = true;
|
reserved.set(name, true);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
cache = new Dictionary();
|
cache = new Dictionary();
|
||||||
@@ -141,8 +141,8 @@ function mangle_properties(ast, options) {
|
|||||||
var debug_suffix;
|
var debug_suffix;
|
||||||
if (debug) debug_suffix = options.debug === true ? "" : options.debug;
|
if (debug) debug_suffix = options.debug === true ? "" : options.debug;
|
||||||
|
|
||||||
var names_to_mangle = Object.create(null);
|
var names_to_mangle = new Dictionary();
|
||||||
var unmangleable = Object.create(reserved);
|
var unmangleable = reserved.clone();
|
||||||
|
|
||||||
// step 1: find candidates to mangle
|
// step 1: find candidates to mangle
|
||||||
ast.walk(new TreeWalker(function(node) {
|
ast.walk(new TreeWalker(function(node) {
|
||||||
@@ -211,20 +211,20 @@ function mangle_properties(ast, options) {
|
|||||||
// only function declarations after this line
|
// only function declarations after this line
|
||||||
|
|
||||||
function can_mangle(name) {
|
function can_mangle(name) {
|
||||||
if (unmangleable[name]) return false;
|
if (unmangleable.has(name)) return false;
|
||||||
if (/^-?[0-9]+(\.[0-9]+)?(e[+-][0-9]+)?$/.test(name)) return false;
|
if (/^-?[0-9]+(\.[0-9]+)?(e[+-][0-9]+)?$/.test(name)) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function should_mangle(name) {
|
function should_mangle(name) {
|
||||||
if (reserved[name]) return false;
|
if (reserved.has(name)) return false;
|
||||||
if (regex && !regex.test(name)) return false;
|
if (regex && !regex.test(name)) return false;
|
||||||
return cache.has(name) || names_to_mangle[name];
|
return cache.has(name) || names_to_mangle.has(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
function add(name) {
|
function add(name) {
|
||||||
if (can_mangle(name)) names_to_mangle[name] = true;
|
if (can_mangle(name)) names_to_mangle.set(name, true);
|
||||||
if (!should_mangle(name)) unmangleable[name] = true;
|
if (!should_mangle(name)) unmangleable.set(name, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function mangle(name) {
|
function mangle(name) {
|
||||||
|
|||||||
146
lib/scope.js
146
lib/scope.js
@@ -44,9 +44,9 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
function SymbolDef(id, scope, orig, init) {
|
function SymbolDef(id, scope, orig, init) {
|
||||||
|
this._bits = 0;
|
||||||
|
this.defun = undefined;
|
||||||
this.eliminated = 0;
|
this.eliminated = 0;
|
||||||
this.exported = false;
|
|
||||||
this.global = false;
|
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.init = init;
|
this.init = init;
|
||||||
this.mangled_name = null;
|
this.mangled_name = null;
|
||||||
@@ -54,8 +54,8 @@ function SymbolDef(id, scope, orig, init) {
|
|||||||
this.orig = [ orig ];
|
this.orig = [ orig ];
|
||||||
this.references = [];
|
this.references = [];
|
||||||
this.replaced = 0;
|
this.replaced = 0;
|
||||||
|
this.safe_ids = undefined;
|
||||||
this.scope = scope;
|
this.scope = scope;
|
||||||
this.undeclared = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SymbolDef.prototype = {
|
SymbolDef.prototype = {
|
||||||
@@ -92,18 +92,35 @@ SymbolDef.prototype = {
|
|||||||
if (def && def !== self) return def.redefined() || def;
|
if (def && def !== self) return def.redefined() || def;
|
||||||
},
|
},
|
||||||
unmangleable: function(options) {
|
unmangleable: function(options) {
|
||||||
return this.global && !options.toplevel
|
if (this.exported) return true;
|
||||||
|| this.exported
|
if (this.undeclared) return true;
|
||||||
|| this.undeclared
|
if (!options.eval && this.scope.pinned()) return true;
|
||||||
|| !options.eval && this.scope.pinned()
|
if (options.keep_fargs && is_funarg(this)) return true;
|
||||||
|| options.keep_fnames
|
if (options.keep_fnames) {
|
||||||
&& (this.orig[0] instanceof AST_SymbolClass
|
var sym = this.orig[0];
|
||||||
|| this.orig[0] instanceof AST_SymbolDefClass
|
if (sym instanceof AST_SymbolClass) return true;
|
||||||
|| this.orig[0] instanceof AST_SymbolDefun
|
if (sym instanceof AST_SymbolDefClass) return true;
|
||||||
|| this.orig[0] instanceof AST_SymbolLambda);
|
if (sym instanceof AST_SymbolDefun) return true;
|
||||||
|
if (sym instanceof AST_SymbolLambda) return true;
|
||||||
|
}
|
||||||
|
if (!options.toplevel && this.global) return true;
|
||||||
|
return false;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
DEF_BITPROPS(SymbolDef, [
|
||||||
|
"const_redefs",
|
||||||
|
"cross_loop",
|
||||||
|
"direct_access",
|
||||||
|
"exported",
|
||||||
|
"global",
|
||||||
|
"undeclared",
|
||||||
|
]);
|
||||||
|
|
||||||
|
function is_funarg(def) {
|
||||||
|
return def.orig[0] instanceof AST_SymbolFunarg || def.orig[1] instanceof AST_SymbolFunarg;
|
||||||
|
}
|
||||||
|
|
||||||
var unary_side_effects = makePredicate("delete ++ --");
|
var unary_side_effects = makePredicate("delete ++ --");
|
||||||
|
|
||||||
function is_lhs(node, parent) {
|
function is_lhs(node, parent) {
|
||||||
@@ -205,10 +222,8 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
|
|||||||
} else if (node instanceof AST_SymbolDefun) {
|
} else if (node instanceof AST_SymbolDefun) {
|
||||||
var def = defun.def_function(node, tw.parent());
|
var def = defun.def_function(node, tw.parent());
|
||||||
if (exported) def.exported = true;
|
if (exported) def.exported = true;
|
||||||
entangle(defun, scope);
|
|
||||||
} else if (node instanceof AST_SymbolFunarg) {
|
} else if (node instanceof AST_SymbolFunarg) {
|
||||||
defun.def_variable(node);
|
defun.def_variable(node);
|
||||||
entangle(defun, scope);
|
|
||||||
} else if (node instanceof AST_SymbolLambda) {
|
} else if (node instanceof AST_SymbolLambda) {
|
||||||
var def = defun.def_function(node, node.name == "arguments" ? undefined : defun);
|
var def = defun.def_function(node, node.name == "arguments" ? undefined : defun);
|
||||||
if (options.ie) def.defun = defun.parent_scope.resolve();
|
if (options.ie) def.defun = defun.parent_scope.resolve();
|
||||||
@@ -218,7 +233,6 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
|
|||||||
} else if (node instanceof AST_SymbolVar) {
|
} else if (node instanceof AST_SymbolVar) {
|
||||||
var def = defun.def_variable(node, node instanceof AST_SymbolImport ? undefined : null);
|
var def = defun.def_variable(node, node instanceof AST_SymbolImport ? undefined : null);
|
||||||
if (exported) def.exported = true;
|
if (exported) def.exported = true;
|
||||||
entangle(defun, scope);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function walk_scope(descend) {
|
function walk_scope(descend) {
|
||||||
@@ -231,16 +245,6 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
|
|||||||
scope = save_scope;
|
scope = save_scope;
|
||||||
defun = save_defun;
|
defun = save_defun;
|
||||||
}
|
}
|
||||||
|
|
||||||
function entangle(defun, scope) {
|
|
||||||
if (defun === scope) return;
|
|
||||||
node.mark_enclosed(options);
|
|
||||||
var def = scope.find_variable(node.name);
|
|
||||||
if (node.thedef === def) return;
|
|
||||||
node.thedef = def;
|
|
||||||
def.orig.push(node);
|
|
||||||
node.mark_enclosed(options);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
self.make_def = function(orig, init) {
|
self.make_def = function(orig, init) {
|
||||||
return new SymbolDef(++next_def_id, this, orig, init);
|
return new SymbolDef(++next_def_id, this, orig, init);
|
||||||
@@ -261,6 +265,7 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
|
|||||||
}
|
}
|
||||||
if (node instanceof AST_Lambda) {
|
if (node instanceof AST_Lambda) {
|
||||||
in_arg.push(node);
|
in_arg.push(node);
|
||||||
|
if (node.name) node.name.walk(tw);
|
||||||
node.argnames.forEach(function(argname) {
|
node.argnames.forEach(function(argname) {
|
||||||
argname.walk(tw);
|
argname.walk(tw);
|
||||||
});
|
});
|
||||||
@@ -287,6 +292,16 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
|
|||||||
// ensure compression works if `const` reuses a scope variable
|
// ensure compression works if `const` reuses a scope variable
|
||||||
var redef = def.redefined();
|
var redef = def.redefined();
|
||||||
if (redef) redef.const_redefs = true;
|
if (redef) redef.const_redefs = true;
|
||||||
|
} else if (def.scope !== node.scope && (node instanceof AST_SymbolDefun
|
||||||
|
|| node instanceof AST_SymbolFunarg
|
||||||
|
|| node instanceof AST_SymbolVar)) {
|
||||||
|
node.mark_enclosed(options);
|
||||||
|
var redef = node.scope.find_variable(node.name);
|
||||||
|
if (node.thedef !== redef) {
|
||||||
|
node.thedef = redef;
|
||||||
|
redef.orig.push(node);
|
||||||
|
node.mark_enclosed(options);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (node.name != "arguments") return true;
|
if (node.name != "arguments") return true;
|
||||||
var parent = node instanceof AST_SymbolVar && tw.parent();
|
var parent = node instanceof AST_SymbolVar && tw.parent();
|
||||||
@@ -363,7 +378,7 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
|
|||||||
if (node instanceof AST_SymbolLambda) {
|
if (node instanceof AST_SymbolLambda) {
|
||||||
var def = node.thedef;
|
var def = node.thedef;
|
||||||
if (!redefine(node, node.scope.parent_scope.resolve())) {
|
if (!redefine(node, node.scope.parent_scope.resolve())) {
|
||||||
delete def.defun;
|
def.defun = undefined;
|
||||||
} else if (typeof node.thedef.init !== "undefined") {
|
} else if (typeof node.thedef.init !== "undefined") {
|
||||||
node.thedef.init = false;
|
node.thedef.init = false;
|
||||||
} else if (def.init) {
|
} else if (def.init) {
|
||||||
@@ -465,9 +480,12 @@ AST_Symbol.DEFMETHOD("mark_enclosed", function(options) {
|
|||||||
for (var s = this.scope; s; s = s.parent_scope) {
|
for (var s = this.scope; s; s = s.parent_scope) {
|
||||||
push_uniq(s.enclosed, def);
|
push_uniq(s.enclosed, def);
|
||||||
if (!options) {
|
if (!options) {
|
||||||
delete s._var_names;
|
s._var_names = undefined;
|
||||||
} else if (options.keep_fnames) {
|
} else {
|
||||||
s.functions.each(function(d) {
|
if (options.keep_fargs && s instanceof AST_Lambda) s.each_argname(function(arg) {
|
||||||
|
push_uniq(def.scope.enclosed, arg.definition());
|
||||||
|
});
|
||||||
|
if (options.keep_fnames) s.functions.each(function(d) {
|
||||||
push_uniq(def.scope.enclosed, d);
|
push_uniq(def.scope.enclosed, d);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -510,12 +528,12 @@ function names_in_use(scope, options) {
|
|||||||
if (!names) {
|
if (!names) {
|
||||||
scope.cname = -1;
|
scope.cname = -1;
|
||||||
scope.cname_holes = [];
|
scope.cname_holes = [];
|
||||||
scope.names_in_use = names = Object.create(null);
|
scope.names_in_use = names = new Dictionary();
|
||||||
var cache = options.cache && options.cache.props;
|
var cache = options.cache && options.cache.props;
|
||||||
scope.enclosed.forEach(function(def) {
|
scope.enclosed.forEach(function(def) {
|
||||||
if (def.unmangleable(options)) names[def.name] = true;
|
if (def.unmangleable(options)) names.set(def.name, true);
|
||||||
if (def.global && cache && cache.has(def.name)) {
|
if (def.global && cache && cache.has(def.name)) {
|
||||||
names[cache.get(def.name)] = true;
|
names.set(cache.get(def.name), true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -526,34 +544,33 @@ function next_mangled_name(def, options) {
|
|||||||
var scope = def.scope;
|
var scope = def.scope;
|
||||||
var in_use = names_in_use(scope, options);
|
var in_use = names_in_use(scope, options);
|
||||||
var holes = scope.cname_holes;
|
var holes = scope.cname_holes;
|
||||||
var names = Object.create(null);
|
var names = new Dictionary();
|
||||||
var scopes = [ scope ];
|
var scopes = [ scope ];
|
||||||
def.forEach(function(sym) {
|
def.forEach(function(sym) {
|
||||||
var scope = sym.scope;
|
var scope = sym.scope;
|
||||||
do {
|
do {
|
||||||
if (scopes.indexOf(scope) < 0) {
|
if (member(scope, scopes)) break;
|
||||||
for (var name in names_in_use(scope, options)) {
|
names_in_use(scope, options).each(function(marker, name) {
|
||||||
names[name] = true;
|
names.set(name, marker);
|
||||||
}
|
});
|
||||||
scopes.push(scope);
|
scopes.push(scope);
|
||||||
} else break;
|
|
||||||
} while (scope = scope.parent_scope);
|
} while (scope = scope.parent_scope);
|
||||||
});
|
});
|
||||||
var name;
|
var name;
|
||||||
for (var i = 0; i < holes.length; i++) {
|
for (var i = 0; i < holes.length; i++) {
|
||||||
name = base54(holes[i]);
|
name = base54(holes[i]);
|
||||||
if (names[name]) continue;
|
if (names.has(name)) continue;
|
||||||
holes.splice(i, 1);
|
holes.splice(i, 1);
|
||||||
in_use[name] = true;
|
in_use.set(name, true);
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
while (true) {
|
while (true) {
|
||||||
name = base54(++scope.cname);
|
name = base54(++scope.cname);
|
||||||
if (in_use[name] || RESERVED_WORDS[name] || options.reserved.has[name]) continue;
|
if (in_use.has(name) || RESERVED_WORDS[name] || options.reserved.has[name]) continue;
|
||||||
if (!names[name]) break;
|
if (!names.has(name)) break;
|
||||||
holes.push(scope.cname);
|
holes.push(scope.cname);
|
||||||
}
|
}
|
||||||
in_use[name] = true;
|
in_use.set(name, true);
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -573,6 +590,7 @@ function _default_mangler_options(options) {
|
|||||||
options = defaults(options, {
|
options = defaults(options, {
|
||||||
eval : false,
|
eval : false,
|
||||||
ie : false,
|
ie : false,
|
||||||
|
keep_fargs : false,
|
||||||
keep_fnames : false,
|
keep_fnames : false,
|
||||||
reserved : [],
|
reserved : [],
|
||||||
toplevel : false,
|
toplevel : false,
|
||||||
@@ -580,32 +598,30 @@ function _default_mangler_options(options) {
|
|||||||
webkit : false,
|
webkit : false,
|
||||||
});
|
});
|
||||||
if (!Array.isArray(options.reserved)) options.reserved = [];
|
if (!Array.isArray(options.reserved)) options.reserved = [];
|
||||||
// Never mangle arguments
|
// Never mangle `arguments`
|
||||||
push_uniq(options.reserved, "arguments");
|
push_uniq(options.reserved, "arguments");
|
||||||
options.reserved.has = makePredicate(options.reserved);
|
options.reserved.has = makePredicate(options.reserved);
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We only need to mangle declaration nodes. Special logic wired into the code
|
||||||
|
// generator will display the mangled name if it is present (and for
|
||||||
|
// `AST_SymbolRef`s it will use the mangled name of the `AST_SymbolDeclaration`
|
||||||
|
// that it points to).
|
||||||
AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
|
AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
|
||||||
options = _default_mangler_options(options);
|
options = _default_mangler_options(options);
|
||||||
|
|
||||||
// We only need to mangle declaration nodes. Special logic wired
|
|
||||||
// into the code generator will display the mangled name if it's
|
|
||||||
// present (and for AST_SymbolRef-s it'll use the mangled name of
|
|
||||||
// the AST_SymbolDeclaration that it points to).
|
|
||||||
var lname = -1;
|
|
||||||
|
|
||||||
if (options.cache && options.cache.props) {
|
if (options.cache && options.cache.props) {
|
||||||
var mangled_names = names_in_use(this, options);
|
var mangled_names = names_in_use(this, options);
|
||||||
options.cache.props.each(function(mangled_name) {
|
options.cache.props.each(function(mangled_name) {
|
||||||
mangled_names[mangled_name] = true;
|
mangled_names.set(mangled_name, true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
var cutoff = 10;
|
||||||
|
var lname = -1;
|
||||||
var redefined = [];
|
var redefined = [];
|
||||||
var tw = new TreeWalker(function(node, descend) {
|
var tw = new TreeWalker(function(node, descend) {
|
||||||
if (node instanceof AST_LabeledStatement) {
|
if (node instanceof AST_LabeledStatement) {
|
||||||
// lname is incremented when we get to the AST_Label
|
// `lname` is incremented when we get to the `AST_Label`
|
||||||
var save_nesting = lname;
|
var save_nesting = lname;
|
||||||
descend();
|
descend();
|
||||||
if (!options.v8 || !in_label(tw)) lname = save_nesting;
|
if (!options.v8 || !in_label(tw)) lname = save_nesting;
|
||||||
@@ -627,9 +643,9 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
|
|||||||
});
|
});
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
node.to_mangle = [];
|
var to_mangle = node.to_mangle = [];
|
||||||
node.variables.each(function(def) {
|
node.variables.each(function(def) {
|
||||||
if (!defer_redef(def)) node.to_mangle.push(def);
|
if (!defer_redef(def)) to_mangle.push(def);
|
||||||
});
|
});
|
||||||
descend();
|
descend();
|
||||||
if (options.cache && node instanceof AST_Toplevel) {
|
if (options.cache && node instanceof AST_Toplevel) {
|
||||||
@@ -640,7 +656,23 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
|
|||||||
sym.scope = node;
|
sym.scope = node;
|
||||||
sym.reference(options);
|
sym.reference(options);
|
||||||
}
|
}
|
||||||
node.to_mangle.forEach(mangle);
|
if (to_mangle.length > cutoff) {
|
||||||
|
var indices = to_mangle.map(function(def, index) {
|
||||||
|
return index;
|
||||||
|
}).sort(function(i, j) {
|
||||||
|
return to_mangle[j].references.length - to_mangle[i].references.length || i - j;
|
||||||
|
});
|
||||||
|
to_mangle = indices.slice(0, cutoff).sort(function(i, j) {
|
||||||
|
return i - j;
|
||||||
|
}).map(function(index) {
|
||||||
|
return to_mangle[index];
|
||||||
|
}).concat(indices.slice(cutoff).sort(function(i, j) {
|
||||||
|
return i - j;
|
||||||
|
}).map(function(index) {
|
||||||
|
return to_mangle[index];
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
to_mangle.forEach(mangle);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (node instanceof AST_Label) {
|
if (node instanceof AST_Label) {
|
||||||
|
|||||||
@@ -77,21 +77,23 @@ function vlq_encode(num) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function create_array_map() {
|
function create_array_map() {
|
||||||
var map = Object.create(null);
|
var map = new Dictionary();
|
||||||
var array = [];
|
var array = [];
|
||||||
array.index = function(name) {
|
array.index = function(name) {
|
||||||
if (!HOP(map, name)) {
|
var index = map.get(name);
|
||||||
map[name] = array.length;
|
if (!(index >= 0)) {
|
||||||
|
index = array.length;
|
||||||
array.push(name);
|
array.push(name);
|
||||||
|
map.set(name, index);
|
||||||
}
|
}
|
||||||
return map[name];
|
return index;
|
||||||
};
|
};
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
function SourceMap(options) {
|
function SourceMap(options) {
|
||||||
var sources = create_array_map();
|
var sources = create_array_map();
|
||||||
var sources_content = options.includeSources && Object.create(null);
|
var sources_content = options.includeSources && new Dictionary();
|
||||||
var names = create_array_map();
|
var names = create_array_map();
|
||||||
var mappings = "";
|
var mappings = "";
|
||||||
if (options.orig) Object.keys(options.orig).forEach(function(name) {
|
if (options.orig) Object.keys(options.orig).forEach(function(name) {
|
||||||
@@ -110,7 +112,7 @@ function SourceMap(options) {
|
|||||||
if (!sources_content || !map.sourcesContent) return;
|
if (!sources_content || !map.sourcesContent) return;
|
||||||
for (var i = 0; i < map.sources.length; i++) {
|
for (var i = 0; i < map.sources.length; i++) {
|
||||||
var content = map.sourcesContent[i];
|
var content = map.sourcesContent[i];
|
||||||
if (content) sources_content[map.sources[i]] = content;
|
if (content) sources_content.set(map.sources[i], content);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var prev_source;
|
var prev_source;
|
||||||
@@ -144,8 +146,8 @@ function SourceMap(options) {
|
|||||||
add(source, gen_line, gen_col, orig_line, orig_col, name);
|
add(source, gen_line, gen_col, orig_line, orig_col, name);
|
||||||
} : add,
|
} : add,
|
||||||
setSourceContent: sources_content ? function(source, content) {
|
setSourceContent: sources_content ? function(source, content) {
|
||||||
if (!(source in sources_content)) {
|
if (!sources_content.has(source)) {
|
||||||
sources_content[source] = content;
|
sources_content.set(source, content);
|
||||||
}
|
}
|
||||||
} : noop,
|
} : noop,
|
||||||
toString: function() {
|
toString: function() {
|
||||||
@@ -155,7 +157,7 @@ function SourceMap(options) {
|
|||||||
sourceRoot: options.root || undefined,
|
sourceRoot: options.root || undefined,
|
||||||
sources: sources,
|
sources: sources,
|
||||||
sourcesContent: sources_content ? sources.map(function(source) {
|
sourcesContent: sources_content ? sources.map(function(source) {
|
||||||
return sources_content[source] || null;
|
return sources_content.get(source) || null;
|
||||||
}) : undefined,
|
}) : undefined,
|
||||||
names: names,
|
names: names,
|
||||||
mappings: mappings,
|
mappings: mappings,
|
||||||
|
|||||||
92
lib/utils.js
92
lib/utils.js
@@ -96,15 +96,6 @@ function defaults(args, defs, croak) {
|
|||||||
return defs;
|
return defs;
|
||||||
}
|
}
|
||||||
|
|
||||||
function merge(obj, ext) {
|
|
||||||
var count = 0;
|
|
||||||
for (var i in ext) if (HOP(ext, i)) {
|
|
||||||
obj[i] = ext[i];
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
function noop() {}
|
function noop() {}
|
||||||
function return_false() { return false; }
|
function return_false() { return false; }
|
||||||
function return_true() { return true; }
|
function return_true() { return true; }
|
||||||
@@ -171,63 +162,80 @@ function all(array, predicate) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Dictionary() {
|
function Dictionary() {
|
||||||
this._values = Object.create(null);
|
this.values = Object.create(null);
|
||||||
this._size = 0;
|
|
||||||
}
|
}
|
||||||
Dictionary.prototype = {
|
Dictionary.prototype = {
|
||||||
set: function(key, val) {
|
set: function(key, val) {
|
||||||
if (!this.has(key)) ++this._size;
|
if (key == "__proto__") {
|
||||||
this._values["$" + key] = val;
|
this.proto_value = val;
|
||||||
|
} else {
|
||||||
|
this.values[key] = val;
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
add: function(key, val) {
|
add: function(key, val) {
|
||||||
if (this.has(key)) {
|
var list = this.get(key);
|
||||||
this.get(key).push(val);
|
if (list) {
|
||||||
|
list.push(val);
|
||||||
} else {
|
} else {
|
||||||
this.set(key, [ val ]);
|
this.set(key, [ val ]);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
get: function(key) { return this._values["$" + key] },
|
get: function(key) {
|
||||||
|
return key == "__proto__" ? this.proto_value : this.values[key];
|
||||||
|
},
|
||||||
del: function(key) {
|
del: function(key) {
|
||||||
if (this.has(key)) {
|
if (key == "__proto__") {
|
||||||
--this._size;
|
delete this.proto_value;
|
||||||
delete this._values["$" + key];
|
} else {
|
||||||
|
delete this.values[key];
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
has: function(key) { return ("$" + key) in this._values },
|
has: function(key) {
|
||||||
|
return key == "__proto__" ? "proto_value" in this : key in this.values;
|
||||||
|
},
|
||||||
all: function(predicate) {
|
all: function(predicate) {
|
||||||
for (var i in this._values)
|
for (var i in this.values)
|
||||||
if (!predicate(this._values[i], i.substr(1)))
|
if (!predicate(this.values[i], i)) return false;
|
||||||
return false;
|
if ("proto_value" in this && !predicate(this.proto_value, "__proto__")) return false;
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
each: function(f) {
|
each: function(f) {
|
||||||
for (var i in this._values)
|
for (var i in this.values)
|
||||||
f(this._values[i], i.substr(1));
|
f(this.values[i], i);
|
||||||
|
if ("proto_value" in this) f(this.proto_value, "__proto__");
|
||||||
},
|
},
|
||||||
size: function() {
|
size: function() {
|
||||||
return this._size;
|
return Object.keys(this.values).length + ("proto_value" in this);
|
||||||
},
|
},
|
||||||
map: function(f) {
|
map: function(f) {
|
||||||
var ret = [];
|
var ret = [];
|
||||||
for (var i in this._values)
|
for (var i in this.values)
|
||||||
ret.push(f(this._values[i], i.substr(1)));
|
ret.push(f(this.values[i], i));
|
||||||
|
if ("proto_value" in this) ret.push(f(this.proto_value, "__proto__"));
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
clone: function() {
|
clone: function() {
|
||||||
var ret = new Dictionary();
|
var ret = new Dictionary();
|
||||||
for (var i in this._values)
|
this.each(function(value, i) {
|
||||||
ret._values[i] = this._values[i];
|
ret.set(i, value);
|
||||||
ret._size = this._size;
|
});
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
toObject: function() { return this._values }
|
toObject: function() {
|
||||||
|
var obj = {};
|
||||||
|
this.each(function(value, i) {
|
||||||
|
obj["$" + i] = value;
|
||||||
|
});
|
||||||
|
return obj;
|
||||||
|
},
|
||||||
};
|
};
|
||||||
Dictionary.fromObject = function(obj) {
|
Dictionary.fromObject = function(obj) {
|
||||||
var dict = new Dictionary();
|
var dict = new Dictionary();
|
||||||
dict._size = merge(dict._values, obj);
|
for (var i in obj)
|
||||||
|
if (HOP(obj, i)) dict.set(i.slice(1), obj[i]);
|
||||||
return dict;
|
return dict;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -265,3 +273,21 @@ function first_in_statement(stack, arrow, export_default) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function DEF_BITPROPS(ctor, props) {
|
||||||
|
if (props.length > 31) throw new Error("Too many properties: " + props.length + "\n" + props.join(", "));
|
||||||
|
props.forEach(function(name, pos) {
|
||||||
|
var mask = 1 << pos;
|
||||||
|
Object.defineProperty(ctor.prototype, name, {
|
||||||
|
get: function() {
|
||||||
|
return !!(this._bits & mask);
|
||||||
|
},
|
||||||
|
set: function(val) {
|
||||||
|
if (val)
|
||||||
|
this._bits |= mask;
|
||||||
|
else
|
||||||
|
this._bits &= ~mask;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@@ -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.14.4",
|
"version": "3.15.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.8.0"
|
"node": ">=0.8.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -442,9 +442,9 @@ compress_annotations_disabled_output_annotations_enabled: {
|
|||||||
}
|
}
|
||||||
expect_exact: [
|
expect_exact: [
|
||||||
"/*@__PURE__*/a(3),",
|
"/*@__PURE__*/a(3),",
|
||||||
"/*#__PURE__*/b(5),",
|
"/*@__PURE__*/b(5),",
|
||||||
"c(side_effect),",
|
"c(side_effect),",
|
||||||
"/*#__PURE__*/d(effect());",
|
"/*@__PURE__*/d(effect());",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -363,6 +363,28 @@ negate: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline_this: {
|
inline_this: {
|
||||||
|
options = {
|
||||||
|
inline: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var p = "PASS";
|
||||||
|
console.log({
|
||||||
|
p: "FAIL",
|
||||||
|
q: (() => this.p)(),
|
||||||
|
}.q);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var p = "PASS";
|
||||||
|
console.log({
|
||||||
|
p: "FAIL",
|
||||||
|
q: this.p,
|
||||||
|
}.q);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|
||||||
|
dont_inline_this: {
|
||||||
options = {
|
options = {
|
||||||
inline: true,
|
inline: true,
|
||||||
}
|
}
|
||||||
@@ -486,7 +508,7 @@ drop_value: {
|
|||||||
((a, b) => a + b)(console.log(42));
|
((a, b) => a + b)(console.log(42));
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
((a, b) => {})(console.log(42));
|
void console.log(42);
|
||||||
}
|
}
|
||||||
expect_stdout: "42"
|
expect_stdout: "42"
|
||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
@@ -884,3 +906,24 @@ issue_4772: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5251: {
|
||||||
|
options = {
|
||||||
|
inline: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(() => {
|
||||||
|
while (console.log(arguments))
|
||||||
|
var arguments = "FAIL";
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(() => {
|
||||||
|
while (console.log(arguments))
|
||||||
|
var arguments = "FAIL";
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect_stdout: true
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|||||||
@@ -489,7 +489,7 @@ logical_assignments: {
|
|||||||
node_version: ">=15"
|
node_version: ">=15"
|
||||||
}
|
}
|
||||||
|
|
||||||
logical_collapse_vars: {
|
logical_collapse_vars_1: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars: true,
|
collapse_vars: true,
|
||||||
}
|
}
|
||||||
@@ -509,6 +509,46 @@ logical_collapse_vars: {
|
|||||||
node_version: ">=15"
|
node_version: ">=15"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logical_collapse_vars_2: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = "PASS";
|
||||||
|
(function(b) {
|
||||||
|
b ||= (a = "FAIL", {});
|
||||||
|
return b;
|
||||||
|
})(console).log(a);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = "PASS";
|
||||||
|
(function(b) {
|
||||||
|
return b ||= (a = "FAIL", {});
|
||||||
|
})(console).log(a);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=15"
|
||||||
|
}
|
||||||
|
|
||||||
|
logical_collapse_vars_3: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = 6;
|
||||||
|
a *= 7;
|
||||||
|
a ??= "FAIL";
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = 6;
|
||||||
|
a = a * 7 ?? "FAIL";
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect_stdout: "42"
|
||||||
|
node_version: ">=15"
|
||||||
|
}
|
||||||
|
|
||||||
logical_reduce_vars: {
|
logical_reduce_vars: {
|
||||||
options = {
|
options = {
|
||||||
evaluate: true,
|
evaluate: true,
|
||||||
|
|||||||
@@ -11,6 +11,21 @@ async_arrow: {
|
|||||||
node_version: ">=8"
|
node_version: ">=8"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async_computed: {
|
||||||
|
input: {
|
||||||
|
var o = {
|
||||||
|
async [42]() {
|
||||||
|
return this.p;
|
||||||
|
},
|
||||||
|
p: "PASS",
|
||||||
|
};
|
||||||
|
o[42]().then(console.log);
|
||||||
|
}
|
||||||
|
expect_exact: 'var o={async[42](){return this.p},p:"PASS"};o[42]().then(console.log);'
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
async_label: {
|
async_label: {
|
||||||
input: {
|
input: {
|
||||||
(async function() {
|
(async function() {
|
||||||
@@ -182,6 +197,34 @@ dont_inline: {
|
|||||||
node_version: ">=8"
|
node_version: ">=8"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dont_inline_nested: {
|
||||||
|
options = {
|
||||||
|
inline: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function await() {
|
||||||
|
return "PASS";
|
||||||
|
}
|
||||||
|
(async function() {
|
||||||
|
(function() {
|
||||||
|
console.log(await("FAIL"));
|
||||||
|
})();
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function await() {
|
||||||
|
return "PASS";
|
||||||
|
}
|
||||||
|
(async function() {
|
||||||
|
(function() {
|
||||||
|
console.log(await("FAIL"));
|
||||||
|
})();
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
inline_await_1: {
|
inline_await_1: {
|
||||||
options = {
|
options = {
|
||||||
awaits: true,
|
awaits: true,
|
||||||
@@ -340,7 +383,436 @@ inline_await_3_trim: {
|
|||||||
node_version: ">=8"
|
node_version: ">=8"
|
||||||
}
|
}
|
||||||
|
|
||||||
await_unary: {
|
inline_await_this: {
|
||||||
|
options = {
|
||||||
|
awaits: true,
|
||||||
|
inline: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var p = "FAIL";
|
||||||
|
({
|
||||||
|
p: "PASS",
|
||||||
|
async f() {
|
||||||
|
return await (async () => this.p)();
|
||||||
|
},
|
||||||
|
}).f().then(console.log);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var p = "FAIL";
|
||||||
|
({
|
||||||
|
p: "PASS",
|
||||||
|
async f() {
|
||||||
|
return await this.p;
|
||||||
|
},
|
||||||
|
}).f().then(console.log);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
|
inline_block: {
|
||||||
|
options = {
|
||||||
|
awaits: true,
|
||||||
|
if_return: true,
|
||||||
|
inline: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log("foo");
|
||||||
|
(async function() {
|
||||||
|
console.log("bar");
|
||||||
|
(async function() {
|
||||||
|
for (var a of [ "baz" ])
|
||||||
|
return a;
|
||||||
|
})();
|
||||||
|
})().then(console.log);
|
||||||
|
console.log("moo");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log("foo");
|
||||||
|
(async function() {
|
||||||
|
console.log("bar");
|
||||||
|
for (var a of [ "baz" ])
|
||||||
|
return void await a;
|
||||||
|
})().then(console.log);
|
||||||
|
console.log("moo");
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"foo",
|
||||||
|
"bar",
|
||||||
|
"moo",
|
||||||
|
"undefined",
|
||||||
|
]
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
|
inline_block_async: {
|
||||||
|
options = {
|
||||||
|
awaits: true,
|
||||||
|
if_return: true,
|
||||||
|
inline: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log("foo");
|
||||||
|
(async function() {
|
||||||
|
console.log("bar");
|
||||||
|
(async function() {
|
||||||
|
for (var a of [ "baz" ])
|
||||||
|
return {
|
||||||
|
then(r) {
|
||||||
|
console.log("moo");
|
||||||
|
r(a);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
})().then(console.log);
|
||||||
|
console.log("moz");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log("foo");
|
||||||
|
(async function() {
|
||||||
|
console.log("bar");
|
||||||
|
for (var a of [ "baz" ])
|
||||||
|
return void await {
|
||||||
|
then(r) {
|
||||||
|
console.log("moo");
|
||||||
|
r(a);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
})().then(console.log);
|
||||||
|
console.log("moz");
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"foo",
|
||||||
|
"bar",
|
||||||
|
"moz",
|
||||||
|
"moo",
|
||||||
|
"undefined",
|
||||||
|
]
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
|
inline_block_await: {
|
||||||
|
options = {
|
||||||
|
awaits: true,
|
||||||
|
if_return: true,
|
||||||
|
inline: true,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log("foo");
|
||||||
|
(async function() {
|
||||||
|
console.log("bar");
|
||||||
|
await async function() {
|
||||||
|
for (var a of [ "baz" ])
|
||||||
|
return a;
|
||||||
|
}();
|
||||||
|
})().then(console.log);
|
||||||
|
console.log("moo");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log("foo");
|
||||||
|
(async function() {
|
||||||
|
console.log("bar");
|
||||||
|
for (var a of [ "baz" ])
|
||||||
|
return void await a;
|
||||||
|
})().then(console.log);
|
||||||
|
console.log("moo");
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"foo",
|
||||||
|
"bar",
|
||||||
|
"moo",
|
||||||
|
"undefined",
|
||||||
|
]
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
|
inline_block_await_async: {
|
||||||
|
options = {
|
||||||
|
inline: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(async function() {
|
||||||
|
console.log("foo");
|
||||||
|
await (async function() {
|
||||||
|
while (await console.log("bar"));
|
||||||
|
console.log("baz");
|
||||||
|
})();
|
||||||
|
console.log("moo");
|
||||||
|
})().then(console.log);
|
||||||
|
console.log("moz");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(async function() {
|
||||||
|
console.log("foo");
|
||||||
|
while (await console.log("bar"));
|
||||||
|
console.log("baz");
|
||||||
|
await 0;
|
||||||
|
console.log("moo");
|
||||||
|
})().then(console.log);
|
||||||
|
console.log("moz");
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"foo",
|
||||||
|
"bar",
|
||||||
|
"moz",
|
||||||
|
"baz",
|
||||||
|
"moo",
|
||||||
|
"undefined",
|
||||||
|
]
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
|
inline_block_await_async_return: {
|
||||||
|
options = {
|
||||||
|
awaits: true,
|
||||||
|
if_return: true,
|
||||||
|
inline: true,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log("foo");
|
||||||
|
(async function() {
|
||||||
|
console.log("bar");
|
||||||
|
await async function() {
|
||||||
|
for (var a of [ "baz" ])
|
||||||
|
return {
|
||||||
|
then(r) {
|
||||||
|
console.log("moo");
|
||||||
|
r(a);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}();
|
||||||
|
})().then(console.log);
|
||||||
|
console.log("moz");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log("foo");
|
||||||
|
(async function() {
|
||||||
|
console.log("bar");
|
||||||
|
for (var a of [ "baz" ])
|
||||||
|
return void await {
|
||||||
|
then(r) {
|
||||||
|
console.log("moo");
|
||||||
|
r(a);
|
||||||
|
},
|
||||||
|
};;
|
||||||
|
})().then(console.log);
|
||||||
|
console.log("moz");
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"foo",
|
||||||
|
"bar",
|
||||||
|
"moz",
|
||||||
|
"moo",
|
||||||
|
"undefined",
|
||||||
|
]
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
|
inline_block_return: {
|
||||||
|
options = {
|
||||||
|
awaits: true,
|
||||||
|
if_return: true,
|
||||||
|
inline: true,
|
||||||
|
passes: 2,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log("foo");
|
||||||
|
(async function() {
|
||||||
|
console.log("bar");
|
||||||
|
return async function() {
|
||||||
|
for (var a of [ "baz" ])
|
||||||
|
return a;
|
||||||
|
}();
|
||||||
|
})().then(console.log);
|
||||||
|
console.log("moo");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log("foo");
|
||||||
|
(async function() {
|
||||||
|
console.log("bar");
|
||||||
|
for (var a of [ "baz" ])
|
||||||
|
return a;
|
||||||
|
})().then(console.log);
|
||||||
|
console.log("moo");
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"foo",
|
||||||
|
"bar",
|
||||||
|
"moo",
|
||||||
|
"baz",
|
||||||
|
]
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
|
inline_block_return_async: {
|
||||||
|
options = {
|
||||||
|
awaits: true,
|
||||||
|
if_return: true,
|
||||||
|
inline: true,
|
||||||
|
passes: 2,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log("foo");
|
||||||
|
(async function() {
|
||||||
|
console.log("bar");
|
||||||
|
return async function() {
|
||||||
|
for (var a of [ "baz" ])
|
||||||
|
return {
|
||||||
|
then(r) {
|
||||||
|
console.log("moo");
|
||||||
|
r(a);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}();
|
||||||
|
})().then(console.log);
|
||||||
|
console.log("moz");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log("foo");
|
||||||
|
(async function() {
|
||||||
|
console.log("bar");
|
||||||
|
for (var a of [ "baz" ])
|
||||||
|
return {
|
||||||
|
then(r) {
|
||||||
|
console.log("moo");
|
||||||
|
r(a);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
})().then(console.log);
|
||||||
|
console.log("moz");
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"foo",
|
||||||
|
"bar",
|
||||||
|
"moz",
|
||||||
|
"moo",
|
||||||
|
"baz",
|
||||||
|
]
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
|
await_then: {
|
||||||
|
options = {
|
||||||
|
awaits: true,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = "PASS";
|
||||||
|
function f() {
|
||||||
|
return {
|
||||||
|
then: function(r) {
|
||||||
|
a = "FAIL";
|
||||||
|
r();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
(async function() {
|
||||||
|
f(), await 42;
|
||||||
|
while (console.log(a));
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = "PASS";
|
||||||
|
function f() {
|
||||||
|
return {
|
||||||
|
then: function(r) {
|
||||||
|
a = "FAIL";
|
||||||
|
r();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
(async function() {
|
||||||
|
await !f();
|
||||||
|
while (console.log(a));
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
|
await_unary_1: {
|
||||||
|
options = {
|
||||||
|
awaits: true,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = "PASS";
|
||||||
|
function f() {
|
||||||
|
return {
|
||||||
|
then: function(r) {
|
||||||
|
a = "FAIL";
|
||||||
|
r();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
(async function() {
|
||||||
|
await !f();
|
||||||
|
while (console.log(a));
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = "PASS";
|
||||||
|
function f() {
|
||||||
|
return {
|
||||||
|
then: function(r) {
|
||||||
|
a = "FAIL";
|
||||||
|
r();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
(async function() {
|
||||||
|
await !f();
|
||||||
|
while (console.log(a));
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
|
await_unary_2: {
|
||||||
|
options = {
|
||||||
|
awaits: true,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = "PASS";
|
||||||
|
function f() {
|
||||||
|
return {
|
||||||
|
then: function(r) {
|
||||||
|
a = "FAIL";
|
||||||
|
r();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
(async function() {
|
||||||
|
await ~f();
|
||||||
|
while (console.log(a));
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = "PASS";
|
||||||
|
function f() {
|
||||||
|
return {
|
||||||
|
then: function(r) {
|
||||||
|
a = "FAIL";
|
||||||
|
r();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
(async function() {
|
||||||
|
await !f();
|
||||||
|
while (console.log(a));
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
|
await_unary_3: {
|
||||||
options = {
|
options = {
|
||||||
awaits: true,
|
awaits: true,
|
||||||
side_effects: true,
|
side_effects: true,
|
||||||
@@ -367,7 +839,46 @@ await_unary: {
|
|||||||
node_version: ">=8"
|
node_version: ">=8"
|
||||||
}
|
}
|
||||||
|
|
||||||
await_void: {
|
await_void_1: {
|
||||||
|
options = {
|
||||||
|
awaits: true,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = "PASS";
|
||||||
|
function f() {
|
||||||
|
return {
|
||||||
|
then: function(r) {
|
||||||
|
a = "FAIL";
|
||||||
|
r();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
(async function() {
|
||||||
|
await void f();
|
||||||
|
while (console.log(a));
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = "PASS";
|
||||||
|
function f() {
|
||||||
|
return {
|
||||||
|
then: function(r) {
|
||||||
|
a = "FAIL";
|
||||||
|
r();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
(async function() {
|
||||||
|
await !f();
|
||||||
|
while (console.log(a));
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
|
await_void_2: {
|
||||||
options = {
|
options = {
|
||||||
awaits: true,
|
awaits: true,
|
||||||
if_return: true,
|
if_return: true,
|
||||||
@@ -382,7 +893,7 @@ await_void: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
(async function() {
|
(async function() {
|
||||||
await console.log("PASS");
|
console.log("PASS");
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
@@ -1235,10 +1746,10 @@ issue_4454_2: {
|
|||||||
f("PASS");
|
f("PASS");
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
function f(b) {
|
function f(a) {
|
||||||
(async function(c = console.log(b)) {})();
|
(async function(c = console.log(a)) {})();
|
||||||
var b = 42..toString();
|
var a = 42..toString();
|
||||||
console.log(b);
|
console.log(a);
|
||||||
}
|
}
|
||||||
f("PASS");
|
f("PASS");
|
||||||
}
|
}
|
||||||
@@ -1938,9 +2449,9 @@ issue_5032_normal: {
|
|||||||
console.log(value);
|
console.log(value);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
async function f(c) {
|
async function f(a) {
|
||||||
var b = log(c), c = b;
|
var a = log(a), c = a;
|
||||||
log(b);
|
log(a);
|
||||||
log(c);
|
log(c);
|
||||||
}
|
}
|
||||||
f("PASS");
|
f("PASS");
|
||||||
@@ -2238,3 +2749,213 @@ issue_5177: {
|
|||||||
expect_stdout: "function"
|
expect_stdout: "function"
|
||||||
node_version: ">=8"
|
node_version: ">=8"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5250: {
|
||||||
|
options = {
|
||||||
|
inline: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(async function() {
|
||||||
|
await function() {
|
||||||
|
while (console.log("foo"));
|
||||||
|
}();
|
||||||
|
console.log("bar");
|
||||||
|
})();
|
||||||
|
console.log("baz");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(async function() {
|
||||||
|
while (console.log("foo"));
|
||||||
|
await 0;
|
||||||
|
console.log("bar");
|
||||||
|
})();
|
||||||
|
console.log("baz");
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"foo",
|
||||||
|
"baz",
|
||||||
|
"bar",
|
||||||
|
]
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5258_1: {
|
||||||
|
options = {
|
||||||
|
awaits: true,
|
||||||
|
inline: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(async function() {
|
||||||
|
(async function() {
|
||||||
|
throw "FAIL";
|
||||||
|
})();
|
||||||
|
return "PASS";
|
||||||
|
})().catch(console.log).then(console.log);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(async function() {
|
||||||
|
(async function() {
|
||||||
|
throw "FAIL";
|
||||||
|
})();
|
||||||
|
return "PASS";
|
||||||
|
})().catch(console.log).then(console.log);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5258_2: {
|
||||||
|
options = {
|
||||||
|
awaits: true,
|
||||||
|
inline: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f() {
|
||||||
|
throw "FAIL";
|
||||||
|
}
|
||||||
|
(async function() {
|
||||||
|
(async function() {
|
||||||
|
f();
|
||||||
|
})();
|
||||||
|
return "PASS";
|
||||||
|
})().catch(console.log).then(console.log);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f() {
|
||||||
|
throw "FAIL";
|
||||||
|
}
|
||||||
|
(async function() {
|
||||||
|
(async function() {
|
||||||
|
f();
|
||||||
|
})();
|
||||||
|
return "PASS";
|
||||||
|
})().catch(console.log).then(console.log);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5298: {
|
||||||
|
options = {
|
||||||
|
awaits: true,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = "PASS";
|
||||||
|
(async function() {
|
||||||
|
for (a in [ 42 in null ]);
|
||||||
|
})();
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = "PASS";
|
||||||
|
(async function() {
|
||||||
|
for (a in [ 42 in null ]);
|
||||||
|
})();
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5305_1: {
|
||||||
|
options = {
|
||||||
|
inline: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = "PASS";
|
||||||
|
(async function() {
|
||||||
|
try {
|
||||||
|
return await function() {
|
||||||
|
while (!console);
|
||||||
|
}();
|
||||||
|
} finally {
|
||||||
|
a = "FAIL";
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = "PASS";
|
||||||
|
(async function() {
|
||||||
|
try {
|
||||||
|
while (!console);
|
||||||
|
return await void 0;
|
||||||
|
} finally {
|
||||||
|
a = "FAIL";
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5305_2: {
|
||||||
|
options = {
|
||||||
|
inline: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = "PASS";
|
||||||
|
(async function() {
|
||||||
|
try {
|
||||||
|
throw null;
|
||||||
|
} catch (e) {
|
||||||
|
return await function() {
|
||||||
|
while (!console);
|
||||||
|
}();
|
||||||
|
} finally {
|
||||||
|
a = "FAIL";
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = "PASS";
|
||||||
|
(async function() {
|
||||||
|
try {
|
||||||
|
throw null;
|
||||||
|
} catch (e) {
|
||||||
|
while (!console);
|
||||||
|
return await void 0;
|
||||||
|
} finally {
|
||||||
|
a = "FAIL";
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5305_3: {
|
||||||
|
options = {
|
||||||
|
awaits: true,
|
||||||
|
inline: true,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = "PASS";
|
||||||
|
(async function() {
|
||||||
|
try {
|
||||||
|
await function() {
|
||||||
|
while (!console);
|
||||||
|
}();
|
||||||
|
} catch (e) {
|
||||||
|
a = "FAIL";
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = "PASS";
|
||||||
|
try {
|
||||||
|
while (!console);
|
||||||
|
} catch (e) {
|
||||||
|
a = "FAIL";
|
||||||
|
}
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ arithmetic: {
|
|||||||
}
|
}
|
||||||
expect_exact: "console.log((1n+0x2n)*(0o3n- -4n)>>5n-6n);"
|
expect_exact: "console.log((1n+0x2n)*(0o3n- -4n)>>5n-6n);"
|
||||||
expect_stdout: "42n"
|
expect_stdout: "42n"
|
||||||
node_version: ">=10"
|
node_version: ">=10.4.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
minus_dot: {
|
minus_dot: {
|
||||||
@@ -13,7 +13,7 @@ minus_dot: {
|
|||||||
}
|
}
|
||||||
expect_exact: "console.log(typeof-42n.toString(),typeof(-42n).toString());"
|
expect_exact: "console.log(typeof-42n.toString(),typeof(-42n).toString());"
|
||||||
expect_stdout: "number string"
|
expect_stdout: "number string"
|
||||||
node_version: ">=10"
|
node_version: ">=10.4.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
evaluate: {
|
evaluate: {
|
||||||
@@ -28,7 +28,7 @@ evaluate: {
|
|||||||
console.log(0xdeadbeefn.toString(16));
|
console.log(0xdeadbeefn.toString(16));
|
||||||
}
|
}
|
||||||
expect_stdout: "deadbeef"
|
expect_stdout: "deadbeef"
|
||||||
node_version: ">=10"
|
node_version: ">=10.4.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
Number: {
|
Number: {
|
||||||
@@ -42,7 +42,7 @@ Number: {
|
|||||||
console.log(+("" + -0xfeed_dead_beef_badn));
|
console.log(+("" + -0xfeed_dead_beef_badn));
|
||||||
}
|
}
|
||||||
expect_stdout: "-1148098955808013200"
|
expect_stdout: "-1148098955808013200"
|
||||||
node_version: ">=10"
|
node_version: ">=10.4.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_4590: {
|
issue_4590: {
|
||||||
@@ -58,7 +58,7 @@ issue_4590: {
|
|||||||
0n || console.log("PASS");
|
0n || console.log("PASS");
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=10"
|
node_version: ">=10.4.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_4801: {
|
issue_4801: {
|
||||||
@@ -88,5 +88,5 @@ issue_4801: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=10"
|
node_version: ">=10.4.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -697,3 +697,30 @@ issue_5041_2: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5228: {
|
||||||
|
options = {
|
||||||
|
booleans: true,
|
||||||
|
evaluate: true,
|
||||||
|
inline: true,
|
||||||
|
passes: 2,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(function() {
|
||||||
|
return !function() {
|
||||||
|
do {
|
||||||
|
return null;
|
||||||
|
} while (console);
|
||||||
|
}();
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(function() {
|
||||||
|
do {
|
||||||
|
return !0;
|
||||||
|
} while (console);
|
||||||
|
return !0;
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect_stdout: "true"
|
||||||
|
}
|
||||||
|
|||||||
@@ -434,6 +434,33 @@ static_side_effects: {
|
|||||||
console.log(a);
|
console.log(a);
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
|
var a = "FAIL 1";
|
||||||
|
(class {
|
||||||
|
static c = a = "PASS";
|
||||||
|
});
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=12"
|
||||||
|
}
|
||||||
|
|
||||||
|
static_side_effects_strict: {
|
||||||
|
options = {
|
||||||
|
inline: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
var a = "FAIL 1";
|
||||||
|
class A {
|
||||||
|
static p = a = "PASS";
|
||||||
|
q = a = "FAIL 2";
|
||||||
|
}
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
var a = "FAIL 1";
|
var a = "FAIL 1";
|
||||||
a = "PASS";
|
a = "PASS";
|
||||||
console.log(a);
|
console.log(a);
|
||||||
@@ -807,6 +834,33 @@ unused_await: {
|
|||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
|
var await = "PASS";
|
||||||
|
(async function() {
|
||||||
|
(class {
|
||||||
|
static c = console.log(await);
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect_stdout: true
|
||||||
|
node_version: ">=12 <16"
|
||||||
|
}
|
||||||
|
|
||||||
|
unused_await_strict: {
|
||||||
|
options = {
|
||||||
|
inline: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
var await = "PASS";
|
||||||
|
(async function() {
|
||||||
|
class A {
|
||||||
|
static p = console.log(await);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
var await = "PASS";
|
var await = "PASS";
|
||||||
(async function() {
|
(async function() {
|
||||||
(() => console.log(await))();
|
(() => console.log(await))();
|
||||||
@@ -890,7 +944,7 @@ keep_fnames: {
|
|||||||
issue_805_1: {
|
issue_805_1: {
|
||||||
options = {
|
options = {
|
||||||
inline: true,
|
inline: true,
|
||||||
passes: 2,
|
passes: 3,
|
||||||
pure_getters: "strict",
|
pure_getters: "strict",
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
sequences: true,
|
sequences: true,
|
||||||
@@ -926,7 +980,7 @@ issue_805_1: {
|
|||||||
issue_805_2: {
|
issue_805_2: {
|
||||||
options = {
|
options = {
|
||||||
inline: true,
|
inline: true,
|
||||||
passes: 2,
|
passes: 3,
|
||||||
pure_getters: "strict",
|
pure_getters: "strict",
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
sequences: true,
|
sequences: true,
|
||||||
@@ -1149,6 +1203,31 @@ issue_4705: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
|
(class {
|
||||||
|
[console.log("PASS")]() {}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=12"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_4705_strict: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
var a = "PASS";
|
||||||
|
class A {
|
||||||
|
p = a = "FAIL";
|
||||||
|
[console.log(a)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
console.log("PASS");
|
console.log("PASS");
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
@@ -1310,6 +1389,7 @@ issue_4725_1: {
|
|||||||
|
|
||||||
issue_4725_2: {
|
issue_4725_2: {
|
||||||
options = {
|
options = {
|
||||||
|
if_return: true,
|
||||||
inline: true,
|
inline: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
@@ -1370,9 +1450,40 @@ issue_4756: {
|
|||||||
expect: {
|
expect: {
|
||||||
try {
|
try {
|
||||||
(class extends 42 {
|
(class extends 42 {
|
||||||
[console.log("foo")]() {}
|
static [console.log("foo")] = console.log("bar");
|
||||||
}),
|
});
|
||||||
(() => console.log("bar"))();
|
} catch (e) {
|
||||||
|
console.log("baz");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"foo",
|
||||||
|
"baz",
|
||||||
|
]
|
||||||
|
node_version: ">=12"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_4756_strict: {
|
||||||
|
options = {
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
try {
|
||||||
|
class A extends 42 {
|
||||||
|
static [console.log("foo")] = console.log("bar");
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log("baz");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
try {
|
||||||
|
(class extends 42 {
|
||||||
|
static [console.log("foo")] = console.log("bar");
|
||||||
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("baz");
|
console.log("baz");
|
||||||
}
|
}
|
||||||
@@ -1439,7 +1550,7 @@ issue_4829_1: {
|
|||||||
input: {
|
input: {
|
||||||
"use strict";
|
"use strict";
|
||||||
try {
|
try {
|
||||||
class A extends { f(){} }.f {}
|
class A extends { f() {} }.f {}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("PASS");
|
console.log("PASS");
|
||||||
}
|
}
|
||||||
@@ -1646,9 +1757,38 @@ issue_4962_1: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
(function g() {}),
|
(function g() {}),
|
||||||
void function() {
|
void class {
|
||||||
|
static c = function() {
|
||||||
while (console.log(typeof g));
|
while (console.log(typeof g));
|
||||||
}();
|
}();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
expect_stdout: "undefined"
|
||||||
|
node_version: ">=12"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_4962_1_strict: {
|
||||||
|
options = {
|
||||||
|
ie: true,
|
||||||
|
inline: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
(function() {
|
||||||
|
function f() {
|
||||||
|
while (console.log(typeof g));
|
||||||
|
}
|
||||||
|
class A {
|
||||||
|
static p = f();
|
||||||
|
}
|
||||||
|
})(function g() {});
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
(function g() {});
|
||||||
|
while (console.log(typeof g));
|
||||||
}
|
}
|
||||||
expect_stdout: "undefined"
|
expect_stdout: "undefined"
|
||||||
node_version: ">=12"
|
node_version: ">=12"
|
||||||
@@ -1672,6 +1812,36 @@ issue_4962_2: {
|
|||||||
}, typeof g));
|
}, typeof g));
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
|
console.log(function f() {}(function g() {
|
||||||
|
(class {
|
||||||
|
static c = f;
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
expect_stdout: "undefined"
|
||||||
|
node_version: ">=12"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_4962_2_strict: {
|
||||||
|
options = {
|
||||||
|
ie: true,
|
||||||
|
inline: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
console.log(function f() {}(function g() {
|
||||||
|
function h() {
|
||||||
|
f;
|
||||||
|
}
|
||||||
|
class A {
|
||||||
|
static p = h();
|
||||||
|
}
|
||||||
|
}, typeof g));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
console.log(function f() {}(function g() {
|
console.log(function f() {}(function g() {
|
||||||
f;
|
f;
|
||||||
}));
|
}));
|
||||||
@@ -1868,6 +2038,32 @@ issue_5015_3: {
|
|||||||
});
|
});
|
||||||
console.log("PASS");
|
console.log("PASS");
|
||||||
}
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
(class A {});
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5015_4: {
|
||||||
|
options = {
|
||||||
|
reduce_vars: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
(class A {
|
||||||
|
static f() {
|
||||||
|
return A;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
expect: {
|
expect: {
|
||||||
"use strict";
|
"use strict";
|
||||||
console.log("PASS");
|
console.log("PASS");
|
||||||
@@ -2027,6 +2223,40 @@ issue_5082_1: {
|
|||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
|
(function() {
|
||||||
|
class A {
|
||||||
|
p = console.log("PASS");
|
||||||
|
q() {}
|
||||||
|
}
|
||||||
|
(class {
|
||||||
|
static c = new A();
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=12"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5082_1_strict: {
|
||||||
|
options = {
|
||||||
|
inline: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
(function() {
|
||||||
|
class A {
|
||||||
|
p = console.log("PASS");
|
||||||
|
q() {}
|
||||||
|
}
|
||||||
|
class B {
|
||||||
|
static P = new A();
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
(function() {
|
(function() {
|
||||||
class A {
|
class A {
|
||||||
p = console.log("PASS");
|
p = console.log("PASS");
|
||||||
@@ -2058,6 +2288,41 @@ issue_5082_2: {
|
|||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
|
(function() {
|
||||||
|
class A {
|
||||||
|
p = console.log("PASS");
|
||||||
|
q() {}
|
||||||
|
}
|
||||||
|
(class {
|
||||||
|
static c = new A();
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=12"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5082_2_static: {
|
||||||
|
options = {
|
||||||
|
inline: true,
|
||||||
|
passes: 2,
|
||||||
|
reduce_vars: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
(function() {
|
||||||
|
class A {
|
||||||
|
p = console.log("PASS");
|
||||||
|
q() {}
|
||||||
|
}
|
||||||
|
class B {
|
||||||
|
static P = new A();
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
void new class {
|
void new class {
|
||||||
p = console.log("PASS");
|
p = console.log("PASS");
|
||||||
q() {}
|
q() {}
|
||||||
@@ -2097,3 +2362,90 @@ issue_5142: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=12"
|
node_version: ">=12"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5294_1: {
|
||||||
|
options = {
|
||||||
|
reduce_vars: true,
|
||||||
|
side_effects: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(class A {
|
||||||
|
static p = console.log(typeof A);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(class A {
|
||||||
|
static c = console.log(typeof A);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect_stdout: "function"
|
||||||
|
node_version: ">=12"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5294_2: {
|
||||||
|
options = {
|
||||||
|
reduce_vars: true,
|
||||||
|
side_effects: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
class A {
|
||||||
|
static p = console.log(typeof A);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
class A {
|
||||||
|
static p = console.log(typeof A);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: "function"
|
||||||
|
node_version: ">=12"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5294_3: {
|
||||||
|
options = {
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = this;
|
||||||
|
(class A {
|
||||||
|
static p = console.log(a === A ? "FAIL" : "PASS");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = this;
|
||||||
|
(class A {
|
||||||
|
static p = console.log(a === A ? "FAIL" : "PASS");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=12"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5294_4: {
|
||||||
|
options = {
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(class A {
|
||||||
|
static p = function() {
|
||||||
|
var a = this;
|
||||||
|
console.log(a === A ? "FAIL" : "PASS");
|
||||||
|
}();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(class A {
|
||||||
|
static p = function() {
|
||||||
|
console.log(this === A ? "FAIL" : "PASS");
|
||||||
|
}();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=12"
|
||||||
|
}
|
||||||
|
|||||||
@@ -346,9 +346,7 @@ collapse_vars_if: {
|
|||||||
return "x" != "Bar" + x / 4 ? g9 : g5;
|
return "x" != "Bar" + x / 4 ? g9 : g5;
|
||||||
}
|
}
|
||||||
function f3(x) {
|
function f3(x) {
|
||||||
if (x)
|
return x ? 1 : 2;
|
||||||
return 1;
|
|
||||||
return 2;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1912,6 +1910,42 @@ collapse_vars_regexp: {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
collapse_arg_sequence: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(function(a) {
|
||||||
|
a("foo");
|
||||||
|
})((console.log("bar"), console.log));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(function(a) {
|
||||||
|
(0, console.log)("foo");
|
||||||
|
})(console.log("bar"));
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"bar",
|
||||||
|
"foo",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
collapse_for_init: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
for (var a = (Math, console), b = a.log("PASS"); b;);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
Math;
|
||||||
|
for (var a, b = console.log("PASS"); b;);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
issue_1537: {
|
issue_1537: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars: true,
|
collapse_vars: true,
|
||||||
@@ -2667,6 +2701,24 @@ chained_4: {
|
|||||||
expect_stdout: "foo undefined"
|
expect_stdout: "foo undefined"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
chained_5: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = "PASS";
|
||||||
|
var a = (console, console.log(a));
|
||||||
|
a && ++a;
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = "PASS";
|
||||||
|
console;
|
||||||
|
var a;
|
||||||
|
(a = console.log(a)) && ++a;
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
boolean_binary_1: {
|
boolean_binary_1: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars: true,
|
collapse_vars: true,
|
||||||
@@ -2906,6 +2958,128 @@ compound_assignment_2: {
|
|||||||
expect_stdout: "4"
|
expect_stdout: "4"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
compound_assignment_3: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = 1;
|
||||||
|
a += (console.log("PASS"), 2);
|
||||||
|
a.p;
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = 1;
|
||||||
|
(a += (console.log("PASS"), 2)).p;
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
compound_assignment_4: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
evaluate: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
A = "PASS";
|
||||||
|
var a = "";
|
||||||
|
a += (a = "FAIL", A);
|
||||||
|
a.p;
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
A = "PASS";
|
||||||
|
var a = "";
|
||||||
|
(a += (a = "FAIL", A)).p;
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
compound_assignment_5: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = 0, b;
|
||||||
|
a += 42;
|
||||||
|
b && (a *= null);
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = 0, b;
|
||||||
|
a += 42;
|
||||||
|
b && (a *= null);
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect_stdout: "42"
|
||||||
|
}
|
||||||
|
|
||||||
|
compound_assignment_6: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a;
|
||||||
|
a ^= 6;
|
||||||
|
a *= a + 1;
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a;
|
||||||
|
a = (a ^= 6) * (a + 1);
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect_stdout: "42"
|
||||||
|
}
|
||||||
|
|
||||||
|
compound_assignment_7: {
|
||||||
|
options = {
|
||||||
|
assignments: true,
|
||||||
|
collapse_vars: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = "FA";
|
||||||
|
a = a + "I";
|
||||||
|
a = a + "L";
|
||||||
|
if (console)
|
||||||
|
a = "PASS";
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = "FA";
|
||||||
|
a = a + "I" + "L";
|
||||||
|
if (console)
|
||||||
|
a = "PASS";
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
compound_assignment_8: {
|
||||||
|
options = {
|
||||||
|
assignments: true,
|
||||||
|
collapse_vars: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = 2;
|
||||||
|
a = 3 * a;
|
||||||
|
a = 7 * a;
|
||||||
|
console || (a = "FAIL");
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = 2;
|
||||||
|
a = a * 3 * 7;
|
||||||
|
console || (a = "FAIL");
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect_stdout: "42"
|
||||||
|
}
|
||||||
|
|
||||||
issue_2187_1: {
|
issue_2187_1: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars: true,
|
collapse_vars: true,
|
||||||
@@ -3030,10 +3204,10 @@ issue_2203_2: {
|
|||||||
a: "FAIL",
|
a: "FAIL",
|
||||||
b: function() {
|
b: function() {
|
||||||
return function(c) {
|
return function(c) {
|
||||||
return (String, (Object, function() {
|
return (Object, function() {
|
||||||
return this;
|
return this;
|
||||||
}())).a;
|
}()).a;
|
||||||
}();
|
}(String);
|
||||||
}
|
}
|
||||||
}.b());
|
}.b());
|
||||||
}
|
}
|
||||||
@@ -3731,6 +3905,7 @@ issue_2437_1: {
|
|||||||
options = {
|
options = {
|
||||||
collapse_vars: true,
|
collapse_vars: true,
|
||||||
conditionals: true,
|
conditionals: true,
|
||||||
|
if_return: true,
|
||||||
inline: true,
|
inline: true,
|
||||||
join_vars: true,
|
join_vars: true,
|
||||||
passes: 2,
|
passes: 2,
|
||||||
@@ -3763,17 +3938,17 @@ issue_2437_1: {
|
|||||||
console.log(foo());
|
console.log(foo());
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
console.log(function() {
|
var req, detectFunc, result;
|
||||||
if (xhrDesc) {
|
console.log((
|
||||||
var result = !!(req = new XMLHttpRequest()).onreadystatechange;
|
xhrDesc ? (result = !!(req = new XMLHttpRequest).onreadystatechange,
|
||||||
return Object.defineProperty(XMLHttpRequest.prototype, "onreadystatechange", xhrDesc || {}),
|
Object.defineProperty(XMLHttpRequest.prototype, "onreadystatechange", xhrDesc||{})
|
||||||
result;
|
) : (
|
||||||
}
|
(req = new XMLHttpRequest).onreadystatechange = detectFunc = function(){},
|
||||||
var req = new XMLHttpRequest(), detectFunc = function(){};
|
|
||||||
return req.onreadystatechange = detectFunc,
|
|
||||||
result = req[SYMBOL_FAKE_ONREADYSTATECHANGE_1] === detectFunc,
|
result = req[SYMBOL_FAKE_ONREADYSTATECHANGE_1] === detectFunc,
|
||||||
req.onreadystatechange = null, result;
|
req.onreadystatechange = null
|
||||||
}());
|
),
|
||||||
|
result
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3783,6 +3958,7 @@ issue_2437_2: {
|
|||||||
conditionals: true,
|
conditionals: true,
|
||||||
inline: true,
|
inline: true,
|
||||||
join_vars: true,
|
join_vars: true,
|
||||||
|
negate_iife: true,
|
||||||
passes: 3,
|
passes: 3,
|
||||||
reduce_funcs: true,
|
reduce_funcs: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
@@ -3813,15 +3989,15 @@ issue_2437_2: {
|
|||||||
foo();
|
foo();
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
!function() {
|
var req;
|
||||||
if (xhrDesc)
|
xhrDesc ? (
|
||||||
return (req = new XMLHttpRequest()).onreadystatechange,
|
(req = new XMLHttpRequest).onreadystatechange,
|
||||||
Object.defineProperty(XMLHttpRequest.prototype, "onreadystatechange", xhrDesc || {});
|
Object.defineProperty(XMLHttpRequest.prototype, "onreadystatechange", xhrDesc || {})
|
||||||
var req = new XMLHttpRequest();
|
) : (
|
||||||
req.onreadystatechange = function(){},
|
(req = new XMLHttpRequest).onreadystatechange = function(){},
|
||||||
req[SYMBOL_FAKE_ONREADYSTATECHANGE_1],
|
req[SYMBOL_FAKE_ONREADYSTATECHANGE_1],
|
||||||
req.onreadystatechange = null;
|
req.onreadystatechange = null
|
||||||
}();
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6443,7 +6619,8 @@ assign_undeclared: {
|
|||||||
console.log(typeof B);
|
console.log(typeof B);
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
B = new (console.log(42), function() {})();
|
console.log(42);
|
||||||
|
B = new function() {}();
|
||||||
console.log(typeof B);
|
console.log(typeof B);
|
||||||
}
|
}
|
||||||
expect_stdout: [
|
expect_stdout: [
|
||||||
@@ -8156,9 +8333,9 @@ issue_3884_1: {
|
|||||||
console.log(a, b);
|
console.log(a, b);
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
var a = 100, b = 1;
|
var a = 100;
|
||||||
b <<= ++a;
|
++a;
|
||||||
console.log(a, b);
|
console.log(a, 32);
|
||||||
}
|
}
|
||||||
expect_stdout: "101 32"
|
expect_stdout: "101 32"
|
||||||
}
|
}
|
||||||
@@ -9139,9 +9316,7 @@ issue_4908: {
|
|||||||
console.log(d[1]);
|
console.log(d[1]);
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
var a = 0, b;
|
var a = 0, b, c = (console || a++, a), d = [ (d = a) && d, d += 42 ];
|
||||||
console || a++;
|
|
||||||
var c = a, d = [ (d = a) && d, d += 42 ];
|
|
||||||
console.log(d[1]);
|
console.log(d[1]);
|
||||||
}
|
}
|
||||||
expect_stdout: "42"
|
expect_stdout: "42"
|
||||||
@@ -9374,9 +9549,8 @@ inline_throw: {
|
|||||||
expect: {
|
expect: {
|
||||||
try {
|
try {
|
||||||
(function(a) {
|
(function(a) {
|
||||||
return function() {
|
|
||||||
throw a;
|
throw a;
|
||||||
}();
|
return;
|
||||||
})("PASS");
|
})("PASS");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
@@ -9566,3 +9740,108 @@ issue_5182: {
|
|||||||
]
|
]
|
||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5273: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
evaluate: true,
|
||||||
|
inline: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
sequences: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = "10", b = 1;
|
||||||
|
function f(c, d) {
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
f((b += a, b *= a), f);
|
||||||
|
console.log(b);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = "10", b = 1;
|
||||||
|
function f(c, d) {
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
b = 1100,
|
||||||
|
f,
|
||||||
|
console.log(b);
|
||||||
|
}
|
||||||
|
expect_stdout: "1100"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5276: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
pure_getters: "strict",
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = A = "PASS";
|
||||||
|
a.p += null;
|
||||||
|
a.p -= 42;
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = A = "PASS";
|
||||||
|
a.p = a.p + null - 42;
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5277: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(function() {
|
||||||
|
var a = function() {
|
||||||
|
a += null;
|
||||||
|
a -= 42;
|
||||||
|
};
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(function() {}());
|
||||||
|
}
|
||||||
|
expect_stdout: "undefined"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5309_1: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
conditionals: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
if (console)
|
||||||
|
var a = (console.log("PASS"), b), b = a;
|
||||||
|
else
|
||||||
|
console.log("FAIL");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a, b;
|
||||||
|
console ? (console.log("PASS"), b = b) : console.log("FAIL");
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5309_2: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a, b;
|
||||||
|
console ? (a = (console.log("PASS"), b), b = a) : console.log("FAIL");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a, b;
|
||||||
|
console ? (console.log("PASS"), b = b) : console.log("FAIL");
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|||||||
@@ -1924,3 +1924,86 @@ object_super: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5232_1: {
|
||||||
|
options = {
|
||||||
|
conditionals: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(function() {
|
||||||
|
if (Math) {
|
||||||
|
function f() {}
|
||||||
|
for (var a in [ 42 ])
|
||||||
|
console.log(typeof f);
|
||||||
|
} else {
|
||||||
|
var b = null;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(function() {
|
||||||
|
var b;
|
||||||
|
if (!Math)
|
||||||
|
return b = null, true;
|
||||||
|
function f() {}
|
||||||
|
for (var a in [ 42 ]) console.log(typeof f);
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect_stdout: "function"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5232_2: {
|
||||||
|
options = {
|
||||||
|
conditionals: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(function() {
|
||||||
|
if (!Math);
|
||||||
|
else {
|
||||||
|
var b = null;
|
||||||
|
return "PASS";
|
||||||
|
}
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(function() {
|
||||||
|
var b;
|
||||||
|
if (Math)
|
||||||
|
return b = null, "PASS";
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5232_3: {
|
||||||
|
options = {
|
||||||
|
conditionals: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(function() {
|
||||||
|
return function() {
|
||||||
|
if (console)
|
||||||
|
console.log("PASS");
|
||||||
|
else {
|
||||||
|
var a = null;
|
||||||
|
return "FAIL";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}()());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(function() {
|
||||||
|
return function() {
|
||||||
|
var a;
|
||||||
|
if (!console)
|
||||||
|
return a = null, "FAIL";
|
||||||
|
console.log("PASS");
|
||||||
|
};
|
||||||
|
}()());
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"PASS",
|
||||||
|
"undefined",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|||||||
@@ -220,6 +220,32 @@ merge_vars_3: {
|
|||||||
expect_stdout: true
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
merge_vars_4: {
|
||||||
|
options = {
|
||||||
|
merge_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = 1;
|
||||||
|
console.log(typeof a);
|
||||||
|
{
|
||||||
|
var b = console;
|
||||||
|
console.log(typeof b);
|
||||||
|
const a = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = 1;
|
||||||
|
console.log(typeof a);
|
||||||
|
{
|
||||||
|
var b = console;
|
||||||
|
console.log(typeof b);
|
||||||
|
const a = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: true
|
||||||
|
}
|
||||||
|
|
||||||
use_before_init_1: {
|
use_before_init_1: {
|
||||||
options = {
|
options = {
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
@@ -838,12 +864,10 @@ issue_4202: {
|
|||||||
expect: {
|
expect: {
|
||||||
{
|
{
|
||||||
const o = {};
|
const o = {};
|
||||||
(function() {
|
|
||||||
function f() {
|
function f() {
|
||||||
o.p = 42;
|
o.p = 42;
|
||||||
}
|
}
|
||||||
f(f);
|
f(f);
|
||||||
})();
|
|
||||||
console.log(o.p++);
|
console.log(o.p++);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1219,9 +1243,9 @@ issue_4248: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_4261: {
|
issue_4261_1: {
|
||||||
options = {
|
options = {
|
||||||
inline: true,
|
inline: 3,
|
||||||
reduce_funcs: true,
|
reduce_funcs: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
toplevel: true,
|
toplevel: true,
|
||||||
@@ -1259,6 +1283,43 @@ issue_4261: {
|
|||||||
expect_stdout: "42"
|
expect_stdout: "42"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_4261_2: {
|
||||||
|
options = {
|
||||||
|
if_return: true,
|
||||||
|
inline: true,
|
||||||
|
reduce_funcs: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
{
|
||||||
|
const a = 42;
|
||||||
|
(function() {
|
||||||
|
function f() {
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
function g() {
|
||||||
|
while (f());
|
||||||
|
}
|
||||||
|
(function() {
|
||||||
|
while (g());
|
||||||
|
})();
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
{
|
||||||
|
const a = 42;
|
||||||
|
function g() {
|
||||||
|
while (void console.log(a));
|
||||||
|
}
|
||||||
|
while (g());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: "42"
|
||||||
|
}
|
||||||
|
|
||||||
issue_4274_1: {
|
issue_4274_1: {
|
||||||
options = {
|
options = {
|
||||||
loops: true,
|
loops: true,
|
||||||
@@ -1692,3 +1753,63 @@ issue_4965_2: {
|
|||||||
expect_stdout: "undefined"
|
expect_stdout: "undefined"
|
||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5254: {
|
||||||
|
options = {
|
||||||
|
inline: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
do {
|
||||||
|
(function() {
|
||||||
|
const a = console.log;
|
||||||
|
a && a("foo");
|
||||||
|
})();
|
||||||
|
} while (console.log("bar"));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
do {
|
||||||
|
const a = console.log;
|
||||||
|
a && a("foo");
|
||||||
|
} while (console.log("bar"));
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"foo",
|
||||||
|
"bar",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5260: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
var a = "foo", o;
|
||||||
|
while (console.log("bar"));
|
||||||
|
o = {
|
||||||
|
baz: function(b) {
|
||||||
|
console.log(a, b);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
for (const a in o)
|
||||||
|
o[a](a);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
var a = "foo", o;
|
||||||
|
while (console.log("bar"));
|
||||||
|
o = {
|
||||||
|
baz: function(b) {
|
||||||
|
console.log(a, b);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
for (const a in o)
|
||||||
|
o[a](a);
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"bar",
|
||||||
|
"foo baz",
|
||||||
|
]
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|||||||
@@ -158,6 +158,28 @@ process_boolean_returns: {
|
|||||||
node_version: ">=6"
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
collapse_arg_sequence: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(function(a = (console.log("bar"), console.log)) {
|
||||||
|
a("foo");
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(function(a = console.log("bar")) {
|
||||||
|
(0, console.log)("foo");
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"bar",
|
||||||
|
"foo",
|
||||||
|
]
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|
||||||
collapse_value_1: {
|
collapse_value_1: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars: true,
|
collapse_vars: true,
|
||||||
@@ -1037,7 +1059,7 @@ mangle_arrow_1: {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=6"
|
node_version: ">=6.9.3"
|
||||||
}
|
}
|
||||||
|
|
||||||
mangle_arrow_1_toplevel: {
|
mangle_arrow_1_toplevel: {
|
||||||
@@ -1073,7 +1095,7 @@ mangle_arrow_1_toplevel: {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=6"
|
node_version: ">=6.9.3"
|
||||||
}
|
}
|
||||||
|
|
||||||
mangle_arrow_2: {
|
mangle_arrow_2: {
|
||||||
@@ -1109,7 +1131,7 @@ mangle_arrow_2: {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=6"
|
node_version: ">=6.9.3"
|
||||||
}
|
}
|
||||||
|
|
||||||
mangle_arrow_2_toplevel: {
|
mangle_arrow_2_toplevel: {
|
||||||
@@ -1145,7 +1167,7 @@ mangle_arrow_2_toplevel: {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=6"
|
node_version: ">=6.9.3"
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_4444: {
|
issue_4444: {
|
||||||
@@ -1587,7 +1609,7 @@ issue_4510_2: {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=8"
|
node_version: ">=8.3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_4523: {
|
issue_4523: {
|
||||||
@@ -1866,7 +1888,7 @@ issue_5057_2: {
|
|||||||
|
|
||||||
issue_5057_3: {
|
issue_5057_3: {
|
||||||
options = {
|
options = {
|
||||||
inline: true,
|
inline: 3,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
@@ -1889,6 +1911,31 @@ issue_5057_3: {
|
|||||||
node_version: ">=6"
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5057_4: {
|
||||||
|
options = {
|
||||||
|
if_return: true,
|
||||||
|
inline: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(function(a) {
|
||||||
|
(function f(b) {
|
||||||
|
(function(a = console.log("FAIL 1")) {})(b);
|
||||||
|
console.log(a);
|
||||||
|
})("FAIL 2");
|
||||||
|
})("PASS");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(function(a) {
|
||||||
|
var b = "FAIL 2";
|
||||||
|
(function(a = console.log("FAIL 1")) {})(b);
|
||||||
|
console.log(a);
|
||||||
|
})("PASS");
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|
||||||
issue_5065: {
|
issue_5065: {
|
||||||
options = {
|
options = {
|
||||||
pure_getters: "strict",
|
pure_getters: "strict",
|
||||||
@@ -1957,3 +2004,80 @@ issue_5192: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=6"
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5246_1: {
|
||||||
|
options = {
|
||||||
|
pure_getters: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(function({} = 42) {
|
||||||
|
return "PASS";
|
||||||
|
}("foo"));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(function({} = 0) {
|
||||||
|
return "PASS";
|
||||||
|
}("foo"));
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
expect_warnings: [
|
||||||
|
"INFO: Dropping unused default argument value {}=42 [test/compress/default-values.js:1,29]",
|
||||||
|
"INFO: Dropping unused default argument value {}=0 [test/compress/default-values.js:1,29]",
|
||||||
|
]
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5246_2: {
|
||||||
|
options = {
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(function f(a = "FAIL", [] = 42) {
|
||||||
|
console.log(a);
|
||||||
|
})("PASS", []);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(function(a = "FAIL", []) {
|
||||||
|
console.log(a);
|
||||||
|
})("PASS", []);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5246_3: {
|
||||||
|
options = {
|
||||||
|
default_values: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(function f([ , {} ] = null){}([ , {} ]));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(function([ {} ]){}([ {} ]));
|
||||||
|
}
|
||||||
|
expect_stdout: "undefined"
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5256: {
|
||||||
|
options = {
|
||||||
|
inline: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(function(arguments = console.log) {
|
||||||
|
console;
|
||||||
|
})();
|
||||||
|
console.log(typeof arguments);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
// Syntax error on Node.js v6
|
||||||
|
(function(arguments = console.log) {
|
||||||
|
console;
|
||||||
|
})();
|
||||||
|
console.log(typeof arguments);
|
||||||
|
}
|
||||||
|
expect_stdout: "undefined"
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ funarg_side_effects_2: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=6"
|
node_version: ">=6.9.2"
|
||||||
}
|
}
|
||||||
|
|
||||||
funarg_side_effects_3: {
|
funarg_side_effects_3: {
|
||||||
@@ -254,7 +254,7 @@ funarg_side_effects_3: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=6"
|
node_version: ">=6.9.2"
|
||||||
}
|
}
|
||||||
|
|
||||||
funarg_unused_1: {
|
funarg_unused_1: {
|
||||||
@@ -395,7 +395,8 @@ funarg_unused_6_keep_fargs: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
(function() {
|
(function() {
|
||||||
var {} = (console, 42);
|
console;
|
||||||
|
var {} = 42;
|
||||||
})();
|
})();
|
||||||
console.log(typeof a);
|
console.log(typeof a);
|
||||||
}
|
}
|
||||||
@@ -1844,13 +1845,13 @@ issue_4294: {
|
|||||||
expect: {
|
expect: {
|
||||||
A = "PASS";
|
A = "PASS";
|
||||||
(function() {
|
(function() {
|
||||||
var b = function({
|
var a = function({
|
||||||
[b]: {},
|
[a]: {},
|
||||||
}) {}({
|
}) {}({
|
||||||
[b]: 0,
|
[a]: 0,
|
||||||
});
|
});
|
||||||
var b = A;
|
var a = A;
|
||||||
console.log(b);
|
console.log(a);
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
@@ -2069,7 +2070,7 @@ issue_4319: {
|
|||||||
|
|
||||||
issue_4321: {
|
issue_4321: {
|
||||||
options = {
|
options = {
|
||||||
inline: true,
|
inline: 3,
|
||||||
keep_fargs: false,
|
keep_fargs: false,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
@@ -3366,3 +3367,62 @@ issue_5189_2: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=6"
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5222: {
|
||||||
|
options = {
|
||||||
|
hoist_props: true,
|
||||||
|
inline: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
side_effects: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f() {
|
||||||
|
do {
|
||||||
|
(function() {
|
||||||
|
var a = {
|
||||||
|
p: [ a ] = [],
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
} while (console.log("PASS"));
|
||||||
|
}
|
||||||
|
f();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
do {
|
||||||
|
a = void 0,
|
||||||
|
a = {
|
||||||
|
p: [ a ] = [],
|
||||||
|
};
|
||||||
|
} while (console.log("PASS"));
|
||||||
|
var a;
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5288: {
|
||||||
|
options = {
|
||||||
|
conditionals: true,
|
||||||
|
inline: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
varify: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
while (function([]) {}([ function f() {
|
||||||
|
if (console)
|
||||||
|
return console.log("PASS");
|
||||||
|
else {
|
||||||
|
let a = 0;
|
||||||
|
}
|
||||||
|
}() ]));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
while ([ [ console ? console.log("PASS") : 0 ] ], void 0);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|||||||
@@ -1233,8 +1233,11 @@ issue_2105_2: {
|
|||||||
issue_2105_3: {
|
issue_2105_3: {
|
||||||
options = {
|
options = {
|
||||||
inline: true,
|
inline: true,
|
||||||
passes: 2,
|
join_vars: true,
|
||||||
|
passes: 3,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
|
side_effects: true,
|
||||||
|
sequences: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
@@ -1258,12 +1261,12 @@ issue_2105_3: {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
!void void {
|
({
|
||||||
prop: function() {
|
prop: function() {
|
||||||
console.log;
|
console.log,
|
||||||
void console.log("PASS");
|
console.log("PASS");
|
||||||
}
|
},
|
||||||
}.prop();
|
}).prop();
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
@@ -1728,7 +1731,8 @@ issue_2768: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
var a = "FAIL";
|
var a = "FAIL";
|
||||||
var c = (d = a, void (d && (a = "PASS")));
|
d = a;
|
||||||
|
var c = void (d && (a = "PASS"));
|
||||||
var d;
|
var d;
|
||||||
console.log(a, typeof c);
|
console.log(a, typeof c);
|
||||||
}
|
}
|
||||||
@@ -1765,7 +1769,7 @@ issue_2846: {
|
|||||||
issue_805_1: {
|
issue_805_1: {
|
||||||
options = {
|
options = {
|
||||||
inline: true,
|
inline: true,
|
||||||
passes: 2,
|
passes: 3,
|
||||||
pure_getters: "strict",
|
pure_getters: "strict",
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
sequences: true,
|
sequences: true,
|
||||||
@@ -1798,7 +1802,7 @@ issue_805_1: {
|
|||||||
issue_805_2: {
|
issue_805_2: {
|
||||||
options = {
|
options = {
|
||||||
inline: true,
|
inline: true,
|
||||||
passes: 2,
|
passes: 3,
|
||||||
pure_getters: "strict",
|
pure_getters: "strict",
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
sequences: true,
|
sequences: true,
|
||||||
@@ -2382,7 +2386,8 @@ issue_3664: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
console.log(function() {
|
console.log(function() {
|
||||||
var a, b = (a = (a = [ b && console.log("FAIL") ]).p = 0, 0);
|
a = (a = [ b && console.log("FAIL") ]).p = 0;
|
||||||
|
var a, b = 0;
|
||||||
return "PASS";
|
return "PASS";
|
||||||
}());
|
}());
|
||||||
}
|
}
|
||||||
@@ -2551,10 +2556,9 @@ issue_3899: {
|
|||||||
console.log(typeof a);
|
console.log(typeof a);
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
function a() {
|
console.log(typeof function() {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
});
|
||||||
console.log(typeof a);
|
|
||||||
}
|
}
|
||||||
expect_stdout: "function"
|
expect_stdout: "function"
|
||||||
}
|
}
|
||||||
@@ -3516,3 +3520,73 @@ issue_5079: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5224: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
keep_fargs: false,
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f() {
|
||||||
|
try {
|
||||||
|
var b = function() {
|
||||||
|
var a = "FAIL 1";
|
||||||
|
null && a;
|
||||||
|
a = console.log(a);
|
||||||
|
}(new function(c, d) {
|
||||||
|
console.log(d);
|
||||||
|
a;
|
||||||
|
}("FAIL 2", Infinity));
|
||||||
|
} finally {
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
f();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(function f() {
|
||||||
|
try {
|
||||||
|
(function() {
|
||||||
|
var a = "FAIL 1";
|
||||||
|
null;
|
||||||
|
a = console.log(a);
|
||||||
|
})(function() {
|
||||||
|
console.log(1 / 0);
|
||||||
|
a;
|
||||||
|
}());
|
||||||
|
} finally {
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect_stdout: "Infinity"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5271: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f() {
|
||||||
|
do {
|
||||||
|
var a = b = 0 ^ f, b = b;
|
||||||
|
} while (console.log(42 - b));
|
||||||
|
}
|
||||||
|
f();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(function f() {
|
||||||
|
do {
|
||||||
|
var b;
|
||||||
|
b = 0 ^ f;
|
||||||
|
} while (console.log(42 - b));
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect_stdout: "42"
|
||||||
|
}
|
||||||
|
|||||||
@@ -2752,8 +2752,7 @@ issue_3944: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
void function f() {
|
void function f() {
|
||||||
while (a = 0 == (a = void 0), console.log(a), void 0);
|
while (0 == void 0, console.log(false), void 0);
|
||||||
var a;
|
|
||||||
f;
|
f;
|
||||||
}();
|
}();
|
||||||
}
|
}
|
||||||
@@ -3203,7 +3202,7 @@ issue_4552: {
|
|||||||
expect_stdout: "NaN"
|
expect_stdout: "NaN"
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_4886: {
|
issue_4886_1: {
|
||||||
options = {
|
options = {
|
||||||
evaluate: true,
|
evaluate: true,
|
||||||
unsafe: true,
|
unsafe: true,
|
||||||
@@ -3222,3 +3221,23 @@ issue_4886: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "true"
|
expect_stdout: "true"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_4886_2: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
unsafe: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log("foo" in {
|
||||||
|
"foo": null,
|
||||||
|
__proto__: 42,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log("foo" in {
|
||||||
|
"foo": null,
|
||||||
|
__proto__: 42,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect_stdout: "true"
|
||||||
|
}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ assignment_2: {
|
|||||||
}
|
}
|
||||||
expect_exact: "var a=8n;a**=a;console.log(a);"
|
expect_exact: "var a=8n;a**=a;console.log(a);"
|
||||||
expect_stdout: "16777216n"
|
expect_stdout: "16777216n"
|
||||||
node_version: ">=10"
|
node_version: ">=10.4.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
evaluate: {
|
evaluate: {
|
||||||
@@ -99,8 +99,8 @@ issue_4664: {
|
|||||||
expect: {
|
expect: {
|
||||||
(function f() {
|
(function f() {
|
||||||
new function(a) {
|
new function(a) {
|
||||||
console.log(typeof f, a, typeof this);
|
console.log(typeof f, 2 ** 30, typeof this);
|
||||||
}((A = 0, 2 ** 30));
|
}(A = 0);
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
expect_stdout: "function 1073741824 object"
|
expect_stdout: "function 1073741824 object"
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1163,13 +1163,13 @@ issue_5182: {
|
|||||||
log(o.p(42));
|
log(o.p(42));
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
var o_p = console;
|
var o = console;
|
||||||
log = o_p.log;
|
log = o.log;
|
||||||
o_p = function(a) {
|
o = function(a) {
|
||||||
console.log(a ? "PASS" : "FAIL");
|
console.log(a ? "PASS" : "FAIL");
|
||||||
return a;
|
return a;
|
||||||
};
|
};
|
||||||
log(o_p(42));
|
log(o(42));
|
||||||
}
|
}
|
||||||
expect_stdout: [
|
expect_stdout: [
|
||||||
"PASS",
|
"PASS",
|
||||||
|
|||||||
@@ -282,7 +282,7 @@ issue_4736: {
|
|||||||
(function() {
|
(function() {
|
||||||
(function() {
|
(function() {
|
||||||
0,
|
0,
|
||||||
console.log(1073741824);
|
console.log(1 << 30);
|
||||||
})();
|
})();
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
@@ -336,7 +336,7 @@ issue_4859: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
(function f(a) {
|
(function f(a) {
|
||||||
console.log(Infinity);
|
console.log(2 + 1 / 0);
|
||||||
return f;
|
return f;
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3109,9 +3109,9 @@ issue_5081_call: {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
function f(b) {
|
function f(a) {
|
||||||
// IE5-10: TypeError: Function expected
|
// IE5-10: TypeError: Function expected
|
||||||
return b(b = "A") + (b += "SS");
|
return a(a = "A") + (a += "SS");
|
||||||
}
|
}
|
||||||
console.log(f(function() {
|
console.log(f(function() {
|
||||||
return "P";
|
return "P";
|
||||||
@@ -3161,8 +3161,8 @@ issue_5081_property_access: {
|
|||||||
console.log(f({ A: "P" }));
|
console.log(f({ A: "P" }));
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
function f(b) {
|
function f(a) {
|
||||||
return b[b = "A"] + (b += "SS");
|
return a[a = "A"] + (a += "SS");
|
||||||
}
|
}
|
||||||
// IE9-11: undefinedASS
|
// IE9-11: undefinedASS
|
||||||
console.log(f({ A: "P" }));
|
console.log(f({ A: "P" }));
|
||||||
@@ -3192,3 +3192,219 @@ issue_5081_property_access_ie: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5269_1: {
|
||||||
|
options = {
|
||||||
|
ie: false,
|
||||||
|
inline: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
do {
|
||||||
|
(function() {
|
||||||
|
try {
|
||||||
|
throw "PASS";
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
} while (!console);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
do {
|
||||||
|
try {
|
||||||
|
throw "PASS";
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
} while (!console);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5269_1_ie: {
|
||||||
|
options = {
|
||||||
|
ie: true,
|
||||||
|
inline: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
do {
|
||||||
|
(function() {
|
||||||
|
try {
|
||||||
|
throw "PASS";
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
} while (!console);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
do {
|
||||||
|
try {
|
||||||
|
throw "PASS";
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
} while (!console);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5269_2: {
|
||||||
|
options = {
|
||||||
|
ie: false,
|
||||||
|
inline: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
for (var i = 0; i < 2; i++)
|
||||||
|
(function() {
|
||||||
|
console.log(e);
|
||||||
|
try {
|
||||||
|
console;
|
||||||
|
} catch (e) {
|
||||||
|
var e = "FAIL 1";
|
||||||
|
}
|
||||||
|
e = "FAIL 2";
|
||||||
|
console;
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
for (var i = 0; i < 2; i++) {
|
||||||
|
e = void 0;
|
||||||
|
console.log(e);
|
||||||
|
try {
|
||||||
|
console;
|
||||||
|
} catch (e) {
|
||||||
|
var e = "FAIL 1";
|
||||||
|
}
|
||||||
|
e = "FAIL 2";
|
||||||
|
console;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"undefined",
|
||||||
|
"undefined",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5269_2_ie: {
|
||||||
|
options = {
|
||||||
|
ie: true,
|
||||||
|
inline: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
for (var i = 0; i < 2; i++)
|
||||||
|
(function() {
|
||||||
|
console.log(e);
|
||||||
|
try {
|
||||||
|
console;
|
||||||
|
} catch (e) {
|
||||||
|
var e = "FAIL 1";
|
||||||
|
}
|
||||||
|
e = "FAIL 2";
|
||||||
|
console;
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
for (var i = 0; i < 2; i++) {
|
||||||
|
e = void 0;
|
||||||
|
console.log(e);
|
||||||
|
try {
|
||||||
|
console;
|
||||||
|
} catch (e) {
|
||||||
|
var e = "FAIL 1";
|
||||||
|
}
|
||||||
|
e = "FAIL 2";
|
||||||
|
console;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"undefined",
|
||||||
|
"undefined",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5269_3: {
|
||||||
|
options = {
|
||||||
|
ie: false,
|
||||||
|
inline: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
e = "foo";
|
||||||
|
for (var i = 0; i < 2; i++)
|
||||||
|
(function() {
|
||||||
|
console.log(e);
|
||||||
|
try {
|
||||||
|
console;
|
||||||
|
} catch (e) {
|
||||||
|
e = "FAIL";
|
||||||
|
}
|
||||||
|
e = "bar";
|
||||||
|
console;
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
e = "foo";
|
||||||
|
for (var i = 0; i < 2; i++) {
|
||||||
|
console.log(e);
|
||||||
|
try {
|
||||||
|
console;
|
||||||
|
} catch (e) {
|
||||||
|
e = "FAIL";
|
||||||
|
}
|
||||||
|
e = "bar";
|
||||||
|
console;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"foo",
|
||||||
|
"bar",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5269_3_ie: {
|
||||||
|
options = {
|
||||||
|
ie: true,
|
||||||
|
inline: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
e = "foo";
|
||||||
|
for (var i = 0; i < 2; i++)
|
||||||
|
(function() {
|
||||||
|
console.log(e);
|
||||||
|
try {
|
||||||
|
console;
|
||||||
|
} catch (e) {
|
||||||
|
e = "FAIL";
|
||||||
|
}
|
||||||
|
e = "bar";
|
||||||
|
console;
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
e = "foo";
|
||||||
|
for (var i = 0; i < 2; i++) {
|
||||||
|
console.log(e);
|
||||||
|
try {
|
||||||
|
console;
|
||||||
|
} catch (e) {
|
||||||
|
e = "FAIL";
|
||||||
|
}
|
||||||
|
e = "bar";
|
||||||
|
console;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"foo",
|
||||||
|
"bar",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|||||||
@@ -545,7 +545,36 @@ if_body_return_3: {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_3600: {
|
issue_3600_1: {
|
||||||
|
options = {
|
||||||
|
if_return: true,
|
||||||
|
inline: 3,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var c = 0;
|
||||||
|
(function() {
|
||||||
|
if ([ ][c++]); else return;
|
||||||
|
return void function() {
|
||||||
|
var b = --b, a = c = 42;
|
||||||
|
return c;
|
||||||
|
}();
|
||||||
|
})();
|
||||||
|
console.log(c);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var c = 0;
|
||||||
|
(function() {
|
||||||
|
if ([][c++]) b = --b, c = 42;
|
||||||
|
var b;
|
||||||
|
})();
|
||||||
|
console.log(c);
|
||||||
|
}
|
||||||
|
expect_stdout: "1"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_3600_2: {
|
||||||
options = {
|
options = {
|
||||||
if_return: true,
|
if_return: true,
|
||||||
inline: true,
|
inline: true,
|
||||||
@@ -566,7 +595,9 @@ issue_3600: {
|
|||||||
expect: {
|
expect: {
|
||||||
var c = 0;
|
var c = 0;
|
||||||
(function() {
|
(function() {
|
||||||
if ([][c++]) b = --b, c = 42;
|
if ([][c++])
|
||||||
|
b = --b,
|
||||||
|
c = 42;
|
||||||
var b;
|
var b;
|
||||||
})();
|
})();
|
||||||
console.log(c);
|
console.log(c);
|
||||||
|
|||||||
@@ -106,6 +106,22 @@ drop_unused: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
drop_side_effect_free: {
|
||||||
|
options = {
|
||||||
|
imports: true,
|
||||||
|
side_effects: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
import foo from "bar";
|
||||||
|
var a = foo;
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
import "bar";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mangle: {
|
mangle: {
|
||||||
rename = false
|
rename = false
|
||||||
mangle = {
|
mangle = {
|
||||||
|
|||||||
@@ -356,6 +356,7 @@ mangle_catch_redef_3: {
|
|||||||
try {
|
try {
|
||||||
throw 0;
|
throw 0;
|
||||||
} catch (o) {
|
} catch (o) {
|
||||||
|
// prints "FAIL" if inlined on Node.js v4-
|
||||||
(function() {
|
(function() {
|
||||||
function f() {
|
function f() {
|
||||||
o = "FAIL";
|
o = "FAIL";
|
||||||
@@ -366,7 +367,8 @@ mangle_catch_redef_3: {
|
|||||||
console.log(o);
|
console.log(o);
|
||||||
}
|
}
|
||||||
expect_exact: 'var o="PASS";try{throw 0}catch(o){(function(){function c(){o="FAIL"}c(),c()})()}console.log(o);'
|
expect_exact: 'var o="PASS";try{throw 0}catch(o){(function(){function c(){o="FAIL"}c(),c()})()}console.log(o);'
|
||||||
expect_stdout: true
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
||||||
mangle_catch_redef_3_toplevel: {
|
mangle_catch_redef_3_toplevel: {
|
||||||
@@ -379,6 +381,7 @@ mangle_catch_redef_3_toplevel: {
|
|||||||
try {
|
try {
|
||||||
throw 0;
|
throw 0;
|
||||||
} catch (o) {
|
} catch (o) {
|
||||||
|
// prints "FAIL" if inlined on Node.js v4-
|
||||||
(function() {
|
(function() {
|
||||||
function f() {
|
function f() {
|
||||||
o = "FAIL";
|
o = "FAIL";
|
||||||
@@ -389,7 +392,8 @@ mangle_catch_redef_3_toplevel: {
|
|||||||
console.log(o);
|
console.log(o);
|
||||||
}
|
}
|
||||||
expect_exact: 'var c="PASS";try{throw 0}catch(c){(function(){function o(){c="FAIL"}o(),o()})()}console.log(c);'
|
expect_exact: 'var c="PASS";try{throw 0}catch(c){(function(){function o(){c="FAIL"}o(),o()})()}console.log(c);'
|
||||||
expect_stdout: true
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
||||||
mangle_catch_redef_3_ie8: {
|
mangle_catch_redef_3_ie8: {
|
||||||
@@ -402,6 +406,7 @@ mangle_catch_redef_3_ie8: {
|
|||||||
try {
|
try {
|
||||||
throw 0;
|
throw 0;
|
||||||
} catch (o) {
|
} catch (o) {
|
||||||
|
// prints "FAIL" if inlined on Node.js v4-
|
||||||
(function() {
|
(function() {
|
||||||
function f() {
|
function f() {
|
||||||
o = "FAIL";
|
o = "FAIL";
|
||||||
@@ -412,7 +417,8 @@ mangle_catch_redef_3_ie8: {
|
|||||||
console.log(o);
|
console.log(o);
|
||||||
}
|
}
|
||||||
expect_exact: 'var o="PASS";try{throw 0}catch(o){(function(){function c(){o="FAIL"}c(),c()})()}console.log(o);'
|
expect_exact: 'var o="PASS";try{throw 0}catch(o){(function(){function c(){o="FAIL"}c(),c()})()}console.log(o);'
|
||||||
expect_stdout: true
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
||||||
mangle_catch_redef_3_ie8_toplevel: {
|
mangle_catch_redef_3_ie8_toplevel: {
|
||||||
@@ -425,6 +431,7 @@ mangle_catch_redef_3_ie8_toplevel: {
|
|||||||
try {
|
try {
|
||||||
throw 0;
|
throw 0;
|
||||||
} catch (o) {
|
} catch (o) {
|
||||||
|
// prints "FAIL" if inlined on Node.js v4-
|
||||||
(function() {
|
(function() {
|
||||||
function f() {
|
function f() {
|
||||||
o = "FAIL";
|
o = "FAIL";
|
||||||
@@ -435,5 +442,6 @@ mangle_catch_redef_3_ie8_toplevel: {
|
|||||||
console.log(o);
|
console.log(o);
|
||||||
}
|
}
|
||||||
expect_exact: 'var c="PASS";try{throw 0}catch(c){(function(){function o(){c="FAIL"}o(),o()})()}console.log(c);'
|
expect_exact: 'var c="PASS";try{throw 0}catch(c){(function(){function o(){c="FAIL"}o(),o()})()}console.log(c);'
|
||||||
expect_stdout: true
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
dont_mangle_arguments: {
|
dont_mangle_arguments: {
|
||||||
mangle = {
|
|
||||||
};
|
|
||||||
options = {
|
options = {
|
||||||
booleans: true,
|
booleans: true,
|
||||||
comparisons: true,
|
comparisons: true,
|
||||||
@@ -21,12 +19,13 @@ dont_mangle_arguments: {
|
|||||||
side_effects: true,
|
side_effects: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
|
mangle = {}
|
||||||
input: {
|
input: {
|
||||||
(function(){
|
(function(){
|
||||||
var arguments = arguments, not_arguments = 9;
|
var arguments = arguments, not_arguments = 9;
|
||||||
console.log(not_arguments, arguments);
|
console.log(not_arguments, arguments);
|
||||||
})(5,6,7);
|
})(5, 6, 7);
|
||||||
}
|
}
|
||||||
expect_exact: "(function(){var arguments=arguments,o=9;console.log(o,arguments)})(5,6,7);"
|
expect_exact: "(function(){var arguments,o=9;console.log(o,arguments)})(5,6,7);"
|
||||||
expect_stdout: true
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -570,6 +570,50 @@ inlined_assignments: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inilne_for: {
|
||||||
|
options = {
|
||||||
|
inline: true,
|
||||||
|
join_vars: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = function() {
|
||||||
|
for (; console.log("PASS"););
|
||||||
|
};
|
||||||
|
a();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
for (; console.log("PASS"););
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
inilne_var: {
|
||||||
|
options = {
|
||||||
|
inline: true,
|
||||||
|
join_vars: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
A = "PASS";
|
||||||
|
var a = function() {
|
||||||
|
var b = A;
|
||||||
|
for (b in console.log(b));
|
||||||
|
};
|
||||||
|
a();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
A = "PASS";
|
||||||
|
var b = A;
|
||||||
|
for (b in console.log(b));
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
typescript_enum: {
|
typescript_enum: {
|
||||||
rename = true
|
rename = true
|
||||||
options = {
|
options = {
|
||||||
@@ -1282,10 +1326,7 @@ assign_sequence_var: {
|
|||||||
console.log(a, b, c);
|
console.log(a, b, c);
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
var a = 0, b = 1;
|
var a = 0, b = 1, c = (console.log(a), a++, b = 2, 3);
|
||||||
console.log(a),
|
|
||||||
a++;
|
|
||||||
var b = 2, c = 3;
|
|
||||||
console.log(a, b, c);
|
console.log(a, b, c);
|
||||||
}
|
}
|
||||||
expect_stdout: [
|
expect_stdout: [
|
||||||
|
|||||||
@@ -181,10 +181,10 @@ issue_2203_2: {
|
|||||||
a: "FAIL",
|
a: "FAIL",
|
||||||
b: function() {
|
b: function() {
|
||||||
return function() {
|
return function() {
|
||||||
return (String, (Object, function() {
|
return (Object, function() {
|
||||||
return this;
|
return this;
|
||||||
}())).a;
|
}()).a;
|
||||||
}();
|
}(String);
|
||||||
}
|
}
|
||||||
}.b());
|
}.b());
|
||||||
}
|
}
|
||||||
@@ -925,6 +925,28 @@ duplicate_lambda_defun_name_2: {
|
|||||||
expect_stdout: "0"
|
expect_stdout: "0"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function_argument_mangle: {
|
||||||
|
mangle = {
|
||||||
|
keep_fargs: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
A = "PASS";
|
||||||
|
var a = A;
|
||||||
|
(function(o) {
|
||||||
|
console.log(a);
|
||||||
|
})("FAIL");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
A = "PASS";
|
||||||
|
var n = A;
|
||||||
|
(function(o) {
|
||||||
|
console.log(n);
|
||||||
|
})("FAIL");
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
function_name_mangle: {
|
function_name_mangle: {
|
||||||
options = {
|
options = {
|
||||||
keep_fargs: false,
|
keep_fargs: false,
|
||||||
@@ -1217,6 +1239,7 @@ issues_3267_1: {
|
|||||||
evaluate: true,
|
evaluate: true,
|
||||||
inline: true,
|
inline: true,
|
||||||
keep_fargs: false,
|
keep_fargs: false,
|
||||||
|
negate_iife: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
sequences: true,
|
sequences: true,
|
||||||
side_effects: true,
|
side_effects: true,
|
||||||
@@ -1235,7 +1258,8 @@ issues_3267_1: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
!function() {
|
!function() {
|
||||||
if (Object())
|
var i = Object();
|
||||||
|
if (i)
|
||||||
return console.log("PASS");
|
return console.log("PASS");
|
||||||
throw "FAIL";
|
throw "FAIL";
|
||||||
}();
|
}();
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
retain_block: {
|
retain_block_1: {
|
||||||
options = {}
|
options = {}
|
||||||
input: {
|
input: {
|
||||||
"use strict";
|
"use strict";
|
||||||
@@ -20,6 +20,94 @@ retain_block: {
|
|||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
retain_block_2: {
|
||||||
|
options = {
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
{
|
||||||
|
var a;
|
||||||
|
let a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
{
|
||||||
|
var a;
|
||||||
|
let a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: true
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|
||||||
|
retain_block_2_mangle: {
|
||||||
|
rename = true
|
||||||
|
mangle = {
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
{
|
||||||
|
var a;
|
||||||
|
let a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
{
|
||||||
|
var t;
|
||||||
|
let t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
retain_block_3: {
|
||||||
|
options = {
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
{
|
||||||
|
let a;
|
||||||
|
var a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
{
|
||||||
|
let a;
|
||||||
|
var a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: true
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|
||||||
|
retain_block_3_mangle: {
|
||||||
|
rename = true
|
||||||
|
mangle = {
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
{
|
||||||
|
let a;
|
||||||
|
var a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
{
|
||||||
|
let t;
|
||||||
|
var t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
retain_assignment: {
|
retain_assignment: {
|
||||||
options = {
|
options = {
|
||||||
dead_code: true,
|
dead_code: true,
|
||||||
@@ -182,8 +270,8 @@ merge_vars_3: {
|
|||||||
var b = console;
|
var b = console;
|
||||||
console.log(typeof b);
|
console.log(typeof b);
|
||||||
}
|
}
|
||||||
var a = 1;
|
var b = 1;
|
||||||
console.log(typeof a);
|
console.log(typeof b);
|
||||||
}
|
}
|
||||||
expect_stdout: [
|
expect_stdout: [
|
||||||
"object",
|
"object",
|
||||||
@@ -192,6 +280,38 @@ merge_vars_3: {
|
|||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
merge_vars_4: {
|
||||||
|
options = {
|
||||||
|
merge_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
var a = 1;
|
||||||
|
console.log(typeof a);
|
||||||
|
{
|
||||||
|
var b = console;
|
||||||
|
console.log(typeof b);
|
||||||
|
let a = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
var a = 1;
|
||||||
|
console.log(typeof a);
|
||||||
|
{
|
||||||
|
var b = console;
|
||||||
|
console.log(typeof b);
|
||||||
|
let a = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"number",
|
||||||
|
"object",
|
||||||
|
]
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|
||||||
use_before_init_1: {
|
use_before_init_1: {
|
||||||
options = {
|
options = {
|
||||||
evaluate: true,
|
evaluate: true,
|
||||||
@@ -966,12 +1086,10 @@ issue_4202: {
|
|||||||
"use strict";
|
"use strict";
|
||||||
{
|
{
|
||||||
let o = {};
|
let o = {};
|
||||||
(function() {
|
|
||||||
function f() {
|
function f() {
|
||||||
o.p = 42;
|
o.p = 42;
|
||||||
}
|
}
|
||||||
f(f);
|
f(f);
|
||||||
})();
|
|
||||||
console.log(o.p++);
|
console.log(o.p++);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1553,7 +1671,7 @@ issue_4438: {
|
|||||||
;
|
;
|
||||||
else {
|
else {
|
||||||
let a = console.log;
|
let a = console.log;
|
||||||
a("PASS");
|
void a("PASS");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
f();
|
f();
|
||||||
@@ -1747,3 +1865,111 @@ issue_4985: {
|
|||||||
expect_stdout: "undefined"
|
expect_stdout: "undefined"
|
||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5240: {
|
||||||
|
options = {
|
||||||
|
inline: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
function f() {
|
||||||
|
if (console) {
|
||||||
|
let g = function() {
|
||||||
|
e;
|
||||||
|
}, e;
|
||||||
|
(function() {
|
||||||
|
if (console) {
|
||||||
|
console.log(e);
|
||||||
|
var e = "FAIL";
|
||||||
|
}
|
||||||
|
})(console.log(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
f();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
function f() {
|
||||||
|
if (console) {
|
||||||
|
let g = function() {
|
||||||
|
e;
|
||||||
|
}, e;
|
||||||
|
(function() {
|
||||||
|
if (console) {
|
||||||
|
console.log(e);
|
||||||
|
var e = "FAIL";
|
||||||
|
}
|
||||||
|
})(console.log(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
f();
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"undefined",
|
||||||
|
"undefined",
|
||||||
|
]
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5254: {
|
||||||
|
options = {
|
||||||
|
inline: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
do {
|
||||||
|
(function() {
|
||||||
|
let a = console.log;
|
||||||
|
a && a("foo");
|
||||||
|
})();
|
||||||
|
} while (console.log("bar"));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
do {
|
||||||
|
let a = console.log;
|
||||||
|
a && a("foo");
|
||||||
|
} while (console.log("bar"));
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"foo",
|
||||||
|
"bar",
|
||||||
|
]
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5260: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
var a = "foo", o;
|
||||||
|
while (console.log("bar"));
|
||||||
|
o = {
|
||||||
|
baz: function(b) {
|
||||||
|
console.log(a, b);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
for (let a in o)
|
||||||
|
o[a](a);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
var a = "foo", o;
|
||||||
|
while (console.log("bar"));
|
||||||
|
o = {
|
||||||
|
baz: function(b) {
|
||||||
|
console.log(a, b);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
for (let a in o)
|
||||||
|
o[a](a);
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"bar",
|
||||||
|
"foo baz",
|
||||||
|
]
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|||||||
@@ -19,11 +19,11 @@ merge: {
|
|||||||
expect: {
|
expect: {
|
||||||
var a = "foo";
|
var a = "foo";
|
||||||
console.log(a);
|
console.log(a);
|
||||||
function f(c) {
|
function f(b) {
|
||||||
var c;
|
var b;
|
||||||
console.log(c);
|
console.log(b);
|
||||||
c = "bar";
|
b = "bar";
|
||||||
console.log(c);
|
console.log(b);
|
||||||
}
|
}
|
||||||
f("baz");
|
f("baz");
|
||||||
var d = "moo";
|
var d = "moo";
|
||||||
@@ -56,17 +56,17 @@ merge_toplevel: {
|
|||||||
console.log(d);
|
console.log(d);
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
var d = "foo";
|
var a = "foo";
|
||||||
console.log(d);
|
console.log(a);
|
||||||
function f(c) {
|
function f(b) {
|
||||||
var c;
|
var b;
|
||||||
console.log(c);
|
console.log(b);
|
||||||
c = "bar";
|
b = "bar";
|
||||||
console.log(c);
|
console.log(b);
|
||||||
}
|
}
|
||||||
f("baz");
|
f("baz");
|
||||||
var d = "moo";
|
var a = "moo";
|
||||||
console.log(d);
|
console.log(a);
|
||||||
}
|
}
|
||||||
expect_stdout: [
|
expect_stdout: [
|
||||||
"foo",
|
"foo",
|
||||||
@@ -94,16 +94,16 @@ segment: {
|
|||||||
console.log(d);
|
console.log(d);
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
var d = "foo";
|
var a = "foo";
|
||||||
console.log(d);
|
console.log(a);
|
||||||
for (var c, i = 0; i < 1; i++) {
|
for (var b, i = 0; i < 1; i++) {
|
||||||
var c = "bar";
|
var b = "bar";
|
||||||
console.log(c);
|
console.log(b);
|
||||||
c = "baz";
|
b = "baz";
|
||||||
console.log(c);
|
console.log(b);
|
||||||
}
|
}
|
||||||
var d = "moo";
|
var a = "moo";
|
||||||
console.log(d);
|
console.log(a);
|
||||||
}
|
}
|
||||||
expect_stdout: [
|
expect_stdout: [
|
||||||
"foo",
|
"foo",
|
||||||
@@ -298,6 +298,89 @@ read_before_assign_2: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
collapse_vars_1: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
merge_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = a && a.p;
|
||||||
|
var b = "PASS";
|
||||||
|
var b = b && console.log(b);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = a && a.p;
|
||||||
|
var a;
|
||||||
|
var a = (a = "PASS") && console.log(a);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
collapse_vars_2: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
merge_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
var log = console.log;
|
||||||
|
(function g(a) {
|
||||||
|
var b = a;
|
||||||
|
var c = Math.random();
|
||||||
|
var c = b;
|
||||||
|
log(c);
|
||||||
|
return c;
|
||||||
|
})("PASS");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
var log = console.log;
|
||||||
|
(function g(a) {
|
||||||
|
var a = a;
|
||||||
|
var c = Math.random();
|
||||||
|
var c;
|
||||||
|
log(c = a);
|
||||||
|
return c;
|
||||||
|
})("PASS");
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
not_redefined: {
|
||||||
|
options = {
|
||||||
|
inline: true,
|
||||||
|
join_vars: true,
|
||||||
|
merge_vars: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
unused: true,
|
||||||
|
varify: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var log = console.log;
|
||||||
|
(function() {
|
||||||
|
return f("PASS");
|
||||||
|
function f(a) {
|
||||||
|
const b = a;
|
||||||
|
const c = log(b);
|
||||||
|
const d = log;
|
||||||
|
c && log(d);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var log = console.log;
|
||||||
|
(function() {
|
||||||
|
return a = "PASS",
|
||||||
|
a = log(a),
|
||||||
|
d = log,
|
||||||
|
void (a && log(d));
|
||||||
|
var a, d;
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
issue_4103: {
|
issue_4103: {
|
||||||
options = {
|
options = {
|
||||||
merge_vars: true,
|
merge_vars: true,
|
||||||
@@ -325,7 +408,7 @@ issue_4103: {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_4107: {
|
issue_4107_1: {
|
||||||
options = {
|
options = {
|
||||||
keep_fargs: false,
|
keep_fargs: false,
|
||||||
merge_vars: true,
|
merge_vars: true,
|
||||||
@@ -342,6 +425,38 @@ issue_4107: {
|
|||||||
})();
|
})();
|
||||||
console.log(typeof a);
|
console.log(typeof a);
|
||||||
}
|
}
|
||||||
|
expect: {
|
||||||
|
(function() {
|
||||||
|
(function(c) {
|
||||||
|
c = console || c;
|
||||||
|
console.log(typeof c);
|
||||||
|
})();
|
||||||
|
})();
|
||||||
|
console.log(typeof a);
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"object",
|
||||||
|
"undefined",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_4107_2: {
|
||||||
|
options = {
|
||||||
|
keep_fargs: false,
|
||||||
|
merge_vars: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(function() {
|
||||||
|
function f(b, b, a) {
|
||||||
|
var d = 1 && c, c = console || a;
|
||||||
|
console.log(typeof c);
|
||||||
|
}
|
||||||
|
f();
|
||||||
|
})();
|
||||||
|
console.log(typeof a);
|
||||||
|
}
|
||||||
expect: {
|
expect: {
|
||||||
(function() {
|
(function() {
|
||||||
(function(a) {
|
(function(a) {
|
||||||
@@ -538,12 +653,12 @@ cross_branch_1_1: {
|
|||||||
expect: {
|
expect: {
|
||||||
var a;
|
var a;
|
||||||
function f() {
|
function f() {
|
||||||
var y, y;
|
var x, x;
|
||||||
if (a)
|
if (a)
|
||||||
y = "foo";
|
x = "foo";
|
||||||
console.log(y);
|
console.log(x);
|
||||||
y = "bar";
|
x = "bar";
|
||||||
console.log(y);
|
console.log(x);
|
||||||
}
|
}
|
||||||
a = 0;
|
a = 0;
|
||||||
f();
|
f();
|
||||||
@@ -581,13 +696,13 @@ cross_branch_1_2: {
|
|||||||
expect: {
|
expect: {
|
||||||
var a;
|
var a;
|
||||||
function f() {
|
function f() {
|
||||||
var y, y;
|
var x, x;
|
||||||
if (a) {
|
if (a) {
|
||||||
y = "foo";
|
x = "foo";
|
||||||
console.log(y);
|
console.log(x);
|
||||||
}
|
}
|
||||||
y = "bar";
|
x = "bar";
|
||||||
console.log(y);
|
console.log(x);
|
||||||
}
|
}
|
||||||
a = 0;
|
a = 0;
|
||||||
f();
|
f();
|
||||||
@@ -624,13 +739,13 @@ cross_branch_1_3: {
|
|||||||
expect: {
|
expect: {
|
||||||
var a;
|
var a;
|
||||||
function f() {
|
function f() {
|
||||||
var y, y;
|
var x, x;
|
||||||
if (a) {
|
if (a) {
|
||||||
y = "foo";
|
x = "foo";
|
||||||
console.log(y);
|
console.log(x);
|
||||||
y = "bar";
|
x = "bar";
|
||||||
}
|
}
|
||||||
console.log(y);
|
console.log(x);
|
||||||
}
|
}
|
||||||
a = 0;
|
a = 0;
|
||||||
f();
|
f();
|
||||||
@@ -666,12 +781,12 @@ cross_branch_1_4: {
|
|||||||
expect: {
|
expect: {
|
||||||
var a;
|
var a;
|
||||||
function f() {
|
function f() {
|
||||||
var y, y;
|
var x, x;
|
||||||
y = "foo";
|
x = "foo";
|
||||||
if (a)
|
if (a)
|
||||||
console.log(y);
|
console.log(x);
|
||||||
y = "bar";
|
x = "bar";
|
||||||
console.log(y);
|
console.log(x);
|
||||||
}
|
}
|
||||||
a = 0;
|
a = 0;
|
||||||
f();
|
f();
|
||||||
@@ -751,12 +866,12 @@ cross_branch_1_6: {
|
|||||||
expect: {
|
expect: {
|
||||||
var a;
|
var a;
|
||||||
function f() {
|
function f() {
|
||||||
var y, y;
|
var x, x;
|
||||||
y = "foo";
|
x = "foo";
|
||||||
if (a) {
|
if (a) {
|
||||||
console.log(y);
|
console.log(x);
|
||||||
y = "bar";
|
x = "bar";
|
||||||
console.log(y);
|
console.log(x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
a = 0;
|
a = 0;
|
||||||
@@ -835,12 +950,12 @@ cross_branch_1_8: {
|
|||||||
expect: {
|
expect: {
|
||||||
var a;
|
var a;
|
||||||
function f() {
|
function f() {
|
||||||
var y, y;
|
var x, x;
|
||||||
y = "foo";
|
x = "foo";
|
||||||
console.log(y);
|
console.log(x);
|
||||||
if (a) {
|
if (a) {
|
||||||
y = "bar";
|
x = "bar";
|
||||||
console.log(y);
|
console.log(x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
a = 0;
|
a = 0;
|
||||||
@@ -877,12 +992,12 @@ cross_branch_1_9: {
|
|||||||
expect: {
|
expect: {
|
||||||
var a;
|
var a;
|
||||||
function f() {
|
function f() {
|
||||||
var y, y;
|
var x, x;
|
||||||
y = "foo";
|
x = "foo";
|
||||||
console.log(y);
|
console.log(x);
|
||||||
y = "bar";
|
x = "bar";
|
||||||
if (a)
|
if (a)
|
||||||
console.log(y);
|
console.log(x);
|
||||||
}
|
}
|
||||||
a = 0;
|
a = 0;
|
||||||
f();
|
f();
|
||||||
@@ -924,14 +1039,14 @@ cross_branch_2a_1: {
|
|||||||
expect: {
|
expect: {
|
||||||
var a, b;
|
var a, b;
|
||||||
function f() {
|
function f() {
|
||||||
var y, y;
|
var x, x;
|
||||||
if (a) {
|
if (a) {
|
||||||
if (b)
|
if (b)
|
||||||
y = "foo";
|
x = "foo";
|
||||||
console.log(y);
|
console.log(x);
|
||||||
}
|
}
|
||||||
y = "bar";
|
x = "bar";
|
||||||
console.log(y);
|
console.log(x);
|
||||||
}
|
}
|
||||||
a = 0, b = 0;
|
a = 0, b = 0;
|
||||||
f();
|
f();
|
||||||
@@ -980,14 +1095,14 @@ cross_branch_2a_2: {
|
|||||||
expect: {
|
expect: {
|
||||||
var a, b;
|
var a, b;
|
||||||
function f() {
|
function f() {
|
||||||
var y, y;
|
var x, x;
|
||||||
if (a) {
|
if (a) {
|
||||||
y = "foo";
|
x = "foo";
|
||||||
if (b)
|
if (b)
|
||||||
console.log(y);
|
console.log(x);
|
||||||
}
|
}
|
||||||
y = "bar";
|
x = "bar";
|
||||||
console.log(y);
|
console.log(x);
|
||||||
}
|
}
|
||||||
a = 0, b = 0;
|
a = 0, b = 0;
|
||||||
f();
|
f();
|
||||||
@@ -1035,14 +1150,14 @@ cross_branch_2a_3: {
|
|||||||
expect: {
|
expect: {
|
||||||
var a, b;
|
var a, b;
|
||||||
function f() {
|
function f() {
|
||||||
var y, y;
|
var x, x;
|
||||||
if (a) {
|
if (a) {
|
||||||
if (b)
|
if (b)
|
||||||
y = "foo";
|
x = "foo";
|
||||||
console.log(y);
|
console.log(x);
|
||||||
y = "bar";
|
x = "bar";
|
||||||
}
|
}
|
||||||
console.log(y);
|
console.log(x);
|
||||||
}
|
}
|
||||||
a = 0, b = 0;
|
a = 0, b = 0;
|
||||||
f();
|
f();
|
||||||
@@ -1092,15 +1207,15 @@ cross_branch_2a_4: {
|
|||||||
expect: {
|
expect: {
|
||||||
var a, b;
|
var a, b;
|
||||||
function f() {
|
function f() {
|
||||||
var y, y;
|
var x, x;
|
||||||
if (a) {
|
if (a) {
|
||||||
if (b) {
|
if (b) {
|
||||||
y = "foo";
|
x = "foo";
|
||||||
console.log(y);
|
console.log(x);
|
||||||
}
|
}
|
||||||
y = "bar";
|
x = "bar";
|
||||||
}
|
}
|
||||||
console.log(y);
|
console.log(x);
|
||||||
}
|
}
|
||||||
a = 0, b = 0;
|
a = 0, b = 0;
|
||||||
f();
|
f();
|
||||||
@@ -1148,14 +1263,14 @@ cross_branch_2a_5: {
|
|||||||
expect: {
|
expect: {
|
||||||
var a, b;
|
var a, b;
|
||||||
function f() {
|
function f() {
|
||||||
var y, y;
|
var x, x;
|
||||||
if (a) {
|
if (a) {
|
||||||
y = "foo";
|
x = "foo";
|
||||||
if (b)
|
if (b)
|
||||||
console.log(y);
|
console.log(x);
|
||||||
y = "bar";
|
x = "bar";
|
||||||
}
|
}
|
||||||
console.log(y);
|
console.log(x);
|
||||||
}
|
}
|
||||||
a = 0, b = 0;
|
a = 0, b = 0;
|
||||||
f();
|
f();
|
||||||
@@ -1427,13 +1542,13 @@ cross_branch_2a_10: {
|
|||||||
expect: {
|
expect: {
|
||||||
var a, b;
|
var a, b;
|
||||||
function f() {
|
function f() {
|
||||||
var y, y;
|
var x, x;
|
||||||
y = "foo";
|
x = "foo";
|
||||||
if (a) {
|
if (a) {
|
||||||
if (b)
|
if (b)
|
||||||
console.log(y);
|
console.log(x);
|
||||||
y = "bar";
|
x = "bar";
|
||||||
console.log(y);
|
console.log(x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
a = 0, b = 0;
|
a = 0, b = 0;
|
||||||
@@ -1590,13 +1705,13 @@ cross_branch_2a_13: {
|
|||||||
expect: {
|
expect: {
|
||||||
var a, b;
|
var a, b;
|
||||||
function f() {
|
function f() {
|
||||||
var y, y;
|
var x, x;
|
||||||
y = "foo";
|
x = "foo";
|
||||||
if (a) {
|
if (a) {
|
||||||
console.log(y);
|
console.log(x);
|
||||||
if (b) {
|
if (b) {
|
||||||
y = "bar";
|
x = "bar";
|
||||||
console.log(y);
|
console.log(x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1644,13 +1759,13 @@ cross_branch_2a_14: {
|
|||||||
expect: {
|
expect: {
|
||||||
var a, b;
|
var a, b;
|
||||||
function f() {
|
function f() {
|
||||||
var y, y;
|
var x, x;
|
||||||
y = "foo";
|
x = "foo";
|
||||||
if (a) {
|
if (a) {
|
||||||
console.log(y);
|
console.log(x);
|
||||||
y = "bar";
|
x = "bar";
|
||||||
if (b)
|
if (b)
|
||||||
console.log(y);
|
console.log(x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
a = 0, b = 0;
|
a = 0, b = 0;
|
||||||
@@ -1753,13 +1868,13 @@ cross_branch_2a_16: {
|
|||||||
expect: {
|
expect: {
|
||||||
var a, b;
|
var a, b;
|
||||||
function f() {
|
function f() {
|
||||||
var y, y;
|
var x, x;
|
||||||
y = "foo";
|
x = "foo";
|
||||||
console.log(y);
|
console.log(x);
|
||||||
if (a) {
|
if (a) {
|
||||||
y = "bar";
|
x = "bar";
|
||||||
if (b)
|
if (b)
|
||||||
console.log(y);
|
console.log(x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
a = 0, b = 0;
|
a = 0, b = 0;
|
||||||
@@ -1807,13 +1922,13 @@ cross_branch_2b_1: {
|
|||||||
expect: {
|
expect: {
|
||||||
var a, b;
|
var a, b;
|
||||||
function f() {
|
function f() {
|
||||||
var y, y;
|
var x, x;
|
||||||
if (a)
|
if (a)
|
||||||
y = "foo";
|
x = "foo";
|
||||||
if (b)
|
if (b)
|
||||||
console.log(y);
|
console.log(x);
|
||||||
y = "bar";
|
x = "bar";
|
||||||
console.log(y);
|
console.log(x);
|
||||||
}
|
}
|
||||||
a = 0, b = 0;
|
a = 0, b = 0;
|
||||||
f();
|
f();
|
||||||
@@ -1918,13 +2033,13 @@ cross_branch_2b_3: {
|
|||||||
expect: {
|
expect: {
|
||||||
var a, b;
|
var a, b;
|
||||||
function f() {
|
function f() {
|
||||||
var y, y;
|
var x, x;
|
||||||
if (a)
|
if (a)
|
||||||
y = "foo";
|
x = "foo";
|
||||||
if (b) {
|
if (b) {
|
||||||
console.log(y);
|
console.log(x);
|
||||||
y = "bar";
|
x = "bar";
|
||||||
console.log(y);
|
console.log(x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
a = 0, b = 0;
|
a = 0, b = 0;
|
||||||
@@ -2028,13 +2143,13 @@ cross_branch_2b_5: {
|
|||||||
expect: {
|
expect: {
|
||||||
var a, b;
|
var a, b;
|
||||||
function f() {
|
function f() {
|
||||||
var y, y;
|
var x, x;
|
||||||
if (a)
|
if (a)
|
||||||
y = "foo";
|
x = "foo";
|
||||||
console.log(y);
|
console.log(x);
|
||||||
if (b) {
|
if (b) {
|
||||||
y = "bar";
|
x = "bar";
|
||||||
console.log(y);
|
console.log(x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
a = 0, b = 0;
|
a = 0, b = 0;
|
||||||
@@ -2141,14 +2256,14 @@ cross_branch_2b_7: {
|
|||||||
expect: {
|
expect: {
|
||||||
var a, b;
|
var a, b;
|
||||||
function f() {
|
function f() {
|
||||||
var y, y;
|
var x, x;
|
||||||
if (a) {
|
if (a) {
|
||||||
y = "foo";
|
x = "foo";
|
||||||
console.log(y);
|
console.log(x);
|
||||||
}
|
}
|
||||||
if (b) {
|
if (b) {
|
||||||
y = "bar";
|
x = "bar";
|
||||||
console.log(y);
|
console.log(x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
a = 0, b = 0;
|
a = 0, b = 0;
|
||||||
@@ -2195,13 +2310,13 @@ cross_branch_2b_8: {
|
|||||||
expect: {
|
expect: {
|
||||||
var a, b;
|
var a, b;
|
||||||
function f() {
|
function f() {
|
||||||
var y, y;
|
var x, x;
|
||||||
if (a)
|
if (a)
|
||||||
y = "foo";
|
x = "foo";
|
||||||
console.log(y);
|
console.log(x);
|
||||||
y = "bar";
|
x = "bar";
|
||||||
if (b)
|
if (b)
|
||||||
console.log(y);
|
console.log(x);
|
||||||
}
|
}
|
||||||
a = 0, b = 0;
|
a = 0, b = 0;
|
||||||
f();
|
f();
|
||||||
@@ -2250,14 +2365,14 @@ cross_branch_2b_9: {
|
|||||||
expect: {
|
expect: {
|
||||||
var a, b;
|
var a, b;
|
||||||
function f() {
|
function f() {
|
||||||
var y, y;
|
var x, x;
|
||||||
if (a) {
|
if (a) {
|
||||||
y = "foo";
|
x = "foo";
|
||||||
console.log(y);
|
console.log(x);
|
||||||
}
|
}
|
||||||
y = "bar";
|
x = "bar";
|
||||||
if (b)
|
if (b)
|
||||||
console.log(y);
|
console.log(x);
|
||||||
}
|
}
|
||||||
a = 0, b = 0;
|
a = 0, b = 0;
|
||||||
f();
|
f();
|
||||||
@@ -2304,14 +2419,14 @@ cross_branch_2b_10: {
|
|||||||
expect: {
|
expect: {
|
||||||
var a, b;
|
var a, b;
|
||||||
function f() {
|
function f() {
|
||||||
var y, y;
|
var x, x;
|
||||||
if (a) {
|
if (a) {
|
||||||
y = "foo";
|
x = "foo";
|
||||||
console.log(y);
|
console.log(x);
|
||||||
y = "bar";
|
x = "bar";
|
||||||
}
|
}
|
||||||
if (b)
|
if (b)
|
||||||
console.log(y);
|
console.log(x);
|
||||||
}
|
}
|
||||||
a = 0, b = 0;
|
a = 0, b = 0;
|
||||||
f();
|
f();
|
||||||
@@ -2412,13 +2527,13 @@ cross_branch_2b_12: {
|
|||||||
expect: {
|
expect: {
|
||||||
var a, b;
|
var a, b;
|
||||||
function f() {
|
function f() {
|
||||||
var y, y;
|
var x, x;
|
||||||
y = "foo";
|
x = "foo";
|
||||||
if (a)
|
if (a)
|
||||||
console.log(y);
|
console.log(x);
|
||||||
if (b) {
|
if (b) {
|
||||||
y = "bar";
|
x = "bar";
|
||||||
console.log(y);
|
console.log(x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
a = 0, b = 0;
|
a = 0, b = 0;
|
||||||
@@ -2465,13 +2580,13 @@ cross_branch_2b_13: {
|
|||||||
expect: {
|
expect: {
|
||||||
var a, b;
|
var a, b;
|
||||||
function f() {
|
function f() {
|
||||||
var y, y;
|
var x, x;
|
||||||
y = "foo";
|
x = "foo";
|
||||||
if (a)
|
if (a)
|
||||||
console.log(y);
|
console.log(x);
|
||||||
y = "bar";
|
x = "bar";
|
||||||
if (b)
|
if (b)
|
||||||
console.log(y);
|
console.log(x);
|
||||||
}
|
}
|
||||||
a = 0, b = 0;
|
a = 0, b = 0;
|
||||||
f();
|
f();
|
||||||
@@ -2620,11 +2735,11 @@ issue_4126_1: {
|
|||||||
try {
|
try {
|
||||||
console.log("PASS");
|
console.log("PASS");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
var c = a;
|
var b = a;
|
||||||
} finally {
|
} finally {
|
||||||
var c = c;
|
var a = b;
|
||||||
}
|
}
|
||||||
console.log(c);
|
console.log(a);
|
||||||
}
|
}
|
||||||
f("FAIL");
|
f("FAIL");
|
||||||
}
|
}
|
||||||
@@ -2816,11 +2931,11 @@ conditional_write: {
|
|||||||
console.log(b);
|
console.log(b);
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
var b = "FAIL", b;
|
var a = "FAIL", a;
|
||||||
if (console)
|
if (console)
|
||||||
b = "PASS";
|
a = "PASS";
|
||||||
b = [b, 42].join();
|
a = [a, 42].join();
|
||||||
console.log(b);
|
console.log(a);
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS,42"
|
expect_stdout: "PASS,42"
|
||||||
}
|
}
|
||||||
@@ -2994,13 +3109,13 @@ issue_4168_use_strict: {
|
|||||||
expect: {
|
expect: {
|
||||||
"use strict";
|
"use strict";
|
||||||
var o = {
|
var o = {
|
||||||
f: function(d, e, f) {
|
f: function(a, b, c) {
|
||||||
var d = d.d;
|
var a = a.d;
|
||||||
var e = e.e;
|
var b = b.e;
|
||||||
var f = f.f;
|
var c = c.f;
|
||||||
this.g(arguments);
|
this.g(arguments);
|
||||||
if (d)
|
if (a)
|
||||||
console.log(e, f);
|
console.log(b, c);
|
||||||
},
|
},
|
||||||
g: function(args) {
|
g: function(args) {
|
||||||
console.log(args[0], args[1], args[2]);
|
console.log(args[0], args[1], args[2]);
|
||||||
@@ -3228,10 +3343,10 @@ issue_4653: {
|
|||||||
f(a++ + (b = b), b |= console.log(a));
|
f(a++ + (b = b), b |= console.log(a));
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
var b = 1;
|
var b, a = 1;
|
||||||
(function(c, d) {
|
(function(c, d) {
|
||||||
c || console.log(d);
|
c || console.log(d);
|
||||||
})(+b + (b = void 0), b |= console.log(2));
|
})(+a + (b = b), b |= console.log(2));
|
||||||
}
|
}
|
||||||
expect_stdout: [
|
expect_stdout: [
|
||||||
"2",
|
"2",
|
||||||
|
|||||||
@@ -389,6 +389,7 @@ issue_1288_side_effects: {
|
|||||||
options = {
|
options = {
|
||||||
conditionals: true,
|
conditionals: true,
|
||||||
negate_iife: true,
|
negate_iife: true,
|
||||||
|
sequences: true,
|
||||||
side_effects: true,
|
side_effects: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
@@ -409,10 +410,10 @@ issue_1288_side_effects: {
|
|||||||
})(0);
|
})(0);
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
w;
|
w,
|
||||||
x || function() {
|
x || function() {
|
||||||
x = {};
|
x = {};
|
||||||
}();
|
}(),
|
||||||
y;
|
y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -262,6 +262,30 @@ de_morgan_2e: {
|
|||||||
node_version: ">=14"
|
node_version: ">=14"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline_binary_nullish: {
|
||||||
|
options = {
|
||||||
|
inline: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(function() {
|
||||||
|
while (console.log("foo"));
|
||||||
|
})() ?? (function() {
|
||||||
|
while (console.log("bar"));
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
if (null == function() {
|
||||||
|
while (console.log("foo"));
|
||||||
|
}())
|
||||||
|
while (console.log("bar"));
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"foo",
|
||||||
|
"bar",
|
||||||
|
]
|
||||||
|
node_version: ">=14"
|
||||||
|
}
|
||||||
|
|
||||||
issue_4679: {
|
issue_4679: {
|
||||||
options = {
|
options = {
|
||||||
comparisons: true,
|
comparisons: true,
|
||||||
@@ -280,3 +304,42 @@ issue_4679: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=14"
|
node_version: ">=14"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5266: {
|
||||||
|
options = {
|
||||||
|
inline: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
[
|
||||||
|
42,
|
||||||
|
null,
|
||||||
|
false,
|
||||||
|
void 0,
|
||||||
|
"FAIL",
|
||||||
|
].forEach(function (a) {
|
||||||
|
a ?? function() {
|
||||||
|
while (console.log(a));
|
||||||
|
}();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
[
|
||||||
|
42,
|
||||||
|
null,
|
||||||
|
false,
|
||||||
|
void 0,
|
||||||
|
"FAIL",
|
||||||
|
].forEach(function (a) {
|
||||||
|
if (null == a) {
|
||||||
|
while (console.log(a));
|
||||||
|
return;
|
||||||
|
} else
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"null",
|
||||||
|
"undefined",
|
||||||
|
]
|
||||||
|
node_version: ">=14"
|
||||||
|
}
|
||||||
|
|||||||
@@ -521,3 +521,25 @@ issue_4415: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5213: {
|
||||||
|
options = {
|
||||||
|
objects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = "FAIL";
|
||||||
|
console.log({
|
||||||
|
p: a = "PASS",
|
||||||
|
0: a,
|
||||||
|
p: null,
|
||||||
|
}[0]);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = "FAIL";
|
||||||
|
console.log({
|
||||||
|
p: (a = "PASS", null),
|
||||||
|
0: a,
|
||||||
|
}[0]);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|||||||
@@ -361,7 +361,9 @@ issue_4906: {
|
|||||||
} while (console.log("PASS"));
|
} while (console.log("PASS"));
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
do {} while (console.log("PASS"));
|
do {
|
||||||
|
var a = a?.[42];
|
||||||
|
} while (console.log("PASS"));
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=14"
|
node_version: ">=14"
|
||||||
@@ -434,7 +436,7 @@ issue_5039: {
|
|||||||
console.log("PASS");
|
console.log("PASS");
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
(function f() {});
|
var a = a?.[function f() {}];
|
||||||
console.log("PASS");
|
console.log("PASS");
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
@@ -455,14 +457,163 @@ issue_5091: {
|
|||||||
console.log(f("FAIL 1") || "PASS");
|
console.log(f("FAIL 1") || "PASS");
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
function f(b) {
|
function f(a) {
|
||||||
var b = b.p;
|
var a = a.p;
|
||||||
var c;
|
var c;
|
||||||
b?.[c = "FAIL 2"];
|
a?.[c = "FAIL 2"];
|
||||||
return b || c;
|
return a || c;
|
||||||
}
|
}
|
||||||
console.log(f("FAIL 1") || "PASS");
|
console.log(f("FAIL 1") || "PASS");
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=14"
|
node_version: ">=14"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5292_dot: {
|
||||||
|
options = {
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var o = {
|
||||||
|
get p() {
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
o?.p;
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var o = {
|
||||||
|
get p() {
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
o?.p;
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=14"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5292_dot_pure_getters: {
|
||||||
|
options = {
|
||||||
|
pure_getters: true,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var o = {
|
||||||
|
get p() {
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
o?.p;
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var o = {
|
||||||
|
get p() {
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5292_dot_pure_getters_strict: {
|
||||||
|
options = {
|
||||||
|
pure_getters: "strict",
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var o = {
|
||||||
|
get p() {
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
o?.p;
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var o = {
|
||||||
|
get p() {
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
o?.p;
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=14"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5292_sub: {
|
||||||
|
options = {
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var o = {
|
||||||
|
get p() {
|
||||||
|
console.log("foo");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
o?.[console.log("bar"), "p"];
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var o = {
|
||||||
|
get p() {
|
||||||
|
console.log("foo");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
o?.[console.log("bar"), "p"];
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"bar",
|
||||||
|
"foo",
|
||||||
|
]
|
||||||
|
node_version: ">=14"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5292_sub_pure_getters: {
|
||||||
|
options = {
|
||||||
|
pure_getters: true,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var o = {
|
||||||
|
get p() {
|
||||||
|
console.log("foo");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
o?.[console.log("bar"), "p"];
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var o = {
|
||||||
|
get p() {
|
||||||
|
console.log("foo");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
console.log("bar");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5292_sub_pure_getters_strict: {
|
||||||
|
options = {
|
||||||
|
pure_getters: "strict",
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var o = {
|
||||||
|
get p() {
|
||||||
|
console.log("foo");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
o?.[console.log("bar"), "p"];
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var o = {
|
||||||
|
get p() {
|
||||||
|
console.log("foo");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
o?.[console.log("bar"), "p"];
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"bar",
|
||||||
|
"foo",
|
||||||
|
]
|
||||||
|
node_version: ">=14"
|
||||||
|
}
|
||||||
|
|||||||
@@ -1363,9 +1363,8 @@ issue_3490_1: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
var b = 42, c = "FAIL";
|
var b = 42, c = "FAIL";
|
||||||
if (function() {
|
|
||||||
var a;
|
var a;
|
||||||
}(), c = "PASS", b) while ("" == typeof d);
|
if (c = "PASS", b) while ("" == typeof d);
|
||||||
console.log(c, b);
|
console.log(c, b);
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS 42"
|
expect_stdout: "PASS 42"
|
||||||
|
|||||||
@@ -41,10 +41,8 @@ reduce_vars: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
var A = 1;
|
var A = 1;
|
||||||
(function() {
|
|
||||||
console.log(-3);
|
console.log(-3);
|
||||||
console.log(A - 5);
|
console.log(A - 5);
|
||||||
})();
|
|
||||||
(function f1() {
|
(function f1() {
|
||||||
var a = 2;
|
var a = 2;
|
||||||
console.log(a - 5);
|
console.log(a - 5);
|
||||||
@@ -905,7 +903,7 @@ use_before_var: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
function f(){
|
function f(){
|
||||||
console.log(void 0);
|
console.log(t);
|
||||||
var t = 1;
|
var t = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -981,7 +979,7 @@ inner_var_for_1: {
|
|||||||
expect: {
|
expect: {
|
||||||
function f() {
|
function f() {
|
||||||
var a = 1;
|
var a = 1;
|
||||||
x(1, void 0, d);
|
x(1, b, d);
|
||||||
for (var b = 2, c = 3; x(1, 2, 3, d); x(1, 2, 3, d)) {
|
for (var b = 2, c = 3; x(1, 2, 3, d); x(1, 2, 3, d)) {
|
||||||
var d = 4, e = 5;
|
var d = 4, e = 5;
|
||||||
x(1, 2, 3, d, e);
|
x(1, 2, 3, d, e);
|
||||||
@@ -6671,6 +6669,7 @@ issues_3267_1: {
|
|||||||
dead_code: true,
|
dead_code: true,
|
||||||
evaluate: true,
|
evaluate: true,
|
||||||
inline: true,
|
inline: true,
|
||||||
|
negate_iife: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
sequences: true,
|
sequences: true,
|
||||||
side_effects: true,
|
side_effects: true,
|
||||||
@@ -6688,8 +6687,9 @@ issues_3267_1: {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
!function(i) {
|
!function(x) {
|
||||||
if (Object())
|
var i = Object();
|
||||||
|
if (i)
|
||||||
return console.log("PASS");
|
return console.log("PASS");
|
||||||
throw "FAIL";
|
throw "FAIL";
|
||||||
}();
|
}();
|
||||||
@@ -6705,6 +6705,7 @@ issues_3267_2: {
|
|||||||
evaluate: true,
|
evaluate: true,
|
||||||
inline: true,
|
inline: true,
|
||||||
keep_fargs: false,
|
keep_fargs: false,
|
||||||
|
negate_iife: true,
|
||||||
passes: 2,
|
passes: 2,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
sequences: true,
|
sequences: true,
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ arrow_destructured_object_1: {
|
|||||||
}
|
}
|
||||||
expect_exact: "var f=({...a})=>a,o=f({PASS:42});for(var k in o)console.log(k,o[k]);"
|
expect_exact: "var f=({...a})=>a,o=f({PASS:42});for(var k in o)console.log(k,o[k]);"
|
||||||
expect_stdout: "PASS 42"
|
expect_stdout: "PASS 42"
|
||||||
node_version: ">=8"
|
node_version: ">=8.3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
arrow_destructured_object_2: {
|
arrow_destructured_object_2: {
|
||||||
@@ -62,7 +62,7 @@ arrow_destructured_object_2: {
|
|||||||
}
|
}
|
||||||
expect_exact: "var f=({FAIL:a,...b})=>b,o=f({PASS:42,FAIL:null});for(var k in o)console.log(k,o[k]);"
|
expect_exact: "var f=({FAIL:a,...b})=>b,o=f({PASS:42,FAIL:null});for(var k in o)console.log(k,o[k]);"
|
||||||
expect_stdout: "PASS 42"
|
expect_stdout: "PASS 42"
|
||||||
node_version: ">=8"
|
node_version: ">=8.3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
arrow_destructured_object_3: {
|
arrow_destructured_object_3: {
|
||||||
@@ -79,7 +79,7 @@ arrow_destructured_object_3: {
|
|||||||
"2 S",
|
"2 S",
|
||||||
"3 S",
|
"3 S",
|
||||||
]
|
]
|
||||||
node_version: ">=8"
|
node_version: ">=8.3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
funarg_1: {
|
funarg_1: {
|
||||||
@@ -131,7 +131,7 @@ destructured_object_1: {
|
|||||||
}
|
}
|
||||||
expect_exact: 'var{...a}=["FAIL","PASS",42];console.log(a[1],a[2]);'
|
expect_exact: 'var{...a}=["FAIL","PASS",42];console.log(a[1],a[2]);'
|
||||||
expect_stdout: "PASS 42"
|
expect_stdout: "PASS 42"
|
||||||
node_version: ">=8"
|
node_version: ">=8.3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
destructured_object_2: {
|
destructured_object_2: {
|
||||||
@@ -141,7 +141,7 @@ destructured_object_2: {
|
|||||||
}
|
}
|
||||||
expect_exact: 'var{0:a,...b}=["FAIL","PASS",42];console.log(b[1],b[2]);'
|
expect_exact: 'var{0:a,...b}=["FAIL","PASS",42];console.log(b[1],b[2]);'
|
||||||
expect_stdout: "PASS 42"
|
expect_stdout: "PASS 42"
|
||||||
node_version: ">=8"
|
node_version: ">=8.3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
drop_fargs: {
|
drop_fargs: {
|
||||||
@@ -231,7 +231,7 @@ reduce_destructured_object: {
|
|||||||
console.log(a[0]);
|
console.log(a[0]);
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=8"
|
node_version: ">=8.3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
retain_destructured_array: {
|
retain_destructured_array: {
|
||||||
@@ -270,7 +270,7 @@ retain_destructured_object_1: {
|
|||||||
"1 PASS",
|
"1 PASS",
|
||||||
"2 42",
|
"2 42",
|
||||||
]
|
]
|
||||||
node_version: ">=8"
|
node_version: ">=8.3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
retain_destructured_object_2: {
|
retain_destructured_object_2: {
|
||||||
@@ -292,7 +292,7 @@ retain_destructured_object_2: {
|
|||||||
"bar PASS",
|
"bar PASS",
|
||||||
"baz 42",
|
"baz 42",
|
||||||
]
|
]
|
||||||
node_version: ">=8"
|
node_version: ">=8.3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
retain_funarg_destructured_array_1: {
|
retain_funarg_destructured_array_1: {
|
||||||
@@ -344,7 +344,7 @@ retain_funarg_destructured_object_1: {
|
|||||||
console.log((({ ...a }) => a)([ "PASS" ])[0]);
|
console.log((({ ...a }) => a)([ "PASS" ])[0]);
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=8"
|
node_version: ">=8.3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
retain_funarg_destructured_object_2: {
|
retain_funarg_destructured_object_2: {
|
||||||
@@ -359,10 +359,10 @@ retain_funarg_destructured_object_2: {
|
|||||||
expect: {
|
expect: {
|
||||||
console.log(function({ p: a, ... b }) {
|
console.log(function({ p: a, ... b }) {
|
||||||
return b;
|
return b;
|
||||||
}({ p: "FAIL" }).p || "PASS");
|
}({}).p || "PASS");
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=8"
|
node_version: ">=8.3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
drop_unused_call_args_1: {
|
drop_unused_call_args_1: {
|
||||||
@@ -436,9 +436,9 @@ merge_funarg: {
|
|||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
(function(...b) {
|
(function(...a) {
|
||||||
var b = b.length;
|
var a = a.length;
|
||||||
console.log(b);
|
console.log(a);
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
expect_stdout: "0"
|
expect_stdout: "0"
|
||||||
@@ -456,9 +456,9 @@ merge_funarg_destructured_array: {
|
|||||||
})([]);
|
})([]);
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
(function([ ...b ]) {
|
(function([ ...a ]) {
|
||||||
var b = b.length;
|
var a = a.length;
|
||||||
console.log(b);
|
console.log(a);
|
||||||
})([]);
|
})([]);
|
||||||
}
|
}
|
||||||
expect_stdout: "0"
|
expect_stdout: "0"
|
||||||
@@ -476,13 +476,13 @@ merge_funarg_destructured_object: {
|
|||||||
})([ "PASS" ]);
|
})([ "PASS" ]);
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
(function({ ...b }) {
|
(function({ ...a }) {
|
||||||
var b = b[0];
|
var a = a[0];
|
||||||
console.log(b);
|
console.log(a);
|
||||||
})([ "PASS" ]);
|
})([ "PASS" ]);
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=8"
|
node_version: ">=8.3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
keep_arguments: {
|
keep_arguments: {
|
||||||
@@ -866,9 +866,9 @@ issue_4575: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
(function(a) {
|
(function(a) {
|
||||||
(function a(...d) {
|
(function(d) {
|
||||||
console.log(d.length);
|
console.log(d.length);
|
||||||
})();
|
})([]);
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
expect_stdout: "0"
|
expect_stdout: "0"
|
||||||
@@ -992,7 +992,7 @@ issue_5089_1: {
|
|||||||
console.log(o.p);
|
console.log(o.p);
|
||||||
}
|
}
|
||||||
expect_stdout: "undefined"
|
expect_stdout: "undefined"
|
||||||
node_version: ">=8"
|
node_version: ">=8.3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_5089_2: {
|
issue_5089_2: {
|
||||||
@@ -1019,7 +1019,7 @@ issue_5089_2: {
|
|||||||
console.log(o.p);
|
console.log(o.p);
|
||||||
}
|
}
|
||||||
expect_stdout: "undefined"
|
expect_stdout: "undefined"
|
||||||
node_version: ">=8"
|
node_version: ">=8.3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_5100_1: {
|
issue_5100_1: {
|
||||||
@@ -1054,7 +1054,7 @@ issue_5100_1: {
|
|||||||
console.log(a.r);
|
console.log(a.r);
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=8"
|
node_version: ">=8.3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_5100_2: {
|
issue_5100_2: {
|
||||||
@@ -1085,7 +1085,7 @@ issue_5100_2: {
|
|||||||
} ][0]);
|
} ][0]);
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=10"
|
node_version: ">=10.22.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_5108: {
|
issue_5108: {
|
||||||
@@ -1104,7 +1104,7 @@ issue_5108: {
|
|||||||
expect: {
|
expect: {
|
||||||
console.log(function([]) {
|
console.log(function([]) {
|
||||||
return "PASS";
|
return "PASS";
|
||||||
}([ "PASS", "FAIL" ]));
|
}([]));
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=6"
|
node_version: ">=6"
|
||||||
@@ -1205,3 +1205,62 @@ issue_5165_2: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=6"
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5246_1: {
|
||||||
|
options = {
|
||||||
|
reduce_vars: true,
|
||||||
|
rests: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(typeof function([ , ...a ]) {
|
||||||
|
return this && a;
|
||||||
|
}([ , function(){} ])[0]);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(typeof function([]) {
|
||||||
|
return this && [ function(){} ];
|
||||||
|
}([])[0]);
|
||||||
|
}
|
||||||
|
expect_stdout: "function"
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5246_2: {
|
||||||
|
options = {
|
||||||
|
reduce_vars: true,
|
||||||
|
rests: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
A = [ , "PASS", "FAIL" ];
|
||||||
|
var [ , ...a ] = [ ... A ];
|
||||||
|
console.log(a[0]);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
A = [ , "PASS", "FAIL" ];
|
||||||
|
var [ , ...a ] = [ ... A ];
|
||||||
|
console.log(a[0]);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5246_3: {
|
||||||
|
options = {
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(function f(...[ [ a ] ]) {
|
||||||
|
console.log(a);
|
||||||
|
})([ "PASS" ]);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(function(...[ a ]) {
|
||||||
|
console.log(a);
|
||||||
|
})([ "PASS" ][0]);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|||||||
@@ -774,7 +774,7 @@ side_effects_cascade_3: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
function f(a, b) {
|
function f(a, b) {
|
||||||
(b += a) || (b = a) || (b -= a, b ^= a),
|
(b += a) || (b = a) || (b = b - a ^ a),
|
||||||
a--;
|
a--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -910,9 +910,7 @@ hoist_decl: {
|
|||||||
var d;
|
var d;
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
var a;
|
var a, b = (w(), x()), c, d;
|
||||||
w();
|
|
||||||
var b = x(), c, d;
|
|
||||||
for (y(); 0;) z();
|
for (y(); 0;) z();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1162,10 +1160,8 @@ issue_3490_1: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
var b = 42, c = "FAIL";
|
var b = 42, c = "FAIL";
|
||||||
if (function() {
|
|
||||||
var a;
|
var a;
|
||||||
a && a.p;
|
if (a && a.p, c = "PASS", b) while ("" == typeof d);
|
||||||
}(), c = "PASS", b) while ("" == typeof d);
|
|
||||||
console.log(c, b);
|
console.log(c, b);
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS 42"
|
expect_stdout: "PASS 42"
|
||||||
@@ -1195,9 +1191,8 @@ issue_3490_2: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
var b = 42, c = "FAIL";
|
var b = 42, c = "FAIL";
|
||||||
for (function() {
|
|
||||||
var a;
|
var a;
|
||||||
}(), c = "PASS", b; "" == typeof d;);
|
for (c = "PASS", b; "" == typeof d;);
|
||||||
console.log(c, b);
|
console.log(c, b);
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS 42"
|
expect_stdout: "PASS 42"
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ dont_inline: {
|
|||||||
node_version: ">=6"
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
||||||
do_inline: {
|
do_inline_1: {
|
||||||
options = {
|
options = {
|
||||||
inline: true,
|
inline: true,
|
||||||
spreads: true,
|
spreads: true,
|
||||||
@@ -164,6 +164,46 @@ do_inline: {
|
|||||||
node_version: ">=6"
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_inline_2: {
|
||||||
|
options = {
|
||||||
|
inline: true,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(function() {
|
||||||
|
(function() {
|
||||||
|
console.log("PASS");
|
||||||
|
})(..."");
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
[] = [ ..."" ],
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|
||||||
|
do_inline_3: {
|
||||||
|
options = {
|
||||||
|
if_return: true,
|
||||||
|
inline: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(function() {
|
||||||
|
(function() {
|
||||||
|
while (console.log("PASS"));
|
||||||
|
})(..."");
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var [] = [ ..."" ];
|
||||||
|
while (console.log("PASS"));
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|
||||||
drop_empty_call_1: {
|
drop_empty_call_1: {
|
||||||
options = {
|
options = {
|
||||||
side_effects: true,
|
side_effects: true,
|
||||||
@@ -201,7 +241,29 @@ drop_empty_call_2: {
|
|||||||
node_version: ">=6"
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
||||||
convert_hole: {
|
convert_hole_array: {
|
||||||
|
options = {
|
||||||
|
spreads: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
[ ...[ "PASS", , 42 ] ].forEach(function(a) {
|
||||||
|
console.log(a);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
[ "PASS", void 0, 42 ].forEach(function(a) {
|
||||||
|
console.log(a);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"PASS",
|
||||||
|
"undefined",
|
||||||
|
"42",
|
||||||
|
]
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|
||||||
|
convert_hole_call: {
|
||||||
options = {
|
options = {
|
||||||
spreads: true,
|
spreads: true,
|
||||||
}
|
}
|
||||||
@@ -341,7 +403,7 @@ convert_setter: {
|
|||||||
console.log(k, o[k]);
|
console.log(k, o[k]);
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS undefined"
|
expect_stdout: "PASS undefined"
|
||||||
node_version: ">=8"
|
node_version: ">=8.3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
keep_getter_1: {
|
keep_getter_1: {
|
||||||
@@ -370,7 +432,7 @@ keep_getter_1: {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=8"
|
node_version: ">=8.3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
keep_getter_2: {
|
keep_getter_2: {
|
||||||
@@ -399,7 +461,7 @@ keep_getter_2: {
|
|||||||
"foo",
|
"foo",
|
||||||
"bar",
|
"bar",
|
||||||
]
|
]
|
||||||
node_version: ">=8"
|
node_version: ">=8.3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
keep_getter_3: {
|
keep_getter_3: {
|
||||||
@@ -429,7 +491,7 @@ keep_getter_3: {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=8"
|
node_version: ">=8.3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
keep_getter_4: {
|
keep_getter_4: {
|
||||||
@@ -460,7 +522,7 @@ keep_getter_4: {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=8"
|
node_version: ">=8.3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
keep_accessor: {
|
keep_accessor: {
|
||||||
@@ -508,7 +570,7 @@ keep_accessor: {
|
|||||||
"q undefined",
|
"q undefined",
|
||||||
"r null",
|
"r null",
|
||||||
]
|
]
|
||||||
node_version: ">=8"
|
node_version: ">=8.3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
object_key_order_1: {
|
object_key_order_1: {
|
||||||
@@ -538,7 +600,7 @@ object_key_order_1: {
|
|||||||
"a 3",
|
"a 3",
|
||||||
"b 2",
|
"b 2",
|
||||||
]
|
]
|
||||||
node_version: ">=8 <=10"
|
node_version: ">=8.3.0 <=10"
|
||||||
}
|
}
|
||||||
|
|
||||||
object_key_order_2: {
|
object_key_order_2: {
|
||||||
@@ -568,7 +630,7 @@ object_key_order_2: {
|
|||||||
"a 3",
|
"a 3",
|
||||||
"b 2",
|
"b 2",
|
||||||
]
|
]
|
||||||
node_version: ">=8"
|
node_version: ">=8.3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
object_key_order_3: {
|
object_key_order_3: {
|
||||||
@@ -598,7 +660,7 @@ object_key_order_3: {
|
|||||||
"a 3",
|
"a 3",
|
||||||
"b 2",
|
"b 2",
|
||||||
]
|
]
|
||||||
node_version: ">=8"
|
node_version: ">=8.3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
object_key_order_4: {
|
object_key_order_4: {
|
||||||
@@ -628,7 +690,7 @@ object_key_order_4: {
|
|||||||
"a 3",
|
"a 3",
|
||||||
"b 2",
|
"b 2",
|
||||||
]
|
]
|
||||||
node_version: ">=8"
|
node_version: ">=8.3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
object_spread_array: {
|
object_spread_array: {
|
||||||
@@ -654,7 +716,7 @@ object_spread_array: {
|
|||||||
"0 foo",
|
"0 foo",
|
||||||
"1 bar",
|
"1 bar",
|
||||||
]
|
]
|
||||||
node_version: ">=8"
|
node_version: ">=8.3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
object_spread_string: {
|
object_spread_string: {
|
||||||
@@ -681,7 +743,7 @@ object_spread_string: {
|
|||||||
"1 o",
|
"1 o",
|
||||||
"2 o",
|
"2 o",
|
||||||
]
|
]
|
||||||
node_version: ">=8"
|
node_version: ">=8.3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
unused_var_side_effects: {
|
unused_var_side_effects: {
|
||||||
@@ -711,7 +773,7 @@ unused_var_side_effects: {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=8"
|
node_version: ">=8.3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe_join_1: {
|
unsafe_join_1: {
|
||||||
@@ -793,7 +855,7 @@ issue_4329: {
|
|||||||
}[0]);
|
}[0]);
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=8"
|
node_version: ">=8.3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_4331: {
|
issue_4331: {
|
||||||
@@ -871,7 +933,7 @@ issue_4345: {
|
|||||||
}[42]);
|
}[42]);
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=8"
|
node_version: ">=8.3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_4361: {
|
issue_4361: {
|
||||||
@@ -901,7 +963,7 @@ issue_4361: {
|
|||||||
"foo",
|
"foo",
|
||||||
"undefined",
|
"undefined",
|
||||||
]
|
]
|
||||||
node_version: ">=8"
|
node_version: ">=8.3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_4363: {
|
issue_4363: {
|
||||||
@@ -922,7 +984,7 @@ issue_4363: {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=8"
|
node_version: ">=8.3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_4556: {
|
issue_4556: {
|
||||||
@@ -994,7 +1056,7 @@ issue_4849: {
|
|||||||
}()));
|
}()));
|
||||||
}
|
}
|
||||||
expect_stdout: "object"
|
expect_stdout: "object"
|
||||||
node_version: ">=8"
|
node_version: ">=8.3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_4882_1: {
|
issue_4882_1: {
|
||||||
@@ -1026,7 +1088,7 @@ issue_4882_1: {
|
|||||||
"PASS",
|
"PASS",
|
||||||
"undefined",
|
"undefined",
|
||||||
]
|
]
|
||||||
node_version: ">=8"
|
node_version: ">=8.3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_4882_2: {
|
issue_4882_2: {
|
||||||
@@ -1052,7 +1114,7 @@ issue_4882_2: {
|
|||||||
"42",
|
"42",
|
||||||
"PASS",
|
"PASS",
|
||||||
]
|
]
|
||||||
node_version: ">=8"
|
node_version: ">=8.3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_4882_3: {
|
issue_4882_3: {
|
||||||
@@ -1082,7 +1144,7 @@ issue_4882_3: {
|
|||||||
"PASS",
|
"PASS",
|
||||||
"42",
|
"42",
|
||||||
]
|
]
|
||||||
node_version: ">=8"
|
node_version: ">=8.3.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_5006: {
|
issue_5006: {
|
||||||
|
|||||||
@@ -337,7 +337,7 @@ malformed_evaluate_4: {
|
|||||||
console.log("\\u00b5");
|
console.log("\\u00b5");
|
||||||
}
|
}
|
||||||
expect_stdout: "\\u00b5"
|
expect_stdout: "\\u00b5"
|
||||||
node_version: ">=8"
|
node_version: ">=8.10.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe_evaluate: {
|
unsafe_evaluate: {
|
||||||
@@ -353,7 +353,7 @@ unsafe_evaluate: {
|
|||||||
console.log("\\uFo");
|
console.log("\\uFo");
|
||||||
}
|
}
|
||||||
expect_stdout: "\\uFo"
|
expect_stdout: "\\uFo"
|
||||||
node_version: ">=8"
|
node_version: ">=8.10.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
side_effects_1: {
|
side_effects_1: {
|
||||||
|
|||||||
@@ -436,6 +436,245 @@ emberjs_global: {
|
|||||||
expect_stdout: Error("PASS")
|
expect_stdout: Error("PASS")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reassign: {
|
||||||
|
options = {
|
||||||
|
comparisons: true,
|
||||||
|
conditionals: true,
|
||||||
|
passes: 2,
|
||||||
|
typeofs: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
A = console;
|
||||||
|
if ("undefined" == typeof A)
|
||||||
|
console.log("FAIL 1");
|
||||||
|
else {
|
||||||
|
A = void 0;
|
||||||
|
while (console.log(void 0 === A ? "PASS" : "FAIL 2"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
A = console;
|
||||||
|
if ("undefined" == typeof A)
|
||||||
|
console.log("FAIL 1");
|
||||||
|
else {
|
||||||
|
A = void 0;
|
||||||
|
while (console.log(void 0 === A ? "PASS" : "FAIL 2"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
reassign_call: {
|
||||||
|
options = {
|
||||||
|
comparisons: true,
|
||||||
|
conditionals: true,
|
||||||
|
passes: 2,
|
||||||
|
typeofs: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
A = console;
|
||||||
|
function f() {
|
||||||
|
A = void 0;
|
||||||
|
}
|
||||||
|
if ("undefined" == typeof A)
|
||||||
|
console.log("FAIL 1");
|
||||||
|
else {
|
||||||
|
f();
|
||||||
|
while (console.log(void 0 === A ? "PASS" : "FAIL 2"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
A = console;
|
||||||
|
function f() {
|
||||||
|
A = void 0;
|
||||||
|
}
|
||||||
|
if ("undefined" == typeof A)
|
||||||
|
console.log("FAIL 1");
|
||||||
|
else {
|
||||||
|
f();
|
||||||
|
while (console.log(void 0 === A ? "PASS" : "FAIL 2"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
reassign_conditional: {
|
||||||
|
options = {
|
||||||
|
comparisons: true,
|
||||||
|
conditionals: true,
|
||||||
|
passes: 2,
|
||||||
|
typeofs: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
A = console;
|
||||||
|
if ("undefined" == typeof A)
|
||||||
|
console.log("FAIL 1");
|
||||||
|
else {
|
||||||
|
A &&= void 0;
|
||||||
|
while (console.log(void 0 === A ? "PASS" : "FAIL 2"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
A = console;
|
||||||
|
if ("undefined" == typeof A)
|
||||||
|
console.log("FAIL 1");
|
||||||
|
else {
|
||||||
|
A &&= void 0;
|
||||||
|
while (console.log(void 0 === A ? "PASS" : "FAIL 2"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=15"
|
||||||
|
}
|
||||||
|
|
||||||
|
reassign_do: {
|
||||||
|
options = {
|
||||||
|
comparisons: true,
|
||||||
|
conditionals: true,
|
||||||
|
if_return: true,
|
||||||
|
passes: 2,
|
||||||
|
reduce_vars: true,
|
||||||
|
typeofs: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
A = console;
|
||||||
|
(function() {
|
||||||
|
if ("undefined" == typeof A)
|
||||||
|
return;
|
||||||
|
var a = A, i = 2;
|
||||||
|
do {
|
||||||
|
console.log(void 0 === A, void 0 === a);
|
||||||
|
A = void 0;
|
||||||
|
} while (--i);
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
A = console;
|
||||||
|
(function() {
|
||||||
|
if ("undefined" != typeof A) {
|
||||||
|
var a = A, i = 2;
|
||||||
|
do {
|
||||||
|
console.log(void 0 === A, (a, false));
|
||||||
|
A = void 0;
|
||||||
|
} while (--i);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"false false",
|
||||||
|
"true false",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
reassign_for: {
|
||||||
|
options = {
|
||||||
|
comparisons: true,
|
||||||
|
conditionals: true,
|
||||||
|
passes: 2,
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
typeofs: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
if (A = console, "undefined" != typeof A)
|
||||||
|
for (var a = A, i = 0; i < 2; i++)
|
||||||
|
console.log(void 0 === A, void 0 === a),
|
||||||
|
A = void 0;
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
if (A = console, "undefined" != typeof A)
|
||||||
|
for (var a = A, i = 0; i < 2; i++)
|
||||||
|
console.log(void 0 === A, (a, false)),
|
||||||
|
A = void 0;
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"false false",
|
||||||
|
"true false",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
reassign_for_in: {
|
||||||
|
options = {
|
||||||
|
comparisons: true,
|
||||||
|
conditionals: true,
|
||||||
|
passes: 2,
|
||||||
|
reduce_vars: true,
|
||||||
|
typeofs: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(A = console) && "undefined" != typeof A && function(a) {
|
||||||
|
for (var k in [ a = A, 42 ]) {
|
||||||
|
console.log(void 0 === A, void 0 === a);
|
||||||
|
A = void 0;
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(A = console) && "undefined" != typeof A && function(a) {
|
||||||
|
for (var k in [ a = A, 42 ]) {
|
||||||
|
console.log(void 0 === A, (a, false));
|
||||||
|
A = void 0;
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"false false",
|
||||||
|
"true false",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
reassign_iife: {
|
||||||
|
options = {
|
||||||
|
comparisons: true,
|
||||||
|
conditionals: true,
|
||||||
|
passes: 2,
|
||||||
|
typeofs: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
A = console;
|
||||||
|
if ("undefined" == typeof A)
|
||||||
|
console.log("FAIL 1");
|
||||||
|
else (function() {
|
||||||
|
A = void 0;
|
||||||
|
})(console.log(void 0 === A ? "FAIL 2" : "PASS"));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
A = console;
|
||||||
|
"undefined" == typeof A ? console.log("FAIL 1") : function() {
|
||||||
|
A = void 0;
|
||||||
|
}(console.log((A, false) ? "FAIL 2" : "PASS"));
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
reassign_property: {
|
||||||
|
options = {
|
||||||
|
comparisons: true,
|
||||||
|
conditionals: true,
|
||||||
|
passes: 2,
|
||||||
|
typeofs: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
A = console;
|
||||||
|
if ("undefined" == typeof A)
|
||||||
|
console.log("FAIL 1");
|
||||||
|
else {
|
||||||
|
A.p = void 0;
|
||||||
|
console.log(void 0 === A ? "FAIL 2" : "PASS");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
A = console;
|
||||||
|
if ("undefined" == typeof A)
|
||||||
|
console.log("FAIL 1");
|
||||||
|
else {
|
||||||
|
A.p = void 0;
|
||||||
|
console.log((A, false) ? "FAIL 2" : "PASS");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
issue_3817: {
|
issue_3817: {
|
||||||
options = {
|
options = {
|
||||||
comparisons: true,
|
comparisons: true,
|
||||||
|
|||||||
@@ -67,7 +67,8 @@ unicode_escaped_identifier_2: {
|
|||||||
}
|
}
|
||||||
expect_exact: 'var a="foo";var \u{10000}="bar";console.log(a,\u{10000});'
|
expect_exact: 'var a="foo";var \u{10000}="bar";console.log(a,\u{10000});'
|
||||||
expect_stdout: "foo bar"
|
expect_stdout: "foo bar"
|
||||||
node_version: ">=4"
|
// non-BMP support is platform-dependent on Node.js v4
|
||||||
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
||||||
unicode_identifier_ascii_only: {
|
unicode_identifier_ascii_only: {
|
||||||
@@ -200,7 +201,8 @@ surrogate_pair: {
|
|||||||
}
|
}
|
||||||
expect_exact: 'var \ud87e\udc00={"\ud87e\udc01":"\udbc0\udc00"};\ud87e\udc00.\ud87e\udc02="\udbc0\udc01";console.log(typeof \ud87e\udc00,\ud87e\udc00.\ud87e\udc01,\ud87e\udc00["\ud87e\udc02"]);'
|
expect_exact: 'var \ud87e\udc00={"\ud87e\udc01":"\udbc0\udc00"};\ud87e\udc00.\ud87e\udc02="\udbc0\udc01";console.log(typeof \ud87e\udc00,\ud87e\udc00.\ud87e\udc01,\ud87e\udc00["\ud87e\udc02"]);'
|
||||||
expect_stdout: "object \udbc0\udc00 \udbc0\udc01"
|
expect_stdout: "object \udbc0\udc00 \udbc0\udc01"
|
||||||
node_version: ">=4"
|
// non-BMP support is platform-dependent on Node.js v4
|
||||||
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
||||||
surrogate_pair_ascii: {
|
surrogate_pair_ascii: {
|
||||||
@@ -216,5 +218,6 @@ surrogate_pair_ascii: {
|
|||||||
}
|
}
|
||||||
expect_exact: 'var \\u{2f800}={"\\ud87e\\udc01":"\\udbc0\\udc00"};\\u{2f800}.\\u{2f802}="\\udbc0\\udc01";console.log(typeof \\u{2f800},\\u{2f800}.\\u{2f801},\\u{2f800}["\\ud87e\\udc02"]);'
|
expect_exact: 'var \\u{2f800}={"\\ud87e\\udc01":"\\udbc0\\udc00"};\\u{2f800}.\\u{2f802}="\\udbc0\\udc01";console.log(typeof \\u{2f800},\\u{2f800}.\\u{2f801},\\u{2f800}["\\ud87e\\udc02"]);'
|
||||||
expect_stdout: "object \udbc0\udc00 \udbc0\udc01"
|
expect_stdout: "object \udbc0\udc00 \udbc0\udc01"
|
||||||
node_version: ">=4"
|
// non-BMP support is platform-dependent on Node.js v4
|
||||||
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,10 +13,10 @@ reduce_merge_const: {
|
|||||||
console.log(b);
|
console.log(b);
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
var b = console;
|
var a = console;
|
||||||
console.log(typeof b);
|
console.log(typeof a);
|
||||||
b = typeof b;
|
a = typeof a;
|
||||||
console.log(b);
|
console.log(a);
|
||||||
}
|
}
|
||||||
expect_stdout: [
|
expect_stdout: [
|
||||||
"object",
|
"object",
|
||||||
@@ -41,10 +41,10 @@ reduce_merge_let: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
"use strict";
|
"use strict";
|
||||||
var b = console;
|
var a = console;
|
||||||
console.log(typeof b);
|
console.log(typeof a);
|
||||||
b = typeof b;
|
a = typeof a;
|
||||||
console.log(b);
|
console.log(a);
|
||||||
}
|
}
|
||||||
expect_stdout: [
|
expect_stdout: [
|
||||||
"object",
|
"object",
|
||||||
|
|||||||
@@ -749,7 +749,7 @@ lift_sequence: {
|
|||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
}
|
}
|
||||||
|
|
||||||
inline_nested_yield: {
|
inline_nested: {
|
||||||
options = {
|
options = {
|
||||||
inline: true,
|
inline: true,
|
||||||
sequences: true,
|
sequences: true,
|
||||||
@@ -784,6 +784,118 @@ inline_nested_yield: {
|
|||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline_nested_async: {
|
||||||
|
options = {
|
||||||
|
awaits: true,
|
||||||
|
inline: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
yields: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log("foo");
|
||||||
|
var a = async function*() {
|
||||||
|
console.log(await(yield* async function*() {
|
||||||
|
yield {
|
||||||
|
then: r => r("bar"),
|
||||||
|
};
|
||||||
|
return "baz";
|
||||||
|
}()));
|
||||||
|
}();
|
||||||
|
console.log("moo");
|
||||||
|
a.next().then(function f(b) {
|
||||||
|
console.log(b.value);
|
||||||
|
b.done || a.next().then(f);
|
||||||
|
});
|
||||||
|
console.log("moz");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log("foo");
|
||||||
|
var a = async function*() {
|
||||||
|
console.log((yield {
|
||||||
|
then: r => r("bar"),
|
||||||
|
}, await "baz"));
|
||||||
|
}();
|
||||||
|
console.log("moo"),
|
||||||
|
a.next().then(function f(b) {
|
||||||
|
console.log(b.value),
|
||||||
|
b.done || a.next().then(f);
|
||||||
|
}),
|
||||||
|
console.log("moz");
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"foo",
|
||||||
|
"moo",
|
||||||
|
"moz",
|
||||||
|
"bar",
|
||||||
|
"baz",
|
||||||
|
"undefined",
|
||||||
|
]
|
||||||
|
node_version: ">=10"
|
||||||
|
}
|
||||||
|
|
||||||
|
inline_nested_block: {
|
||||||
|
options = {
|
||||||
|
if_return: true,
|
||||||
|
inline: true,
|
||||||
|
yields: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = function*() {
|
||||||
|
yield* function*() {
|
||||||
|
for (var a of [ "foo", "bar" ])
|
||||||
|
yield a;
|
||||||
|
return "FAIL";
|
||||||
|
}();
|
||||||
|
}(), b;
|
||||||
|
do {
|
||||||
|
b = a.next();
|
||||||
|
console.log(b.value);
|
||||||
|
} while (!b.done);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = function*() {
|
||||||
|
for (var a of [ "foo", "bar" ])
|
||||||
|
yield a;
|
||||||
|
"FAIL";
|
||||||
|
}(), b;
|
||||||
|
do {
|
||||||
|
b = a.next();
|
||||||
|
console.log(b.value);
|
||||||
|
} while (!b.done);
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"foo",
|
||||||
|
"bar",
|
||||||
|
"undefined",
|
||||||
|
]
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|
||||||
|
dont_inline_nested: {
|
||||||
|
options = {
|
||||||
|
inline: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var yield = "PASS";
|
||||||
|
(function*() {
|
||||||
|
(function() {
|
||||||
|
console.log(yield);
|
||||||
|
})();
|
||||||
|
})().next();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var yield = "PASS";
|
||||||
|
(function*() {
|
||||||
|
(function() {
|
||||||
|
console.log(yield);
|
||||||
|
})();
|
||||||
|
})().next();
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|
||||||
drop_body: {
|
drop_body: {
|
||||||
options = {
|
options = {
|
||||||
side_effects: true,
|
side_effects: true,
|
||||||
@@ -864,10 +976,10 @@ issue_4454_2: {
|
|||||||
f("PASS");
|
f("PASS");
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
function f(b) {
|
function f(a) {
|
||||||
(function*(c = console.log(b)) {})();
|
(function*(c = console.log(a)) {})();
|
||||||
var b = 42..toString();
|
var a = 42..toString();
|
||||||
console.log(b);
|
console.log(a);
|
||||||
}
|
}
|
||||||
f("PASS");
|
f("PASS");
|
||||||
}
|
}
|
||||||
@@ -970,7 +1082,7 @@ issue_4639_1: {
|
|||||||
}().next().value());
|
}().next().value());
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=4"
|
node_version: ">=4 <7 || >=8.7.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_4639_2: {
|
issue_4639_2: {
|
||||||
@@ -1177,9 +1289,9 @@ issue_5032_normal: {
|
|||||||
console.log(value);
|
console.log(value);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
function *f(c) {
|
function *f(a) {
|
||||||
var b = log(c), c = b;
|
var a = log(a), c = a;
|
||||||
log(b);
|
log(a);
|
||||||
log(c);
|
log(c);
|
||||||
}
|
}
|
||||||
f("PASS").next();
|
f("PASS").next();
|
||||||
@@ -1259,12 +1371,12 @@ issue_5034: {
|
|||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_5076: {
|
issue_5076_1: {
|
||||||
options = {
|
options = {
|
||||||
evaluate: true,
|
evaluate: true,
|
||||||
hoist_vars: true,
|
hoist_vars: true,
|
||||||
passes: 2,
|
|
||||||
pure_getters: "strict",
|
pure_getters: "strict",
|
||||||
|
sequences: true,
|
||||||
side_effects: true,
|
side_effects: true,
|
||||||
toplevel: true,
|
toplevel: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
@@ -1281,13 +1393,41 @@ issue_5076: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
var a;
|
var a;
|
||||||
console.log("PASS");
|
console.log("PASS"),
|
||||||
a = 42["a"];
|
a = 42["a"];
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=6"
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5076_2: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
hoist_vars: true,
|
||||||
|
passes: 2,
|
||||||
|
pure_getters: "strict",
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
yields: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a;
|
||||||
|
console.log("PASS");
|
||||||
|
var b = function*({
|
||||||
|
p: {},
|
||||||
|
}) {}({
|
||||||
|
p: { a } = 42,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|
||||||
issue_5177: {
|
issue_5177: {
|
||||||
options = {
|
options = {
|
||||||
properties: true,
|
properties: true,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ var assert = require("assert");
|
|||||||
var exec = require("child_process").exec;
|
var exec = require("child_process").exec;
|
||||||
var fs = require("fs");
|
var fs = require("fs");
|
||||||
var run_code = require("../sandbox").run_code;
|
var run_code = require("../sandbox").run_code;
|
||||||
|
var semver = require("semver");
|
||||||
var to_ascii = require("../node").to_ascii;
|
var to_ascii = require("../node").to_ascii;
|
||||||
|
|
||||||
function read(path) {
|
function read(path) {
|
||||||
@@ -12,10 +13,13 @@ 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 = [
|
||||||
exec(command, {
|
uglifyjscmd,
|
||||||
maxBuffer: 1048576
|
"--self",
|
||||||
}, function(err, stdout) {
|
semver.satisfies(process.version, "<=0.12") ? "-mc hoist_funs" : "-mc",
|
||||||
|
"--wrap WrappedUglifyJS",
|
||||||
|
].join(" ");
|
||||||
|
exec(command, { maxBuffer: 1048576 }, function(err, stdout) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
eval(stdout);
|
eval(stdout);
|
||||||
assert.strictEqual(typeof WrappedUglifyJS, "object");
|
assert.strictEqual(typeof WrappedUglifyJS, "object");
|
||||||
@@ -184,6 +188,30 @@ describe("bin/uglifyjs", function() {
|
|||||||
child.stdin.end(read("test/input/issue-3040/input.js"));
|
child.stdin.end(read("test/input/issue-3040/input.js"));
|
||||||
}, 1000);
|
}, 1000);
|
||||||
});
|
});
|
||||||
|
it("Should work with --keep-fargs (mangle only)", function(done) {
|
||||||
|
var command = uglifyjscmd + ' test/input/issue-1431/sample.js --keep-fargs -m';
|
||||||
|
exec(command, function(err, stdout) {
|
||||||
|
if (err) throw err;
|
||||||
|
assert.strictEqual(stdout, "function f(x){return function(){function n(a){return a*a}return x(n)}}function g(op){return op(1)+op(2)}console.log(f(g)()==5);\n");
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it("Should work with --keep-fargs (mangle & compress)", function(done) {
|
||||||
|
var command = uglifyjscmd + ' test/input/issue-1431/sample.js --keep-fargs -m -c';
|
||||||
|
exec(command, function(err, stdout) {
|
||||||
|
if (err) throw err;
|
||||||
|
assert.strictEqual(stdout, "function f(x){return function(){return x(function(a){return a*a})}}function g(op){return op(1)+op(2)}console.log(5==f(g)());\n");
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it("Should work with keep_fargs under mangler options", function(done) {
|
||||||
|
var command = uglifyjscmd + ' test/input/issue-1431/sample.js -m keep_fargs=true';
|
||||||
|
exec(command, function(err, stdout) {
|
||||||
|
if (err) throw err;
|
||||||
|
assert.strictEqual(stdout, "function f(x){return function(){function n(a){return a*a}return x(n)}}function g(op){return op(1)+op(2)}console.log(f(g)()==5);\n");
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
it("Should work with --keep-fnames (mangle only)", function(done) {
|
it("Should work with --keep-fnames (mangle only)", function(done) {
|
||||||
var command = uglifyjscmd + ' test/input/issue-1431/sample.js --keep-fnames -m';
|
var command = uglifyjscmd + ' test/input/issue-1431/sample.js --keep-fnames -m';
|
||||||
exec(command, function(err, stdout) {
|
exec(command, function(err, stdout) {
|
||||||
@@ -193,10 +221,10 @@ describe("bin/uglifyjs", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
it("Should work with --keep-fnames (mangle & compress)", function(done) {
|
it("Should work with --keep-fnames (mangle & compress)", function(done) {
|
||||||
var command = uglifyjscmd + ' test/input/issue-1431/sample.js --keep-fnames -m -c unused=false';
|
var command = uglifyjscmd + ' test/input/issue-1431/sample.js --keep-fnames -m -c';
|
||||||
exec(command, function(err, stdout) {
|
exec(command, function(err, stdout) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
assert.strictEqual(stdout, "function f(r){return function(){function n(n){return n*n}return r(n)}}function g(n){return n(1)+n(2)}console.log(5==f(g)());\n");
|
assert.strictEqual(stdout, "function f(n){return function(){return n(function n(r){return r*r})}}function g(n){return n(1)+n(2)}console.log(5==f(g)());\n");
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -418,4 +418,20 @@ describe("test/reduce.js", function() {
|
|||||||
if (result.error) throw result.error;
|
if (result.error) throw result.error;
|
||||||
assert.deepEqual(result.warnings, []);
|
assert.deepEqual(result.warnings, []);
|
||||||
});
|
});
|
||||||
|
it("Should handle thrown falsy values gracefully", function() {
|
||||||
|
var code = [
|
||||||
|
"throw 0;",
|
||||||
|
"setTimeout(null, 42);",
|
||||||
|
].join("\n");
|
||||||
|
var result = reduce_test(code, {
|
||||||
|
mangle: false,
|
||||||
|
});
|
||||||
|
if (result.error) throw result.error;
|
||||||
|
assert.strictEqual(result.code, [
|
||||||
|
"// Can't reproduce test failure",
|
||||||
|
"// minify options: {",
|
||||||
|
'// "mangle": false',
|
||||||
|
"// }",
|
||||||
|
].join("\n"));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -205,8 +205,8 @@ describe("sourcemaps", function() {
|
|||||||
});
|
});
|
||||||
if (result.error) throw result.error;
|
if (result.error) throw result.error;
|
||||||
assert.strictEqual(result.code, [
|
assert.strictEqual(result.code, [
|
||||||
"var Foo=function(){console.log(3)};new Foo;var bar=function(o){return o};",
|
"var Foo=function(){console.log(3)},bar=(new Foo,function(o){return o});",
|
||||||
"//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0ZGluIiwiMSJdLCJuYW1lcyI6WyJGb28iLCJjb25zb2xlIiwibG9nIiwiYmFyIl0sIm1hcHBpbmdzIjoiQUFBQSxJQUFNQSxJQUFJLFdBQWdCQyxRQUFRQyxJQUFJLElBQVMsSUFBSUYsSUNBbkQsSUFBSUcsSUFDQSxTQUFjQSxHQUNWLE9BQU9BIn0=",
|
"//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0ZGluIiwiMSJdLCJuYW1lcyI6WyJGb28iLCJjb25zb2xlIiwibG9nIiwiYmFyIl0sIm1hcHBpbmdzIjoiQUFBQSxJQUFNQSxJQUFJLFdBQWdCQyxRQUFRQyxJQUFJLElDQWxDQyxLREEyQyxJQUFJSCxJQ0MvQyxTQUFjRyxHQUNWLE9BQU9BIn0=",
|
||||||
].join("\n"));
|
].join("\n"));
|
||||||
assert.deepEqual(result.warnings, [ "WARN: inline source map not found: 1" ]);
|
assert.deepEqual(result.warnings, [ "WARN: inline source map not found: 1" ]);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,14 +1,26 @@
|
|||||||
var assert = require("assert");
|
var assert = require("assert");
|
||||||
var exec = require("child_process").exec;
|
var exec = require("child_process").exec;
|
||||||
|
var semver = require("semver");
|
||||||
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(120000);
|
this.timeout(120000);
|
||||||
var uglifyjs = '"' + process.argv[0] + '" bin/uglifyjs';
|
var uglifyjs = '"' + process.argv[0] + '" bin/uglifyjs';
|
||||||
|
var options = semver.satisfies(process.version, "<=0.12") ? "-mc hoist_funs" : "-mc";
|
||||||
var command = [
|
var command = [
|
||||||
uglifyjs + " --self -cm --wrap SpiderUglify -o spidermonkey",
|
[
|
||||||
uglifyjs + " -p spidermonkey -cm",
|
uglifyjs,
|
||||||
|
"--self",
|
||||||
|
options,
|
||||||
|
"--wrap SpiderUglify",
|
||||||
|
"-o spidermonkey",
|
||||||
|
].join(" "),
|
||||||
|
[
|
||||||
|
uglifyjs,
|
||||||
|
"-p spidermonkey",
|
||||||
|
options,
|
||||||
|
].join(" "),
|
||||||
].join(" | ");
|
].join(" | ");
|
||||||
exec(command, { maxBuffer: 1048576 }, function(err, stdout) {
|
exec(command, { maxBuffer: 1048576 }, function(err, stdout) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
|
|||||||
@@ -548,7 +548,7 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options)
|
|||||||
}));
|
}));
|
||||||
var before_iterations = testcase;
|
var before_iterations = testcase;
|
||||||
for (var c = 0; c < max_iterations; ++c) {
|
for (var c = 0; c < max_iterations; ++c) {
|
||||||
if (verbose && pass == 1 && c % 25 == 0) {
|
if (verbose && c % (pass == 1 ? 25 : 100) == 0) {
|
||||||
log("// reduce test pass " + pass + ", iteration " + c + ": " + testcase.length + " bytes");
|
log("// reduce test pass " + pass + ", iteration " + c + ": " + testcase.length + " bytes");
|
||||||
}
|
}
|
||||||
var CHANGED = false;
|
var CHANGED = false;
|
||||||
|
|||||||
@@ -26,9 +26,11 @@ exports.run_code = semver.satisfies(process.version, "0.8") ? function(code, top
|
|||||||
return stdout;
|
return stdout;
|
||||||
} : semver.satisfies(process.version, "<0.12") ? run_code_vm : function(code, toplevel, timeout) {
|
} : semver.satisfies(process.version, "<0.12") ? run_code_vm : function(code, toplevel, timeout) {
|
||||||
if ([
|
if ([
|
||||||
/\basync[ \t]*\([\s\S]*?\)[ \t]*=>/,
|
|
||||||
/\b(async[ \t]+function|Promise|setImmediate|setInterval|setTimeout)\b/,
|
/\b(async[ \t]+function|Promise|setImmediate|setInterval|setTimeout)\b/,
|
||||||
/\basync([ \t]+|[ \t]*#|[ \t]*\*[ \t]*)[^\s()[\]{}#:;,.&|!~=*%/+-]+(\s*\(|[ \t]*=>)/,
|
/\basync([ \t]+|[ \t]*#)[^\s()[\]{}#:;,.&|!~=*%/+-]+(\s*\(|[ \t]*=>)/,
|
||||||
|
/\basync[ \t]*\*[ \t]*[^\s()[\]{}#:;,.&|!~=*%/+-]+\s*\(/,
|
||||||
|
/\basync([ \t]*\*)?[ \t]*\[[\s\S]*?\]\s*\(/,
|
||||||
|
/\basync[ \t]*\([\s\S]*?\)[ \t]*=>/,
|
||||||
].some(function(pattern) {
|
].some(function(pattern) {
|
||||||
return pattern.test(code);
|
return pattern.test(code);
|
||||||
})) {
|
})) {
|
||||||
@@ -146,7 +148,8 @@ function setup(global, builtins, setup_log, setup_tty) {
|
|||||||
delete ex[name];
|
delete ex[name];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
process.stderr.write(inspect(value) + "\n\n-----===== UNCAUGHT EXCEPTION =====-----\n\n");
|
var marker = "\n\n-----===== UNCAUGHT EXCEPTION =====-----\n\n";
|
||||||
|
process.stderr.write(marker + inspect(value) + marker);
|
||||||
throw ex;
|
throw ex;
|
||||||
}).on("unhandledRejection", function() {});
|
}).on("unhandledRejection", function() {});
|
||||||
}
|
}
|
||||||
@@ -252,8 +255,11 @@ function run_code_vm(code, toplevel, timeout) {
|
|||||||
var ctx = vm.createContext({ console: console });
|
var ctx = vm.createContext({ console: console });
|
||||||
// for Node.js v6
|
// for Node.js v6
|
||||||
vm.runInContext(setup_code, ctx);
|
vm.runInContext(setup_code, ctx);
|
||||||
vm.runInContext(toplevel ? "(function(){" + code + "})();" : code, ctx, { timeout: timeout });
|
vm.runInContext(toplevel ? "(function(){\n" + code + "\n})();" : code, ctx, { timeout: timeout });
|
||||||
return strip_color_codes(stdout);
|
// for Node.js v4
|
||||||
|
return strip_color_codes(stdout.replace(/\b(Array \[|Object {)/g, function(match) {
|
||||||
|
return match.slice(-1);
|
||||||
|
}));
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
return ex;
|
return ex;
|
||||||
} finally {
|
} finally {
|
||||||
@@ -263,7 +269,7 @@ function run_code_vm(code, toplevel, timeout) {
|
|||||||
|
|
||||||
function run_code_exec(code, toplevel, timeout) {
|
function run_code_exec(code, toplevel, timeout) {
|
||||||
if (toplevel) {
|
if (toplevel) {
|
||||||
code = setup_code + "(function(){" + code + "})();";
|
code = setup_code + "(function(){\n" + code + "\n})();";
|
||||||
} else {
|
} else {
|
||||||
code = code.replace(/^((["'])[^"']*\2(;|$))?/, function(directive) {
|
code = code.replace(/^((["'])[^"']*\2(;|$))?/, function(directive) {
|
||||||
return directive + setup_code;
|
return directive + setup_code;
|
||||||
@@ -281,17 +287,21 @@ function run_code_exec(code, toplevel, timeout) {
|
|||||||
return new Error("Script execution timed out.");
|
return new Error("Script execution timed out.");
|
||||||
}
|
}
|
||||||
if (result.error) return result.error;
|
if (result.error) return result.error;
|
||||||
var end = msg.indexOf("\n\n-----===== UNCAUGHT EXCEPTION =====-----\n\n");
|
var match = /\n([^:\s]*Error)(?:: ([\s\S]+?))?\n( at [\s\S]+)\n$/.exec(msg);
|
||||||
|
var marker = "\n\n-----===== UNCAUGHT EXCEPTION =====-----\n\n";
|
||||||
|
var start = msg.indexOf(marker) + marker.length;
|
||||||
|
var end = msg.indexOf(marker, start);
|
||||||
var details;
|
var details;
|
||||||
if (end >= 0) {
|
if (end >= 0) {
|
||||||
details = msg.slice(0, end).replace(/<([1-9][0-9]*) empty items?>/g, function(match, count) {
|
details = msg.slice(start, end).replace(/<([1-9][0-9]*) empty items?>/g, function(match, count) {
|
||||||
return new Array(+count).join();
|
return new Array(+count).join();
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
details = vm.runInNewContext("(" + details + ")");
|
details = vm.runInNewContext("(" + details + ")");
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
} else if (!match) {
|
||||||
|
return new Error("Script execution aborted.");
|
||||||
}
|
}
|
||||||
var match = /\n([^:\s]*Error)(?:: ([\s\S]+?))?\n( at [\s\S]+)\n$/.exec(msg);
|
|
||||||
if (!match) return details;
|
if (!match) return details;
|
||||||
var ex = new global[match[1]](match[2]);
|
var ex = new global[match[1]](match[2]);
|
||||||
ex.stack = ex.stack.slice(0, ex.stack.indexOf(" at ")) + match[3];
|
ex.stack = ex.stack.slice(0, ex.stack.indexOf(" at ")) + match[3];
|
||||||
|
|||||||
@@ -2290,7 +2290,7 @@ function fuzzy_match(original, uglified) {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
function collect(input, nums) {
|
function collect(input, nums) {
|
||||||
return input.replace(/-?([1-9][0-9]*(\.[0-9]+)?|0\.[0-9]+)(e-?[1-9][0-9]*)?/ig, function(num) {
|
return input.replace(/-?([1-9][0-9]*(\.[0-9]+)?|0\.[0-9]+)(e-?[1-9][0-9]*)?/gi, function(num) {
|
||||||
return "<|" + nums.push(+num) + "|>";
|
return "<|" + nums.push(+num) + "|>";
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -2470,7 +2470,9 @@ for (var round = 1; round <= num_iterations; round++) {
|
|||||||
println(result);
|
println(result);
|
||||||
println();
|
println();
|
||||||
// ignore v8 parser bug
|
// ignore v8 parser bug
|
||||||
return bug_async_arrow_rest(result);
|
return bug_async_arrow_rest(result)
|
||||||
|
// ignore runtime platform bugs
|
||||||
|
|| result.message == "Script execution aborted.";
|
||||||
})) continue;
|
})) continue;
|
||||||
minify_options.forEach(function(options) {
|
minify_options.forEach(function(options) {
|
||||||
var o = JSON.parse(options);
|
var o = JSON.parse(options);
|
||||||
@@ -2485,6 +2487,8 @@ for (var round = 1; round <= num_iterations; round++) {
|
|||||||
ok = sandbox.same_stdout(original_result, uglify_result);
|
ok = sandbox.same_stdout(original_result, uglify_result);
|
||||||
// ignore v8 parser bug
|
// ignore v8 parser bug
|
||||||
if (!ok && bug_async_arrow_rest(uglify_result)) ok = true;
|
if (!ok && bug_async_arrow_rest(uglify_result)) ok = true;
|
||||||
|
// ignore runtime platform bugs
|
||||||
|
if (!ok && uglify_result.message == "Script execution aborted.") ok = true;
|
||||||
// handle difference caused by time-outs
|
// handle difference caused by time-outs
|
||||||
if (!ok && errored && is_error_timeout(original_result)) {
|
if (!ok && errored && is_error_timeout(original_result)) {
|
||||||
if (is_error_timeout(uglify_result)) {
|
if (is_error_timeout(uglify_result)) {
|
||||||
@@ -2497,7 +2501,7 @@ for (var round = 1; round <= num_iterations; round++) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ignore declaration order of global variables
|
// ignore declaration order of global variables
|
||||||
if (!ok && !toplevel) {
|
if (!ok && !toplevel && uglify_result.name != "SyntaxError" && original_result.name != "SyntaxError") {
|
||||||
ok = sandbox.same_stdout(run_code(sort_globals(original_code)), run_code(sort_globals(uglify_code)));
|
ok = sandbox.same_stdout(run_code(sort_globals(original_code)), run_code(sort_globals(uglify_code)));
|
||||||
}
|
}
|
||||||
// ignore numerical imprecision caused by `unsafe_math`
|
// ignore numerical imprecision caused by `unsafe_math`
|
||||||
@@ -2517,11 +2521,10 @@ for (var round = 1; round <= num_iterations; round++) {
|
|||||||
// ignore difference due to implicit strict-mode in `class`
|
// ignore difference due to implicit strict-mode in `class`
|
||||||
if (!ok && /\bclass\b/.test(original_code)) {
|
if (!ok && /\bclass\b/.test(original_code)) {
|
||||||
var original_strict = run_code('"use strict";\n' + original_code, toplevel);
|
var original_strict = run_code('"use strict";\n' + original_code, toplevel);
|
||||||
var uglify_strict = run_code('"use strict";\n' + uglify_code, toplevel);
|
if (/^(Syntax|Type)Error$/.test(uglify_result.name)) {
|
||||||
if (typeof original_strict != "string") {
|
ok = typeof original_strict != "string";
|
||||||
ok = typeof uglify_strict != "string";
|
|
||||||
} else {
|
} else {
|
||||||
ok = sandbox.same_stdout(original_strict, uglify_strict);
|
ok = sandbox.same_stdout(original_strict, uglify_result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ignore difference in error message caused by `import` symbol redeclaration
|
// ignore difference in error message caused by `import` symbol redeclaration
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
"passes": 1e6,
|
"passes": 1e6,
|
||||||
"unsafe": true
|
"unsafe": true
|
||||||
},
|
},
|
||||||
|
"keep_fargs": true,
|
||||||
"keep_fnames": true,
|
"keep_fnames": true,
|
||||||
"toplevel": true
|
"toplevel": true
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user