Compare commits
42 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b23b333d9d | ||
|
|
7621527a5f | ||
|
|
1a064b6e74 | ||
|
|
82772ccb12 | ||
|
|
7cbcd11440 | ||
|
|
980dbde171 | ||
|
|
8b05677c15 | ||
|
|
95090dbf24 | ||
|
|
7c5b6f349e | ||
|
|
e9c902b044 | ||
|
|
111366fca0 | ||
|
|
e368d39715 | ||
|
|
fd8dec61ad | ||
|
|
7880568d15 | ||
|
|
21fc8f4630 | ||
|
|
bf76e35772 | ||
|
|
ac1262dc97 | ||
|
|
498ac83541 | ||
|
|
6fc7a2ab6a | ||
|
|
f8b2215145 | ||
|
|
70ceda5398 | ||
|
|
ce75477670 | ||
|
|
e70b84895c | ||
|
|
8dbf0b042e | ||
|
|
83f7887e5d | ||
|
|
dff7b48921 | ||
|
|
f4f0d2a2dd | ||
|
|
06e3dbc089 | ||
|
|
55a230daa8 | ||
|
|
23b9f36bd8 | ||
|
|
7e88d52fae | ||
|
|
b9d5bba5fb | ||
|
|
8d23496e0f | ||
|
|
260431f4e0 | ||
|
|
7fa1dea9d0 | ||
|
|
d40631fd44 | ||
|
|
d320a6cde2 | ||
|
|
8cd95dd263 | ||
|
|
749a828fc5 | ||
|
|
ab42a90edb | ||
|
|
362abe0ffb | ||
|
|
e3798d9a76 |
13
.github/workflows/ufuzz.yml
vendored
13
.github/workflows/ufuzz.yml
vendored
@@ -3,10 +3,13 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '*/15 * * * *'
|
- cron: '*/15 * * * *'
|
||||||
|
workflow_dispatch:
|
||||||
|
workflow_run:
|
||||||
|
branches: [ master ]
|
||||||
|
types: [ completed ]
|
||||||
|
workflows: [ 'Build testing', CI ]
|
||||||
env:
|
env:
|
||||||
BASE_URL: https://api.github.com/repos/${{ github.repository }}
|
BASE_URL: https://api.github.com/repos/${{ github.repository }}
|
||||||
CAUSE: ${{ github.event_name }}
|
|
||||||
RUN_NUM: ${{ github.run_number }}
|
|
||||||
TOKEN: ${{ github.token }}
|
TOKEN: ${{ github.token }}
|
||||||
jobs:
|
jobs:
|
||||||
ufuzz:
|
ufuzz:
|
||||||
@@ -34,8 +37,8 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
. ./test/release/install.sh
|
. ./test/release/install.sh
|
||||||
if [[ $CAUSE == "schedule" ]]; then
|
if [[ $GITHUB_EVENT_NAME == "pull_request" ]]; then
|
||||||
node test/ufuzz/job $BASE_URL $TOKEN $RUN_NUM
|
|
||||||
else
|
|
||||||
node test/ufuzz/job 5000
|
node test/ufuzz/job 5000
|
||||||
|
else
|
||||||
|
node test/ufuzz/job $BASE_URL $TOKEN $GITHUB_RUN_NUMBER
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -344,9 +344,9 @@ function run() {
|
|||||||
var list = annotations[node.start.file];
|
var list = annotations[node.start.file];
|
||||||
var pure = list[node.start.pos];
|
var pure = list[node.start.pos];
|
||||||
if (!pure) {
|
if (!pure) {
|
||||||
var pos = node.start.parens;
|
var tokens = node.start.parens;
|
||||||
if (pos) for (var i = 0; !pure && i < pos.length; i++) {
|
if (tokens) for (var i = 0; !pure && i < tokens.length; i++) {
|
||||||
pure = list[pos[i]];
|
pure = list[tokens[i].pos];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pure) node.pure = pure;
|
if (pure) node.pure = pure;
|
||||||
|
|||||||
40
lib/ast.js
40
lib/ast.js
@@ -56,35 +56,31 @@ function DEFNODE(type, props, methods, base) {
|
|||||||
code.push("this.", prop, "=props.", prop, ";");
|
code.push("this.", prop, "=props.", prop, ";");
|
||||||
});
|
});
|
||||||
code.push("}");
|
code.push("}");
|
||||||
var proto = base && new base;
|
var proto = Object.create(base && base.prototype);
|
||||||
if (proto && proto.initialize || methods && methods.initialize) code.push("this.initialize();");
|
if (methods.initialize || proto.initialize) code.push("this.initialize();");
|
||||||
code.push("}");
|
code.push("};");
|
||||||
var ctor = new Function(code.join(""))();
|
var ctor = new Function(code.join(""))();
|
||||||
if (proto) {
|
ctor.prototype = proto;
|
||||||
ctor.prototype = proto;
|
|
||||||
ctor.BASE = base;
|
|
||||||
}
|
|
||||||
if (base) base.SUBCLASSES.push(ctor);
|
|
||||||
ctor.prototype.CTOR = ctor;
|
ctor.prototype.CTOR = ctor;
|
||||||
ctor.PROPS = props || null;
|
ctor.prototype.TYPE = ctor.TYPE = type;
|
||||||
ctor.SELF_PROPS = self_props;
|
if (base) {
|
||||||
ctor.SUBCLASSES = [];
|
ctor.BASE = base;
|
||||||
if (type) {
|
base.SUBCLASSES.push(ctor);
|
||||||
ctor.prototype.TYPE = ctor.TYPE = type;
|
|
||||||
}
|
|
||||||
if (methods) for (var name in methods) if (HOP(methods, name)) {
|
|
||||||
if (/^\$/.test(name)) {
|
|
||||||
ctor[name.substr(1)] = methods[name];
|
|
||||||
} else {
|
|
||||||
ctor.prototype[name] = methods[name];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ctor.DEFMETHOD = function(name, method) {
|
ctor.DEFMETHOD = function(name, method) {
|
||||||
this.prototype[name] = method;
|
this.prototype[name] = method;
|
||||||
};
|
};
|
||||||
if (typeof exports !== "undefined") {
|
ctor.PROPS = props;
|
||||||
exports["AST_" + type] = ctor;
|
ctor.SELF_PROPS = self_props;
|
||||||
|
ctor.SUBCLASSES = [];
|
||||||
|
for (var name in methods) if (HOP(methods, name)) {
|
||||||
|
if (/^\$/.test(name)) {
|
||||||
|
ctor[name.substr(1)] = methods[name];
|
||||||
|
} else {
|
||||||
|
ctor.DEFMETHOD(name, methods[name]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (typeof exports !== "undefined") exports["AST_" + type] = ctor;
|
||||||
return ctor;
|
return ctor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
856
lib/compress.js
856
lib/compress.js
File diff suppressed because it is too large
Load Diff
@@ -100,7 +100,7 @@ function minify(files, options) {
|
|||||||
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" ]);
|
||||||
if (options.webkit) set_shorthand("webkit", options, [ "mangle", "output" ]);
|
if (options.webkit) set_shorthand("webkit", options, [ "compress", "mangle", "output" ]);
|
||||||
var quoted_props;
|
var quoted_props;
|
||||||
if (options.mangle) {
|
if (options.mangle) {
|
||||||
options.mangle = defaults(options.mangle, {
|
options.mangle = defaults(options.mangle, {
|
||||||
|
|||||||
@@ -1134,58 +1134,54 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function map(moztype, mytype, propmap) {
|
function map(moztype, mytype, propmap) {
|
||||||
var moz_to_me = "function From_Moz_" + moztype + "(M){\n";
|
var moz_to_me = [
|
||||||
moz_to_me += "return new U2." + mytype.name + "({\n" +
|
"start: my_start_token(M)",
|
||||||
"start: my_start_token(M),\n" +
|
"end: my_end_token(M)",
|
||||||
"end: my_end_token(M)";
|
];
|
||||||
|
var me_to_moz = [
|
||||||
var me_to_moz = "function To_Moz_" + moztype + "(M){\n";
|
"type: " + JSON.stringify(moztype),
|
||||||
me_to_moz += "return {\n" +
|
];
|
||||||
"type: " + JSON.stringify(moztype);
|
|
||||||
|
|
||||||
if (propmap) propmap.split(/\s*,\s*/).forEach(function(prop) {
|
if (propmap) propmap.split(/\s*,\s*/).forEach(function(prop) {
|
||||||
var m = /([a-z0-9$_]+)(=|@|>|%)([a-z0-9$_]+)/i.exec(prop);
|
var m = /([a-z0-9$_]+)(=|@|>|%)([a-z0-9$_]+)/i.exec(prop);
|
||||||
if (!m) throw new Error("Can't understand property map: " + prop);
|
if (!m) throw new Error("Can't understand property map: " + prop);
|
||||||
var moz = m[1], how = m[2], my = m[3];
|
var moz = m[1], how = m[2], my = m[3];
|
||||||
moz_to_me += ",\n" + my + ": ";
|
|
||||||
me_to_moz += ",\n" + moz + ": ";
|
|
||||||
switch (how) {
|
switch (how) {
|
||||||
case "@":
|
case "@":
|
||||||
moz_to_me += "M." + moz + ".map(from_moz)";
|
moz_to_me.push(my + ": M." + moz + ".map(from_moz)");
|
||||||
me_to_moz += "M." + my + ".map(to_moz)";
|
me_to_moz.push(moz + ": M." + my + ".map(to_moz)");
|
||||||
break;
|
break;
|
||||||
case ">":
|
case ">":
|
||||||
moz_to_me += "from_moz(M." + moz + ")";
|
moz_to_me.push(my + ": from_moz(M." + moz + ")");
|
||||||
me_to_moz += "to_moz(M." + my + ")";
|
me_to_moz.push(moz + ": to_moz(M." + my + ")");
|
||||||
break;
|
break;
|
||||||
case "=":
|
case "=":
|
||||||
moz_to_me += "M." + moz;
|
moz_to_me.push(my + ": M." + moz);
|
||||||
me_to_moz += "M." + my;
|
me_to_moz.push(moz + ": M." + my);
|
||||||
break;
|
break;
|
||||||
case "%":
|
case "%":
|
||||||
moz_to_me += "from_moz(M." + moz + ").body";
|
moz_to_me.push(my + ": from_moz(M." + moz + ").body");
|
||||||
me_to_moz += "to_moz_block(M)";
|
me_to_moz.push(moz + ": to_moz_block(M)");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error("Can't understand operator in propmap: " + prop);
|
throw new Error("Can't understand operator in propmap: " + prop);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
moz_to_me += "\n})\n}";
|
MOZ_TO_ME[moztype] = new Function("U2", "my_start_token", "my_end_token", "from_moz", [
|
||||||
me_to_moz += "\n}\n}";
|
"return function From_Moz_" + moztype + "(M) {",
|
||||||
|
" return new U2.AST_" + mytype.TYPE + "({",
|
||||||
//moz_to_me = parse(moz_to_me).print_to_string({ beautify: true });
|
moz_to_me.join(",\n"),
|
||||||
//me_to_moz = parse(me_to_moz).print_to_string({ beautify: true });
|
" });",
|
||||||
//console.log(moz_to_me);
|
"};",
|
||||||
|
].join("\n"))(exports, my_start_token, my_end_token, from_moz);
|
||||||
moz_to_me = new Function("U2", "my_start_token", "my_end_token", "from_moz", "return(" + moz_to_me + ")")(
|
def_to_moz(mytype, new Function("to_moz", "to_moz_block", "to_moz_scope", [
|
||||||
exports, my_start_token, my_end_token, from_moz
|
"return function To_Moz_" + moztype + "(M) {",
|
||||||
);
|
" return {",
|
||||||
me_to_moz = new Function("to_moz", "to_moz_block", "to_moz_scope", "return(" + me_to_moz + ")")(
|
me_to_moz.join(",\n"),
|
||||||
to_moz, to_moz_block, to_moz_scope
|
" };",
|
||||||
);
|
"};",
|
||||||
MOZ_TO_ME[moztype] = moz_to_me;
|
].join("\n"))(to_moz, to_moz_block, to_moz_scope));
|
||||||
def_to_moz(mytype, me_to_moz);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var FROM_MOZ_STACK = null;
|
var FROM_MOZ_STACK = null;
|
||||||
|
|||||||
21
lib/parse.js
21
lib/parse.js
@@ -1334,21 +1334,19 @@ function parse($TEXT, options) {
|
|||||||
if (is("punc", "{")) {
|
if (is("punc", "{")) {
|
||||||
body = block_();
|
body = block_();
|
||||||
value = null;
|
value = null;
|
||||||
if (S.input.has_directive("use strict")) {
|
|
||||||
argnames.forEach(strict_verify_symbol);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
body = [];
|
body = [];
|
||||||
handle_regexp();
|
handle_regexp();
|
||||||
value = maybe_assign();
|
value = maybe_assign();
|
||||||
}
|
}
|
||||||
|
var is_strict = S.input.has_directive("use strict");
|
||||||
S.input.pop_directives_stack();
|
S.input.pop_directives_stack();
|
||||||
--S.in_function;
|
--S.in_function;
|
||||||
S.in_loop = loop;
|
S.in_loop = loop;
|
||||||
S.labels = labels;
|
S.labels = labels;
|
||||||
S.in_generator = was_gen;
|
S.in_generator = was_gen;
|
||||||
S.in_async = was_async;
|
S.in_async = was_async;
|
||||||
return new (async ? AST_AsyncArrow : AST_Arrow)({
|
var node = new (async ? AST_AsyncArrow : AST_Arrow)({
|
||||||
start: start,
|
start: start,
|
||||||
argnames: argnames,
|
argnames: argnames,
|
||||||
rest: rest,
|
rest: rest,
|
||||||
@@ -1356,6 +1354,8 @@ function parse($TEXT, options) {
|
|||||||
value: value,
|
value: value,
|
||||||
end: prev(),
|
end: prev(),
|
||||||
});
|
});
|
||||||
|
if (is_strict) node.each_argname(strict_verify_symbol);
|
||||||
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
var function_ = function(ctor) {
|
var function_ = function(ctor) {
|
||||||
@@ -1388,23 +1388,24 @@ function parse($TEXT, options) {
|
|||||||
S.in_loop = 0;
|
S.in_loop = 0;
|
||||||
S.labels = [];
|
S.labels = [];
|
||||||
var body = block_();
|
var body = block_();
|
||||||
if (S.input.has_directive("use strict")) {
|
var is_strict = S.input.has_directive("use strict");
|
||||||
if (name) strict_verify_symbol(name);
|
|
||||||
argnames.forEach(strict_verify_symbol);
|
|
||||||
if (argnames.rest) strict_verify_symbol(argnames.rest);
|
|
||||||
}
|
|
||||||
S.input.pop_directives_stack();
|
S.input.pop_directives_stack();
|
||||||
--S.in_function;
|
--S.in_function;
|
||||||
S.in_loop = loop;
|
S.in_loop = loop;
|
||||||
S.labels = labels;
|
S.labels = labels;
|
||||||
S.in_generator = was_gen;
|
S.in_generator = was_gen;
|
||||||
S.in_async = was_async;
|
S.in_async = was_async;
|
||||||
return new ctor({
|
var node = new ctor({
|
||||||
name: name,
|
name: name,
|
||||||
argnames: argnames,
|
argnames: argnames,
|
||||||
rest: argnames.rest || null,
|
rest: argnames.rest || null,
|
||||||
body: body
|
body: body
|
||||||
});
|
});
|
||||||
|
if (is_strict) {
|
||||||
|
if (name) strict_verify_symbol(name);
|
||||||
|
node.each_argname(strict_verify_symbol);
|
||||||
|
}
|
||||||
|
return node;
|
||||||
};
|
};
|
||||||
|
|
||||||
function if_() {
|
function if_() {
|
||||||
|
|||||||
@@ -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.13.8",
|
"version": "3.13.10",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.8.0"
|
"node": ">=0.8.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ var urls = [
|
|||||||
"https://code.angularjs.org/1.7.8/angular.js",
|
"https://code.angularjs.org/1.7.8/angular.js",
|
||||||
"https://unpkg.com/mathjs@6.2.3/dist/math.js",
|
"https://unpkg.com/mathjs@6.2.3/dist/math.js",
|
||||||
"https://unpkg.com/react@15.3.2/dist/react.js",
|
"https://unpkg.com/react@15.3.2/dist/react.js",
|
||||||
"https://cdnjs.cloudflare.com/ajax/libs/d3/5.12.0/d3.js",
|
"https://cdnjs.cloudflare.com/ajax/libs/d3/6.7.0/d3.js",
|
||||||
"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.js",
|
"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.js",
|
||||||
"https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.15/lodash.js",
|
"https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.15/lodash.js",
|
||||||
"https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.12.2/ember.prod.js",
|
"https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.12.2/ember.prod.js",
|
||||||
|
|||||||
@@ -256,6 +256,7 @@ issue_3858: {
|
|||||||
collapse_vars: true,
|
collapse_vars: true,
|
||||||
inline: true,
|
inline: true,
|
||||||
keep_fargs: false,
|
keep_fargs: false,
|
||||||
|
unsafe: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
|
|||||||
@@ -254,6 +254,25 @@ duplicate_argname: {
|
|||||||
expect_stdout: "bar 42 foo 42 bar"
|
expect_stdout: "bar 42 foo 42 bar"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fraction: {
|
||||||
|
options = {
|
||||||
|
arguments: true,
|
||||||
|
keep_fargs: false,
|
||||||
|
reduce_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(function() {
|
||||||
|
return arguments[0.3];
|
||||||
|
}("FAIL") || "PASS");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(function() {
|
||||||
|
return arguments[0.3];
|
||||||
|
}("FAIL") || "PASS");
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
issue_3273: {
|
issue_3273: {
|
||||||
options = {
|
options = {
|
||||||
arguments: true,
|
arguments: true,
|
||||||
|
|||||||
@@ -421,6 +421,7 @@ collapse_value: {
|
|||||||
arrows: true,
|
arrows: true,
|
||||||
collapse_vars: true,
|
collapse_vars: true,
|
||||||
keep_fargs: false,
|
keep_fargs: false,
|
||||||
|
unsafe: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
|
|||||||
@@ -227,9 +227,7 @@ inline_await_1_trim: {
|
|||||||
console.log("PASS");
|
console.log("PASS");
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
(async function() {
|
void 0;
|
||||||
await 0;
|
|
||||||
})();
|
|
||||||
console.log("PASS");
|
console.log("PASS");
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
@@ -334,7 +332,7 @@ inline_await_3_trim: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
(async function() {
|
(async function() {
|
||||||
return a = "PASS", b = console.log, await b(a);
|
return a = "PASS", b = console.log, b(a);
|
||||||
var a, b;
|
var a, b;
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
@@ -557,6 +555,51 @@ collapse_property_lambda: {
|
|||||||
node_version: ">=8"
|
node_version: ">=8"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
drop_async_1: {
|
||||||
|
options = {
|
||||||
|
awaits: true,
|
||||||
|
inline: true,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(function(a) {
|
||||||
|
(async function() {
|
||||||
|
a *= 7;
|
||||||
|
})();
|
||||||
|
return a;
|
||||||
|
}(6));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(function(a) {
|
||||||
|
void (a *= 7);
|
||||||
|
return a;
|
||||||
|
}(6));
|
||||||
|
}
|
||||||
|
expect_stdout: "42"
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
|
drop_async_2: {
|
||||||
|
options = {
|
||||||
|
awaits: true,
|
||||||
|
collapse_vars: true,
|
||||||
|
evaluate: true,
|
||||||
|
inline: true,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(function(a) {
|
||||||
|
(async b => await (a *= b))(7);
|
||||||
|
return a;
|
||||||
|
}(6));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(42);
|
||||||
|
}
|
||||||
|
expect_stdout: "42"
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
drop_return: {
|
drop_return: {
|
||||||
options = {
|
options = {
|
||||||
side_effects: true,
|
side_effects: true,
|
||||||
@@ -1531,3 +1574,452 @@ issue_4764_3: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=8"
|
node_version: ">=8"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_4972_1: {
|
||||||
|
options = {
|
||||||
|
awaits: true,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log("foo");
|
||||||
|
(async function() {
|
||||||
|
try {
|
||||||
|
return await "bar";
|
||||||
|
} finally {
|
||||||
|
console.log("baz");
|
||||||
|
}
|
||||||
|
})().then(console.log);
|
||||||
|
console.log("moo");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log("foo");
|
||||||
|
(async function() {
|
||||||
|
try {
|
||||||
|
return await "bar";
|
||||||
|
} finally {
|
||||||
|
console.log("baz");
|
||||||
|
}
|
||||||
|
})().then(console.log);
|
||||||
|
console.log("moo");
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"foo",
|
||||||
|
"moo",
|
||||||
|
"baz",
|
||||||
|
"bar",
|
||||||
|
]
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_4972_2: {
|
||||||
|
options = {
|
||||||
|
awaits: true,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log("foo");
|
||||||
|
(async function() {
|
||||||
|
try {
|
||||||
|
console.log("bar");
|
||||||
|
} finally {
|
||||||
|
return await "baz";
|
||||||
|
}
|
||||||
|
})().then(console.log);
|
||||||
|
console.log("moo");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log("foo");
|
||||||
|
(async function() {
|
||||||
|
try {
|
||||||
|
console.log("bar");
|
||||||
|
} finally {
|
||||||
|
return "baz";
|
||||||
|
}
|
||||||
|
})().then(console.log);
|
||||||
|
console.log("moo");
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"foo",
|
||||||
|
"bar",
|
||||||
|
"moo",
|
||||||
|
"baz",
|
||||||
|
]
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_4972_3: {
|
||||||
|
options = {
|
||||||
|
awaits: true,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log("foo");
|
||||||
|
try {
|
||||||
|
(async function() {
|
||||||
|
return await "bar";
|
||||||
|
})().then(console.log);
|
||||||
|
} finally {
|
||||||
|
console.log("baz");
|
||||||
|
}
|
||||||
|
console.log("moo");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log("foo");
|
||||||
|
try {
|
||||||
|
(async function() {
|
||||||
|
return "bar";
|
||||||
|
})().then(console.log);
|
||||||
|
} finally {
|
||||||
|
console.log("baz");
|
||||||
|
}
|
||||||
|
console.log("moo");
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"foo",
|
||||||
|
"baz",
|
||||||
|
"moo",
|
||||||
|
"bar",
|
||||||
|
]
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_4974: {
|
||||||
|
options = {
|
||||||
|
awaits: true,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(async function f() {
|
||||||
|
return 42 in f();
|
||||||
|
})();
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(async function f() {
|
||||||
|
return 42 in f();
|
||||||
|
})();
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
expect_stdout: true
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_4975: {
|
||||||
|
options = {
|
||||||
|
awaits: true,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(async function f(a) {
|
||||||
|
try {
|
||||||
|
if (a) console.log(typeof f());
|
||||||
|
} catch (e) {}
|
||||||
|
})(42);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(async function f(a) {
|
||||||
|
try {
|
||||||
|
if (a) console.log(typeof f());
|
||||||
|
} catch (e) {}
|
||||||
|
})(42);
|
||||||
|
}
|
||||||
|
expect_stdout: "object"
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_4987: {
|
||||||
|
options = {
|
||||||
|
awaits: true,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(async function() {
|
||||||
|
try {
|
||||||
|
await 42;
|
||||||
|
} finally {
|
||||||
|
console.log("foo");
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
console.log("bar");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(async function() {
|
||||||
|
try {
|
||||||
|
await 0;
|
||||||
|
} finally {
|
||||||
|
console.log("foo");
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
console.log("bar");
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"bar",
|
||||||
|
"foo",
|
||||||
|
]
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5001: {
|
||||||
|
options = {
|
||||||
|
awaits: true,
|
||||||
|
inline: true,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = 0;
|
||||||
|
(async function() {
|
||||||
|
a++ | await 42;
|
||||||
|
})();
|
||||||
|
console.log(a ? "PASS" : "FAIL");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = 0;
|
||||||
|
void a++;
|
||||||
|
console.log(a ? "PASS" : "FAIL");
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5019_1: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(function(a) {
|
||||||
|
(async function() {
|
||||||
|
await 42;
|
||||||
|
console.log(a);
|
||||||
|
})();
|
||||||
|
a = "PASS";
|
||||||
|
})("FAIL");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(function(a) {
|
||||||
|
(async function() {
|
||||||
|
await 42;
|
||||||
|
console.log(a);
|
||||||
|
})();
|
||||||
|
a = "PASS";
|
||||||
|
})("FAIL");
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5019_2: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log("sync", function(a) {
|
||||||
|
(async function() {
|
||||||
|
console.log(await "async", a);
|
||||||
|
})();
|
||||||
|
return a = "PASS";
|
||||||
|
}("FAIL"));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log("sync", function(a) {
|
||||||
|
(async function() {
|
||||||
|
console.log(await "async", a);
|
||||||
|
})();
|
||||||
|
return a = "PASS";
|
||||||
|
}("FAIL"));
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"sync PASS",
|
||||||
|
"async PASS",
|
||||||
|
]
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5019_3: {
|
||||||
|
options = {
|
||||||
|
inline: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
for (var i in "foo") {
|
||||||
|
(function(a) {
|
||||||
|
(async function() {
|
||||||
|
console.log(await "async", a);
|
||||||
|
})();
|
||||||
|
})(i);
|
||||||
|
console.log("sync", i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
for (var i in "foo") {
|
||||||
|
(function(a) {
|
||||||
|
(async function() {
|
||||||
|
console.log(await "async", a);
|
||||||
|
})();
|
||||||
|
})(i);
|
||||||
|
console.log("sync", i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"sync 0",
|
||||||
|
"sync 1",
|
||||||
|
"sync 2",
|
||||||
|
"async 0",
|
||||||
|
"async 1",
|
||||||
|
"async 2",
|
||||||
|
]
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5023_1: {
|
||||||
|
options = {
|
||||||
|
awaits: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(async function() {
|
||||||
|
let a = a;
|
||||||
|
})();
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(async function() {
|
||||||
|
let a = a;
|
||||||
|
})();
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5023_2: {
|
||||||
|
options = {
|
||||||
|
awaits: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(async function() {
|
||||||
|
let a;
|
||||||
|
a = a;
|
||||||
|
})();
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(function() {
|
||||||
|
let a;
|
||||||
|
a = a;
|
||||||
|
})();
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5032_normal: {
|
||||||
|
options = {
|
||||||
|
merge_vars: true,
|
||||||
|
webkit: false,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function log(value) {
|
||||||
|
console.log(value);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
async function f(a) {
|
||||||
|
var b = log(a), c = b;
|
||||||
|
log(b);
|
||||||
|
log(c);
|
||||||
|
}
|
||||||
|
f("PASS");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function log(value) {
|
||||||
|
console.log(value);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
async function f(c) {
|
||||||
|
var b = log(c), c = b;
|
||||||
|
log(b);
|
||||||
|
log(c);
|
||||||
|
}
|
||||||
|
f("PASS");
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"PASS",
|
||||||
|
"PASS",
|
||||||
|
"PASS",
|
||||||
|
]
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5032_webkit: {
|
||||||
|
options = {
|
||||||
|
merge_vars: true,
|
||||||
|
webkit: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function log(value) {
|
||||||
|
console.log(value);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
async function f(a) {
|
||||||
|
var b = log(a), c = b;
|
||||||
|
log(b);
|
||||||
|
log(c);
|
||||||
|
}
|
||||||
|
f("PASS");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function log(value) {
|
||||||
|
console.log(value);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
async function f(a) {
|
||||||
|
var b = log(a), c = b;
|
||||||
|
log(b);
|
||||||
|
log(c);
|
||||||
|
}
|
||||||
|
f("PASS");
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"PASS",
|
||||||
|
"PASS",
|
||||||
|
"PASS",
|
||||||
|
]
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5034: {
|
||||||
|
options = {
|
||||||
|
functions: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(function() {
|
||||||
|
var await = function f() {
|
||||||
|
return async function() {
|
||||||
|
return f;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
await()().then(function(value) {
|
||||||
|
console.log(value === await ? "PASS" : "FAIL");
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(function() {
|
||||||
|
var await = function f() {
|
||||||
|
return async function() {
|
||||||
|
return f;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
await()().then(function(value) {
|
||||||
|
console.log(value === await ? "PASS" : "FAIL");
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|||||||
@@ -29,6 +29,383 @@ iife_boolean_context: {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
de_morgan_1a: {
|
||||||
|
options = {
|
||||||
|
booleans: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f(a) {
|
||||||
|
return a || a;
|
||||||
|
}
|
||||||
|
console.log(f(null), f(42));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f(a) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
console.log(f(null), f(42));
|
||||||
|
}
|
||||||
|
expect_stdout: "null 42"
|
||||||
|
}
|
||||||
|
|
||||||
|
de_morgan_1b: {
|
||||||
|
options = {
|
||||||
|
booleans: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f(a) {
|
||||||
|
return a && a;
|
||||||
|
}
|
||||||
|
console.log(f(null), f(42));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f(a) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
console.log(f(null), f(42));
|
||||||
|
}
|
||||||
|
expect_stdout: "null 42"
|
||||||
|
}
|
||||||
|
|
||||||
|
de_morgan_1c: {
|
||||||
|
options = {
|
||||||
|
booleans: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(delete (NaN && NaN));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(delete (0, NaN));
|
||||||
|
}
|
||||||
|
expect_stdout: "true"
|
||||||
|
}
|
||||||
|
|
||||||
|
de_morgan_2a: {
|
||||||
|
options = {
|
||||||
|
booleans: true,
|
||||||
|
conditionals: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f(a, b) {
|
||||||
|
return a || (a || b);
|
||||||
|
}
|
||||||
|
console.log(f(null), f(null, {}));
|
||||||
|
console.log(f(42), f(42, {}));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f(a, b) {
|
||||||
|
return a || b;
|
||||||
|
}
|
||||||
|
console.log(f(null), f(null, {}));
|
||||||
|
console.log(f(42), f(42, {}));
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"undefined {}",
|
||||||
|
"42 42",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
de_morgan_2b: {
|
||||||
|
options = {
|
||||||
|
booleans: true,
|
||||||
|
evaluate: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f(a, b) {
|
||||||
|
return a || (a && b);
|
||||||
|
}
|
||||||
|
console.log(f(null), f(null, {}));
|
||||||
|
console.log(f(42), f(42, {}));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f(a, b) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
console.log(f(null), f(null, {}));
|
||||||
|
console.log(f(42), f(42, {}));
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"null null",
|
||||||
|
"42 42",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
de_morgan_2c: {
|
||||||
|
options = {
|
||||||
|
booleans: true,
|
||||||
|
evaluate: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f(a, b) {
|
||||||
|
return a && (a || b);
|
||||||
|
}
|
||||||
|
console.log(f(null), f(null, {}));
|
||||||
|
console.log(f(42), f(42, {}));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f(a, b) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
console.log(f(null), f(null, {}));
|
||||||
|
console.log(f(42), f(42, {}));
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"null null",
|
||||||
|
"42 42",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
de_morgan_2d: {
|
||||||
|
options = {
|
||||||
|
booleans: true,
|
||||||
|
evaluate: true,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f(a, b) {
|
||||||
|
return a && (a && b);
|
||||||
|
}
|
||||||
|
console.log(f(null), f(null, {}));
|
||||||
|
console.log(f(42), f(42, {}));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f(a, b) {
|
||||||
|
return a && b;
|
||||||
|
}
|
||||||
|
console.log(f(null), f(null, {}));
|
||||||
|
console.log(f(42), f(42, {}));
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"null null",
|
||||||
|
"undefined {}",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
de_morgan_3a: {
|
||||||
|
options = {
|
||||||
|
booleans: true,
|
||||||
|
conditionals: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f(a, b, c) {
|
||||||
|
return a || ((a || b) || c);
|
||||||
|
}
|
||||||
|
console.log(f(null, false), f(null, false, {}), f(null, true), f(null, true, {}));
|
||||||
|
console.log(f(42, false), f(42, false, {}), f(42, true), f(42, true, {}));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f(a, b, c) {
|
||||||
|
return a || b || c;
|
||||||
|
}
|
||||||
|
console.log(f(null, !1), f(null, !1, {}), f(null, !0), f(null, !0, {}));
|
||||||
|
console.log(f(42, !1), f(42, !1, {}), f(42, !0), f(42, !0, {}));
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"undefined {} true true",
|
||||||
|
"42 42 42 42",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
de_morgan_3b: {
|
||||||
|
options = {
|
||||||
|
booleans: true,
|
||||||
|
evaluate: true,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f(a, b, c) {
|
||||||
|
return a || ((a || b) && c);
|
||||||
|
}
|
||||||
|
console.log(f(null, false), f(null, false, {}), f(null, true), f(null, true, {}));
|
||||||
|
console.log(f(42, false), f(42, false, {}), f(42, true), f(42, true, {}));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f(a, b, c) {
|
||||||
|
return a || b && c;
|
||||||
|
}
|
||||||
|
console.log(f(null, !1), f(null, !1, {}), f(null, !0), f(null, !0, {}));
|
||||||
|
console.log(f(42, !1), f(42, !1, {}), f(42, !0), f(42, !0, {}));
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"false false undefined {}",
|
||||||
|
"42 42 42 42",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
de_morgan_3c: {
|
||||||
|
options = {
|
||||||
|
booleans: true,
|
||||||
|
evaluate: true,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f(a, b, c) {
|
||||||
|
return a || ((a && b) || c);
|
||||||
|
}
|
||||||
|
console.log(f(null, false), f(null, false, {}), f(null, true), f(null, true, {}));
|
||||||
|
console.log(f(42, false), f(42, false, {}), f(42, true), f(42, true, {}));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f(a, b, c) {
|
||||||
|
return a || c;
|
||||||
|
}
|
||||||
|
console.log(f(null, !1), f(null, !1, {}), f(null, !0), f(null, !0, {}));
|
||||||
|
console.log(f(42, !1), f(42, !1, {}), f(42, !0), f(42, !0, {}));
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"undefined {} undefined {}",
|
||||||
|
"42 42 42 42",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
de_morgan_3d: {
|
||||||
|
options = {
|
||||||
|
booleans: true,
|
||||||
|
evaluate: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f(a, b, c) {
|
||||||
|
return a || ((a && b) && c);
|
||||||
|
}
|
||||||
|
console.log(f(null, false), f(null, false, {}), f(null, true), f(null, true, {}));
|
||||||
|
console.log(f(42, false), f(42, false, {}), f(42, true), f(42, true, {}));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f(a, b, c) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
console.log(f(null, !1), f(null, !1, {}), f(null, !0), f(null, !0, {}));
|
||||||
|
console.log(f(42, !1), f(42, !1, {}), f(42, !0), f(42, !0, {}));
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"null null null null",
|
||||||
|
"42 42 42 42",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
de_morgan_3e: {
|
||||||
|
options = {
|
||||||
|
booleans: true,
|
||||||
|
evaluate: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f(a, b, c) {
|
||||||
|
return a && ((a || b) || c);
|
||||||
|
}
|
||||||
|
console.log(f(null, false), f(null, false, {}), f(null, true), f(null, true, {}));
|
||||||
|
console.log(f(42, false), f(42, false, {}), f(42, true), f(42, true, {}));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f(a, b, c) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
console.log(f(null, !1), f(null, !1, {}), f(null, !0), f(null, !0, {}));
|
||||||
|
console.log(f(42, !1), f(42, !1, {}), f(42, !0), f(42, !0, {}));
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"null null null null",
|
||||||
|
"42 42 42 42",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
de_morgan_3f: {
|
||||||
|
options = {
|
||||||
|
booleans: true,
|
||||||
|
evaluate: true,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f(a, b, c) {
|
||||||
|
return a && ((a || b) && c);
|
||||||
|
}
|
||||||
|
console.log(f(null, false), f(null, false, {}), f(null, true), f(null, true, {}));
|
||||||
|
console.log(f(42, false), f(42, false, {}), f(42, true), f(42, true, {}));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f(a, b, c) {
|
||||||
|
return a && c;
|
||||||
|
}
|
||||||
|
console.log(f(null, !1), f(null, !1, {}), f(null, !0), f(null, !0, {}));
|
||||||
|
console.log(f(42, !1), f(42, !1, {}), f(42, !0), f(42, !0, {}));
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"null null null null",
|
||||||
|
"undefined {} undefined {}",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
de_morgan_3g: {
|
||||||
|
options = {
|
||||||
|
booleans: true,
|
||||||
|
evaluate: true,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f(a, b, c) {
|
||||||
|
return a && ((a && b) || c);
|
||||||
|
}
|
||||||
|
console.log(f(null, false), f(null, false, {}), f(null, true), f(null, true, {}));
|
||||||
|
console.log(f(42, false), f(42, false, {}), f(42, true), f(42, true, {}));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f(a, b, c) {
|
||||||
|
return a && (b || c);
|
||||||
|
}
|
||||||
|
console.log(f(null, !1), f(null, !1, {}), f(null, !0), f(null, !0, {}));
|
||||||
|
console.log(f(42, !1), f(42, !1, {}), f(42, !0), f(42, !0, {}));
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"null null null null",
|
||||||
|
"undefined {} true true",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
de_morgan_3h: {
|
||||||
|
options = {
|
||||||
|
booleans: true,
|
||||||
|
conditionals: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f(a, b, c) {
|
||||||
|
return a && ((a && b) && c);
|
||||||
|
}
|
||||||
|
console.log(f(null, false), f(null, false, {}), f(null, true), f(null, true, {}));
|
||||||
|
console.log(f(42, false), f(42, false, {}), f(42, true), f(42, true, {}));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f(a, b, c) {
|
||||||
|
return a && b && c;
|
||||||
|
}
|
||||||
|
console.log(f(null, !1), f(null, !1, {}), f(null, !0), f(null, !0, {}));
|
||||||
|
console.log(f(42, !1), f(42, !1, {}), f(42, !0), f(42, !0, {}));
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"null null null null",
|
||||||
|
"false false undefined {}",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
conditional_chain: {
|
||||||
|
options = {
|
||||||
|
booleans: true,
|
||||||
|
conditionals: true,
|
||||||
|
evaluate: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f(a, b) {
|
||||||
|
return a ? a : b ? b : 42;
|
||||||
|
}
|
||||||
|
console.log(f("PASS", "FAIL"));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f(a, b) {
|
||||||
|
return a || b || 42;
|
||||||
|
}
|
||||||
|
console.log(f("PASS", "FAIL"));
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
issue_3465_1: {
|
issue_3465_1: {
|
||||||
options = {
|
options = {
|
||||||
booleans: true,
|
booleans: true,
|
||||||
@@ -181,3 +558,79 @@ issue_4374: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "0"
|
expect_stdout: "0"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5028_1: {
|
||||||
|
options = {
|
||||||
|
booleans: true,
|
||||||
|
conditionals: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = 1;
|
||||||
|
console.log(function() {
|
||||||
|
return a-- ? a-- ? "FAIL 1" : "PASS" : "FAIL 2";
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = 1;
|
||||||
|
console.log(function() {
|
||||||
|
return a-- ? a-- ? "FAIL 1" : "PASS" : "FAIL 2";
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5028_2: {
|
||||||
|
options = {
|
||||||
|
booleans: true,
|
||||||
|
conditionals: true,
|
||||||
|
dead_code: true,
|
||||||
|
if_return: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = 1;
|
||||||
|
(function() {
|
||||||
|
if (a--)
|
||||||
|
if (a--)
|
||||||
|
a = "FAIL";
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
})();
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = 1;
|
||||||
|
(function() {
|
||||||
|
a-- && a-- && (a = "FAIL");
|
||||||
|
})();
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect_stdout: "-1"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5028_3: {
|
||||||
|
options = {
|
||||||
|
booleans: true,
|
||||||
|
conditionals: true,
|
||||||
|
evaluate: true,
|
||||||
|
if_return: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = 1;
|
||||||
|
(function() {
|
||||||
|
if (a--)
|
||||||
|
if (a--)
|
||||||
|
a = "FAIL";
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
})();
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = 1;
|
||||||
|
(function() {
|
||||||
|
a-- && a-- && (a = "FAIL");
|
||||||
|
})();
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect_stdout: "-1"
|
||||||
|
}
|
||||||
|
|||||||
@@ -260,6 +260,9 @@ block_scoped: {
|
|||||||
expect: {
|
expect: {
|
||||||
"use strict";
|
"use strict";
|
||||||
0;
|
0;
|
||||||
|
{
|
||||||
|
class A {}
|
||||||
|
}
|
||||||
if (console) {
|
if (console) {
|
||||||
class B {}
|
class B {}
|
||||||
}
|
}
|
||||||
@@ -269,6 +272,38 @@ block_scoped: {
|
|||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
retain_declaration: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
var a = "FAIL";
|
||||||
|
try {
|
||||||
|
console.log(function() {
|
||||||
|
return a;
|
||||||
|
class a {}
|
||||||
|
}());
|
||||||
|
} catch (e) {
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
var a = "FAIL";
|
||||||
|
try {
|
||||||
|
console.log(function() {
|
||||||
|
return a;
|
||||||
|
class a {}
|
||||||
|
}());
|
||||||
|
} catch (e) {
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|
||||||
drop_extends: {
|
drop_extends: {
|
||||||
options = {
|
options = {
|
||||||
inline: true,
|
inline: true,
|
||||||
@@ -632,6 +667,7 @@ collapse_non_strict: {
|
|||||||
collapse_rhs: {
|
collapse_rhs: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars: true,
|
collapse_vars: true,
|
||||||
|
unsafe: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
"use strict";
|
"use strict";
|
||||||
@@ -937,9 +973,9 @@ issue_4681: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
console.log(function(a) {
|
console.log(function(a) {
|
||||||
class A {
|
(class {
|
||||||
static p = a = this;
|
static p = a = this;
|
||||||
}
|
});
|
||||||
return typeof a;
|
return typeof a;
|
||||||
}());
|
}());
|
||||||
}
|
}
|
||||||
@@ -1363,9 +1399,9 @@ issue_4821_1: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
var a;
|
var a;
|
||||||
class A {
|
(class {
|
||||||
static p = void (a = this);
|
static p = void (a = this);
|
||||||
}
|
});
|
||||||
console.log(typeof a);
|
console.log(typeof a);
|
||||||
}
|
}
|
||||||
expect_stdout: "function"
|
expect_stdout: "function"
|
||||||
@@ -1643,3 +1679,199 @@ issue_4962_2: {
|
|||||||
expect_stdout: "undefined"
|
expect_stdout: "undefined"
|
||||||
node_version: ">=12"
|
node_version: ">=12"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_4982_1: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
try {} catch (e) {
|
||||||
|
class A extends 42 {}
|
||||||
|
}
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
{
|
||||||
|
class A {}
|
||||||
|
}
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_4982_2: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = "PASS";
|
||||||
|
try {} catch (e) {
|
||||||
|
class A {
|
||||||
|
static p = a = "FAIL";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = "PASS";
|
||||||
|
{
|
||||||
|
class A {}
|
||||||
|
}
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=12"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_4992: {
|
||||||
|
options = {
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
class A {
|
||||||
|
static P = this;
|
||||||
|
get p() {}
|
||||||
|
}
|
||||||
|
console.log(typeof A.P);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(typeof class {
|
||||||
|
static P = this;
|
||||||
|
get p() {}
|
||||||
|
}.P);
|
||||||
|
}
|
||||||
|
expect_stdout: "function"
|
||||||
|
node_version: ">=12"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_4996_1: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = 1;
|
||||||
|
console.log(new class A {
|
||||||
|
p = a-- && new A();
|
||||||
|
}().p.p);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = 1;
|
||||||
|
console.log(new class A {
|
||||||
|
p = a-- && new A();
|
||||||
|
}().p.p);
|
||||||
|
}
|
||||||
|
expect_stdout: "0"
|
||||||
|
node_version: ">=12"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_4996_2: {
|
||||||
|
options = {
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = 1;
|
||||||
|
console.log(new class A {
|
||||||
|
p = a-- && new A();
|
||||||
|
}().p.p);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = 1;
|
||||||
|
console.log(new class A {
|
||||||
|
p = a-- && new A();
|
||||||
|
}().p.p);
|
||||||
|
}
|
||||||
|
expect_stdout: "0"
|
||||||
|
node_version: ">=12"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5015_1: {
|
||||||
|
options = {
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
var a;
|
||||||
|
try {
|
||||||
|
(class a {
|
||||||
|
[a]() {}
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
var a;
|
||||||
|
try {
|
||||||
|
(class a {
|
||||||
|
[a]() {}
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5015_2: {
|
||||||
|
options = {
|
||||||
|
reduce_vars: true,
|
||||||
|
side_effects: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
try {
|
||||||
|
new class A {
|
||||||
|
[(A, 42)]() {}
|
||||||
|
}();
|
||||||
|
} catch (e) {
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
try {
|
||||||
|
new class A {
|
||||||
|
[(A, 42)]() {}
|
||||||
|
}();
|
||||||
|
} catch (e) {
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5015_3: {
|
||||||
|
options = {
|
||||||
|
reduce_vars: true,
|
||||||
|
side_effects: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
(class A {
|
||||||
|
static f() {
|
||||||
|
return A;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|||||||
@@ -2264,6 +2264,7 @@ var_defs: {
|
|||||||
properties: true,
|
properties: true,
|
||||||
sequences: true,
|
sequences: true,
|
||||||
side_effects: true,
|
side_effects: true,
|
||||||
|
unsafe: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
@@ -2486,6 +2487,7 @@ issue_1858: {
|
|||||||
options = {
|
options = {
|
||||||
collapse_vars: true,
|
collapse_vars: true,
|
||||||
pure_getters: true,
|
pure_getters: true,
|
||||||
|
reduce_vars: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
@@ -2907,6 +2909,7 @@ compound_assignment_2: {
|
|||||||
issue_2187_1: {
|
issue_2187_1: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars: true,
|
collapse_vars: true,
|
||||||
|
reduce_vars: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
@@ -4271,6 +4274,7 @@ issue_2436_14: {
|
|||||||
options = {
|
options = {
|
||||||
collapse_vars: true,
|
collapse_vars: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
|
unsafe: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
@@ -4724,7 +4728,7 @@ cascade_statement: {
|
|||||||
}
|
}
|
||||||
function f3(a, b) {
|
function f3(a, b) {
|
||||||
for (; a < b; a++)
|
for (; a < b; a++)
|
||||||
if (c = a, a && b)
|
if ((c = a) && b)
|
||||||
var c = c = b(a);
|
var c = c = b(a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4761,6 +4765,7 @@ unsafe_builtin: {
|
|||||||
options = {
|
options = {
|
||||||
collapse_vars: true,
|
collapse_vars: true,
|
||||||
pure_getters: "strict",
|
pure_getters: "strict",
|
||||||
|
reduce_vars: true,
|
||||||
unsafe: true,
|
unsafe: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
@@ -6965,6 +6970,7 @@ sequence_in_iife_2: {
|
|||||||
inline: true,
|
inline: true,
|
||||||
passes: 2,
|
passes: 2,
|
||||||
side_effects: true,
|
side_effects: true,
|
||||||
|
unsafe: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
@@ -6976,7 +6982,7 @@ sequence_in_iife_2: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
var a = "foo", b = 42;
|
var a = "foo", b = 42;
|
||||||
console.log(a, b = a);
|
console.log(b = a, b);
|
||||||
}
|
}
|
||||||
expect_stdout: "foo foo"
|
expect_stdout: "foo foo"
|
||||||
}
|
}
|
||||||
@@ -6988,6 +6994,7 @@ sequence_in_iife_3: {
|
|||||||
passes: 2,
|
passes: 2,
|
||||||
side_effects: true,
|
side_effects: true,
|
||||||
toplevel: true,
|
toplevel: true,
|
||||||
|
unsafe: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
@@ -7092,6 +7099,7 @@ setter_side_effect: {
|
|||||||
substitution_assign: {
|
substitution_assign: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars: true,
|
collapse_vars: true,
|
||||||
|
unsafe: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
function f1(a, b) {
|
function f1(a, b) {
|
||||||
@@ -7112,8 +7120,7 @@ substitution_assign: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
function f1(a, b) {
|
function f1(a, b) {
|
||||||
f1 = a;
|
console.log(f1 = a, a);
|
||||||
console.log(a, a);
|
|
||||||
}
|
}
|
||||||
function f2(a, b) {
|
function f2(a, b) {
|
||||||
a = 1 + (b = a);
|
a = 1 + (b = a);
|
||||||
@@ -7917,6 +7924,7 @@ issue_3744: {
|
|||||||
assign_value_def: {
|
assign_value_def: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars: true,
|
collapse_vars: true,
|
||||||
|
reduce_vars: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
@@ -7957,6 +7965,7 @@ join_vars_value_def: {
|
|||||||
options = {
|
options = {
|
||||||
collapse_vars: true,
|
collapse_vars: true,
|
||||||
join_vars: true,
|
join_vars: true,
|
||||||
|
reduce_vars: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
@@ -7996,6 +8005,7 @@ join_vars_value_def: {
|
|||||||
var_value_def: {
|
var_value_def: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars: true,
|
collapse_vars: true,
|
||||||
|
reduce_vars: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
@@ -8033,6 +8043,7 @@ var_value_def: {
|
|||||||
mangleable_var: {
|
mangleable_var: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars: true,
|
collapse_vars: true,
|
||||||
|
reduce_vars: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
@@ -8067,6 +8078,7 @@ mangleable_var: {
|
|||||||
mangleable_assignment_1: {
|
mangleable_assignment_1: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars: true,
|
collapse_vars: true,
|
||||||
|
reduce_vars: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
@@ -8098,6 +8110,7 @@ mangleable_assignment_1: {
|
|||||||
mangleable_assignment_2: {
|
mangleable_assignment_2: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars: true,
|
collapse_vars: true,
|
||||||
|
reduce_vars: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
@@ -8850,7 +8863,7 @@ issue_4732_1: {
|
|||||||
expect: {
|
expect: {
|
||||||
var a = 0;
|
var a = 0;
|
||||||
(function(b) {
|
(function(b) {
|
||||||
(b = a++) && (b && console.log("PASS"));
|
(b = a++) && console.log("PASS");
|
||||||
})(a++);
|
})(a++);
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
@@ -8939,6 +8952,8 @@ dot_non_local: {
|
|||||||
issue_4806: {
|
issue_4806: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars: true,
|
collapse_vars: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
var a, o = {
|
var a, o = {
|
||||||
@@ -8962,6 +8977,7 @@ issue_4806: {
|
|||||||
issue_4852: {
|
issue_4852: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars: true,
|
collapse_vars: true,
|
||||||
|
unsafe: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
var a = "PASS";
|
var a = "PASS";
|
||||||
@@ -9195,7 +9211,7 @@ issue_4918: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_4920: {
|
issue_4920_1: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars: true,
|
collapse_vars: true,
|
||||||
toplevel: true,
|
toplevel: true,
|
||||||
@@ -9221,6 +9237,64 @@ issue_4920: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_4920_2: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var o = {
|
||||||
|
get PASS() {
|
||||||
|
a = "FAIL";
|
||||||
|
},
|
||||||
|
};
|
||||||
|
var a = "PASS", b;
|
||||||
|
o[b = a];
|
||||||
|
console.log(b);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var o = {
|
||||||
|
get PASS() {
|
||||||
|
a = "FAIL";
|
||||||
|
},
|
||||||
|
};
|
||||||
|
var a = "PASS", b;
|
||||||
|
o[b = a];
|
||||||
|
console.log(b);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_4920_3: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var log = console.log;
|
||||||
|
var o = {
|
||||||
|
get PASS() {
|
||||||
|
a = "FAIL";
|
||||||
|
},
|
||||||
|
};
|
||||||
|
var a = "PASS", b;
|
||||||
|
o[b = a];
|
||||||
|
log(b);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var log = console.log;
|
||||||
|
var o = {
|
||||||
|
get PASS() {
|
||||||
|
a = "FAIL";
|
||||||
|
},
|
||||||
|
};
|
||||||
|
var a = "PASS", b;
|
||||||
|
o[b = a];
|
||||||
|
log(b);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
issue_4935: {
|
issue_4935: {
|
||||||
options = {
|
options = {
|
||||||
collapse_vars: true,
|
collapse_vars: true,
|
||||||
@@ -9279,3 +9353,62 @@ inline_throw: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_4977_1: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
unsafe: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = "FAIL";
|
||||||
|
var o = {
|
||||||
|
get p() {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
a = "PASS";
|
||||||
|
console.log(o.p, a);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = "FAIL";
|
||||||
|
var o = {
|
||||||
|
get p() {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
a = "PASS";
|
||||||
|
console.log(o.p, a);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_4977_2: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
unsafe: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a, o = {
|
||||||
|
get p() {
|
||||||
|
return a = "PASS";
|
||||||
|
},
|
||||||
|
};
|
||||||
|
if (console) {
|
||||||
|
var a = "FAIL";
|
||||||
|
console.log(o.p, a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a, o = {
|
||||||
|
get p() {
|
||||||
|
return a = "PASS";
|
||||||
|
},
|
||||||
|
};
|
||||||
|
if (console) {
|
||||||
|
var a = "FAIL";
|
||||||
|
console.log(o.p, a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS PASS"
|
||||||
|
}
|
||||||
|
|||||||
@@ -822,6 +822,33 @@ cond_13: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cond_14: {
|
||||||
|
options = {
|
||||||
|
booleans: true,
|
||||||
|
conditionals: true,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f(a) {
|
||||||
|
if (a)
|
||||||
|
if (a)
|
||||||
|
console.log("PASS");
|
||||||
|
else
|
||||||
|
console.log("FAIL");
|
||||||
|
}
|
||||||
|
f(null);
|
||||||
|
f(42);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f(a) {
|
||||||
|
a && console.log("PASS");
|
||||||
|
}
|
||||||
|
f(null);
|
||||||
|
f(42);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
ternary_boolean_consequent: {
|
ternary_boolean_consequent: {
|
||||||
options = {
|
options = {
|
||||||
booleans: true,
|
booleans: true,
|
||||||
|
|||||||
@@ -939,6 +939,185 @@ catch_return_assign: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
catch_return_assign_may_throw: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f() {
|
||||||
|
try {
|
||||||
|
throw "FAIL";
|
||||||
|
} catch (e) {
|
||||||
|
return e = console.log("PASS");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
f();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f() {
|
||||||
|
try {
|
||||||
|
throw "FAIL";
|
||||||
|
} catch (e) {
|
||||||
|
return console.log("PASS");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
f();
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
finally_return_assign: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(function(a) {
|
||||||
|
try {
|
||||||
|
throw "FAIL";
|
||||||
|
} finally {
|
||||||
|
return a = "PASS";
|
||||||
|
}
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(function(a) {
|
||||||
|
try {
|
||||||
|
throw "FAIL";
|
||||||
|
} finally {
|
||||||
|
return "PASS";
|
||||||
|
}
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
last_assign_statement: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f(a) {
|
||||||
|
a = a("PASS");
|
||||||
|
}
|
||||||
|
f(console.log);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f(a) {
|
||||||
|
a("PASS");
|
||||||
|
}
|
||||||
|
f(console.log);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
last_assign_if_else: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f(a) {
|
||||||
|
if (a)
|
||||||
|
a = console.log("foo");
|
||||||
|
else {
|
||||||
|
console.log("bar");
|
||||||
|
a = console.log("baz");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
f(42);
|
||||||
|
f(null);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f(a) {
|
||||||
|
if (a)
|
||||||
|
console.log("foo");
|
||||||
|
else {
|
||||||
|
console.log("bar");
|
||||||
|
console.log("baz");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
f(42);
|
||||||
|
f(null);
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"foo",
|
||||||
|
"bar",
|
||||||
|
"baz",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
last_assign_catch: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f() {
|
||||||
|
try {
|
||||||
|
throw "FAIL";
|
||||||
|
} catch (e) {
|
||||||
|
e = console.log("PASS");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
f();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f() {
|
||||||
|
try {
|
||||||
|
throw "FAIL";
|
||||||
|
} catch (e) {
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
f();
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
last_assign_finally: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f(a) {
|
||||||
|
try {
|
||||||
|
throw a.log;
|
||||||
|
} catch (e) {
|
||||||
|
a = e;
|
||||||
|
} finally {
|
||||||
|
a = a("PASS");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
f(console);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f(a) {
|
||||||
|
try {
|
||||||
|
throw a.log;
|
||||||
|
} catch (e) {
|
||||||
|
a = e;
|
||||||
|
} finally {
|
||||||
|
a("PASS");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
f(console);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
consecutive_assignments: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
while (a = void 0, a = "PASS", console.log(a));
|
||||||
|
var a;
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
while (void 0, a = "PASS", console.log(a));
|
||||||
|
var a;
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
issue_3578: {
|
issue_3578: {
|
||||||
options = {
|
options = {
|
||||||
dead_code: true,
|
dead_code: true,
|
||||||
@@ -1420,3 +1599,37 @@ issue_4570: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "NaN"
|
expect_stdout: "NaN"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5030: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(function(a, b) {
|
||||||
|
a = function f() {
|
||||||
|
if (a)
|
||||||
|
if (b--)
|
||||||
|
setImmediate(f);
|
||||||
|
else
|
||||||
|
console.log("FAIL");
|
||||||
|
else
|
||||||
|
console.log("PASS");
|
||||||
|
}();
|
||||||
|
})(42, 1);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(function(a, b) {
|
||||||
|
a = function f() {
|
||||||
|
if (a)
|
||||||
|
if (b--)
|
||||||
|
setImmediate(f);
|
||||||
|
else
|
||||||
|
console.log("FAIL");
|
||||||
|
else
|
||||||
|
console.log("PASS");
|
||||||
|
}();
|
||||||
|
})(42, 1);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=0.12"
|
||||||
|
}
|
||||||
|
|||||||
@@ -422,7 +422,9 @@ inline_loop_1: {
|
|||||||
inline_loop_2: {
|
inline_loop_2: {
|
||||||
options = {
|
options = {
|
||||||
inline: true,
|
inline: true,
|
||||||
|
sequences: true,
|
||||||
toplevel: true,
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
while (function(a = [ "PASS" ]) {
|
while (function(a = [ "PASS" ]) {
|
||||||
@@ -432,10 +434,11 @@ inline_loop_2: {
|
|||||||
}());
|
}());
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
while (a = [ "PASS" ], a = function f(b) {
|
while (a = [ "PASS" ],
|
||||||
console.log(a[b]);
|
b = void 0,
|
||||||
}(0), void 0) ;
|
b = 0,
|
||||||
var a;
|
void (a = void console.log(a[b])));
|
||||||
|
var a, b;
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=6"
|
node_version: ">=6"
|
||||||
@@ -598,6 +601,7 @@ unused_var_1: {
|
|||||||
|
|
||||||
unused_var_2: {
|
unused_var_2: {
|
||||||
options = {
|
options = {
|
||||||
|
pure_getters: "strict",
|
||||||
toplevel: true,
|
toplevel: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
@@ -609,11 +613,7 @@ unused_var_2: {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
var {
|
console.log("PASS");
|
||||||
p: [] = [ console.log("FAIL") ],
|
|
||||||
} = {
|
|
||||||
p: [ console.log("PASS") ],
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=6"
|
node_version: ">=6"
|
||||||
@@ -1729,3 +1729,28 @@ issue_4916: {
|
|||||||
expect_stdout: "undefined"
|
expect_stdout: "undefined"
|
||||||
node_version: ">=6"
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_4994: {
|
||||||
|
options = {
|
||||||
|
loops: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = "FAIL";
|
||||||
|
(function(b = function() {
|
||||||
|
for (a in { PASS: 42 });
|
||||||
|
}()) {
|
||||||
|
var a;
|
||||||
|
})();
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = "FAIL";
|
||||||
|
(function(b = function() {
|
||||||
|
for (a in { PASS: 42 });
|
||||||
|
}()) {})();
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|||||||
@@ -1010,6 +1010,42 @@ collapse_vars_8: {
|
|||||||
node_version: ">=6"
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
collapse_vars_9: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(function(a) {
|
||||||
|
try {
|
||||||
|
var b = function([ c ]) {
|
||||||
|
if (c)
|
||||||
|
return "FAIL 1";
|
||||||
|
}();
|
||||||
|
a = "FAIL 2";
|
||||||
|
return b;
|
||||||
|
} catch (e) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
}("PASS"));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(function(a) {
|
||||||
|
try {
|
||||||
|
var b = function([ c ]) {
|
||||||
|
if (c)
|
||||||
|
return "FAIL 1";
|
||||||
|
}();
|
||||||
|
a = "FAIL 2";
|
||||||
|
return b;
|
||||||
|
} catch (e) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
}("PASS"));
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|
||||||
conditionals: {
|
conditionals: {
|
||||||
options = {
|
options = {
|
||||||
conditionals: true,
|
conditionals: true,
|
||||||
@@ -2556,3 +2592,58 @@ issue_4608_2: {
|
|||||||
expect_stdout: "f"
|
expect_stdout: "f"
|
||||||
node_version: ">=6"
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_4994: {
|
||||||
|
options = {
|
||||||
|
loops: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = "FAIL";
|
||||||
|
(function([
|
||||||
|
{
|
||||||
|
[function() {
|
||||||
|
for (a in { PASS: null });
|
||||||
|
}()]: b,
|
||||||
|
},
|
||||||
|
]) {
|
||||||
|
var a;
|
||||||
|
})([ 42 ]);
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = "FAIL";
|
||||||
|
(function([
|
||||||
|
{
|
||||||
|
[function() {
|
||||||
|
for (a in { PASS: null });
|
||||||
|
}()]: b,
|
||||||
|
},
|
||||||
|
]) {})([ 42 ]);
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5017: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = function() {};
|
||||||
|
var b = c = a;
|
||||||
|
var c = [ c ] = [ c ];
|
||||||
|
console.log(c[0] === a ? "PASS" : "FAIL");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = function() {};
|
||||||
|
var b = a;
|
||||||
|
var c = [ c ] = [ c = a ];
|
||||||
|
console.log(c[0] === a ? "PASS" : "FAIL");
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|||||||
@@ -5236,7 +5236,7 @@ issue_4265: {
|
|||||||
expect: {
|
expect: {
|
||||||
function f() {
|
function f() {
|
||||||
return console, function() {
|
return console, function() {
|
||||||
return console.log(a);
|
console.log(a);
|
||||||
var a;
|
var a;
|
||||||
}(), 0;
|
}(), 0;
|
||||||
}
|
}
|
||||||
@@ -6208,3 +6208,78 @@ reduce_cross_reference_4_toplevel: {
|
|||||||
expect: {}
|
expect: {}
|
||||||
expect_stdout: true
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
recursive_collapse: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(function f(a) {
|
||||||
|
var b = a && f();
|
||||||
|
return b;
|
||||||
|
}("FAIL") || "PASS");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(function f(a) {
|
||||||
|
var b;
|
||||||
|
return a && f();
|
||||||
|
}("FAIL") || "PASS");
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5025: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
inline: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f(a) {
|
||||||
|
function g() {
|
||||||
|
b = 42;
|
||||||
|
}
|
||||||
|
g(b = a);
|
||||||
|
var b = this;
|
||||||
|
console.log(typeof b);
|
||||||
|
}
|
||||||
|
f();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f(a) {
|
||||||
|
b = a,
|
||||||
|
void (b = 42);
|
||||||
|
var b = this;
|
||||||
|
console.log(typeof b);
|
||||||
|
}
|
||||||
|
f();
|
||||||
|
}
|
||||||
|
expect_stdout: "object"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5036: {
|
||||||
|
options = {
|
||||||
|
functions: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(typeof function() {
|
||||||
|
var await = function f() {
|
||||||
|
return f;
|
||||||
|
};
|
||||||
|
return await() === await;
|
||||||
|
}() ? "PASS" : "FAIL");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(typeof function() {
|
||||||
|
function await() {
|
||||||
|
return await;
|
||||||
|
}
|
||||||
|
return await() === await;
|
||||||
|
}() ? "PASS" : "FAIL");
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|||||||
@@ -94,13 +94,15 @@ drop_unused: {
|
|||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
import a, * as b from "foo";
|
import a, * as b from "foo";
|
||||||
import { c, bar as d } from "baz";
|
import { c } from "bar";
|
||||||
console.log(c);
|
import { d, _ as e } from "baz";
|
||||||
|
console.log(d);
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
import "foo";
|
import "foo";
|
||||||
import { c as c } from "baz";
|
import "bar";
|
||||||
console.log(c);
|
import { d as d } from "baz";
|
||||||
|
console.log(d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1015,7 +1015,7 @@ issue_3856: {
|
|||||||
console.log(function() {
|
console.log(function() {
|
||||||
(function() {
|
(function() {
|
||||||
var a, b;
|
var a, b;
|
||||||
if (a) return !!a;
|
if (a) return a, 1;
|
||||||
for (a = 0; !console;);
|
for (a = 0; !console;);
|
||||||
return 0;
|
return 0;
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ issue_1858: {
|
|||||||
collapse_vars: true,
|
collapse_vars: true,
|
||||||
keep_fargs: false,
|
keep_fargs: false,
|
||||||
pure_getters: true,
|
pure_getters: true,
|
||||||
|
reduce_vars: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
@@ -1157,8 +1158,8 @@ replace_all_var_scope: {
|
|||||||
var a = 100, b = 10;
|
var a = 100, b = 10;
|
||||||
(function(r, a) {
|
(function(r, a) {
|
||||||
switch (~a) {
|
switch (~a) {
|
||||||
case (b += a):
|
case (b += a):
|
||||||
case a++:
|
case a++:
|
||||||
}
|
}
|
||||||
})(--b, a);
|
})(--b, a);
|
||||||
console.log(a, b);
|
console.log(a, b);
|
||||||
@@ -1167,8 +1168,8 @@ replace_all_var_scope: {
|
|||||||
var a = 100, b = 10;
|
var a = 100, b = 10;
|
||||||
(function(c) {
|
(function(c) {
|
||||||
switch (~a) {
|
switch (~a) {
|
||||||
case (b += a):
|
case (b += a):
|
||||||
case c++:
|
case c++:
|
||||||
}
|
}
|
||||||
})((--b, a));
|
})((--b, a));
|
||||||
console.log(a, b);
|
console.log(a, b);
|
||||||
|
|||||||
@@ -20,6 +20,39 @@ retain_block: {
|
|||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
retain_assignment: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
function f() {
|
||||||
|
return a = 0;
|
||||||
|
let a;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
f();
|
||||||
|
} catch (e) {
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
function f() {
|
||||||
|
return a = 0;
|
||||||
|
let a;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
f();
|
||||||
|
} catch (e) {
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|
||||||
retain_catch: {
|
retain_catch: {
|
||||||
options = {
|
options = {
|
||||||
dead_code: true,
|
dead_code: true,
|
||||||
@@ -536,6 +569,38 @@ loop_block_2: {
|
|||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_break: {
|
||||||
|
options = {
|
||||||
|
loops: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
try {
|
||||||
|
do {
|
||||||
|
if (a)
|
||||||
|
break;
|
||||||
|
let a;
|
||||||
|
} while (!console);
|
||||||
|
} catch (e) {
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
try {
|
||||||
|
do {
|
||||||
|
if (a)
|
||||||
|
break;
|
||||||
|
let a;
|
||||||
|
} while (!console);
|
||||||
|
} catch (e) {
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|
||||||
do_continue: {
|
do_continue: {
|
||||||
options = {
|
options = {
|
||||||
loops: true,
|
loops: true,
|
||||||
@@ -596,6 +661,82 @@ dead_block_after_return: {
|
|||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if_return_1: {
|
||||||
|
options = {
|
||||||
|
if_return: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
function f(a) {
|
||||||
|
function g() {
|
||||||
|
return b = "PASS";
|
||||||
|
}
|
||||||
|
if (a)
|
||||||
|
return g();
|
||||||
|
let b;
|
||||||
|
return g();
|
||||||
|
};
|
||||||
|
console.log(f());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
function f(a) {
|
||||||
|
function g() {
|
||||||
|
return b = "PASS";
|
||||||
|
}
|
||||||
|
if (a)
|
||||||
|
return g();
|
||||||
|
let b;
|
||||||
|
return g();
|
||||||
|
};
|
||||||
|
console.log(f());
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|
||||||
|
if_return_2: {
|
||||||
|
options = {
|
||||||
|
if_return: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
function f(a) {
|
||||||
|
function g() {
|
||||||
|
return b = "FAIL";
|
||||||
|
}
|
||||||
|
if (a)
|
||||||
|
return g();
|
||||||
|
let b;
|
||||||
|
return g();
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
console.log(f(42));
|
||||||
|
} catch (e) {
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
function f(a) {
|
||||||
|
function g() {
|
||||||
|
return b = "FAIL";
|
||||||
|
}
|
||||||
|
if (a)
|
||||||
|
return g();
|
||||||
|
let b;
|
||||||
|
return g();
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
console.log(f(42));
|
||||||
|
} catch (e) {
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|
||||||
do_if_continue_1: {
|
do_if_continue_1: {
|
||||||
options = {
|
options = {
|
||||||
if_return: true,
|
if_return: true,
|
||||||
@@ -897,6 +1038,7 @@ issue_4210: {
|
|||||||
issue_4212_1: {
|
issue_4212_1: {
|
||||||
options = {
|
options = {
|
||||||
dead_code: true,
|
dead_code: true,
|
||||||
|
reduce_vars: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
"use strict";
|
"use strict";
|
||||||
@@ -1546,3 +1688,27 @@ issue_4848: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_4985: {
|
||||||
|
options = {
|
||||||
|
hoist_props: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
let a = { p: 42 };
|
||||||
|
console.log(function() {
|
||||||
|
a;
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
let a = { p: 42 };
|
||||||
|
console.log(function() {
|
||||||
|
a;
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect_stdout: "undefined"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|||||||
@@ -3075,7 +3075,7 @@ issue_4237_2: {
|
|||||||
console.log(function(a) {
|
console.log(function(a) {
|
||||||
do {
|
do {
|
||||||
switch (0) {
|
switch (0) {
|
||||||
case 0:
|
default:
|
||||||
var b = a++;
|
var b = a++;
|
||||||
if (b)
|
if (b)
|
||||||
return "FAIL";
|
return "FAIL";
|
||||||
|
|||||||
@@ -110,6 +110,158 @@ conditional_assignment_4: {
|
|||||||
node_version: ">=14"
|
node_version: ">=14"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
de_morgan_1: {
|
||||||
|
options = {
|
||||||
|
booleans: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f(a) {
|
||||||
|
return a ?? a;
|
||||||
|
}
|
||||||
|
console.log(f(null), f(42));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f(a) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
console.log(f(null), f(42));
|
||||||
|
}
|
||||||
|
expect_stdout: "null 42"
|
||||||
|
node_version: ">=14"
|
||||||
|
}
|
||||||
|
|
||||||
|
de_morgan_2a: {
|
||||||
|
options = {
|
||||||
|
booleans: true,
|
||||||
|
conditionals: true,
|
||||||
|
evaluate: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f(a, b) {
|
||||||
|
return a || (a ?? b);
|
||||||
|
}
|
||||||
|
console.log(f(null), f(null, {}));
|
||||||
|
console.log(f(42), f(42, {}));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f(a, b) {
|
||||||
|
return a || (a ?? b);
|
||||||
|
}
|
||||||
|
console.log(f(null), f(null, {}));
|
||||||
|
console.log(f(42), f(42, {}));
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"undefined {}",
|
||||||
|
"42 42",
|
||||||
|
]
|
||||||
|
node_version: ">=14"
|
||||||
|
}
|
||||||
|
|
||||||
|
de_morgan_2b: {
|
||||||
|
options = {
|
||||||
|
booleans: true,
|
||||||
|
evaluate: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f(a, b) {
|
||||||
|
return a && (a ?? b);
|
||||||
|
}
|
||||||
|
console.log(f(null), f(null, {}));
|
||||||
|
console.log(f(42), f(42, {}));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f(a, b) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
console.log(f(null), f(null, {}));
|
||||||
|
console.log(f(42), f(42, {}));
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"null null",
|
||||||
|
"42 42",
|
||||||
|
]
|
||||||
|
node_version: ">=14"
|
||||||
|
}
|
||||||
|
|
||||||
|
de_morgan_2c: {
|
||||||
|
options = {
|
||||||
|
booleans: true,
|
||||||
|
evaluate: true,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f(a, b) {
|
||||||
|
return a ?? (a || b);
|
||||||
|
}
|
||||||
|
console.log(f(null), f(null, {}));
|
||||||
|
console.log(f(42), f(42, {}));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f(a, b) {
|
||||||
|
return a ?? b;
|
||||||
|
}
|
||||||
|
console.log(f(null), f(null, {}));
|
||||||
|
console.log(f(42), f(42, {}));
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"undefined {}",
|
||||||
|
"42 42",
|
||||||
|
]
|
||||||
|
node_version: ">=14"
|
||||||
|
}
|
||||||
|
|
||||||
|
de_morgan_2d: {
|
||||||
|
options = {
|
||||||
|
booleans: true,
|
||||||
|
evaluate: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f(a, b) {
|
||||||
|
return a ?? (a && b);
|
||||||
|
}
|
||||||
|
console.log(f(null), f(null, {}));
|
||||||
|
console.log(f(42), f(42, {}));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f(a, b) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
console.log(f(null), f(null, {}));
|
||||||
|
console.log(f(42), f(42, {}));
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"null null",
|
||||||
|
"42 42",
|
||||||
|
]
|
||||||
|
node_version: ">=14"
|
||||||
|
}
|
||||||
|
|
||||||
|
de_morgan_2e: {
|
||||||
|
options = {
|
||||||
|
booleans: true,
|
||||||
|
conditionals: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f(a, b) {
|
||||||
|
return a ?? (a ?? b);
|
||||||
|
}
|
||||||
|
console.log(f(null), f(null, {}));
|
||||||
|
console.log(f(42), f(42, {}));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f(a, b) {
|
||||||
|
return a ?? b;
|
||||||
|
}
|
||||||
|
console.log(f(null), f(null, {}));
|
||||||
|
console.log(f(42), f(42, {}));
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"undefined {}",
|
||||||
|
"42 42",
|
||||||
|
]
|
||||||
|
node_version: ">=14"
|
||||||
|
}
|
||||||
|
|
||||||
issue_4679: {
|
issue_4679: {
|
||||||
options = {
|
options = {
|
||||||
comparisons: true,
|
comparisons: true,
|
||||||
|
|||||||
@@ -2071,72 +2071,6 @@ issue_1670_2: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
issue_1670_3: {
|
issue_1670_3: {
|
||||||
options = {
|
|
||||||
comparisons: true,
|
|
||||||
conditionals: true,
|
|
||||||
dead_code: true,
|
|
||||||
evaluate: true,
|
|
||||||
reduce_funcs: true,
|
|
||||||
reduce_vars: true,
|
|
||||||
side_effects: true,
|
|
||||||
switches: true,
|
|
||||||
typeofs: true,
|
|
||||||
unused: true,
|
|
||||||
}
|
|
||||||
input: {
|
|
||||||
(function f() {
|
|
||||||
switch (1) {
|
|
||||||
case 0:
|
|
||||||
var a = true;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
if (typeof a === "undefined") console.log("PASS");
|
|
||||||
else console.log("FAIL");
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
}
|
|
||||||
expect: {
|
|
||||||
(function() {
|
|
||||||
var a;
|
|
||||||
void 0 === a ? console.log("PASS") : console.log("FAIL");
|
|
||||||
})();
|
|
||||||
}
|
|
||||||
expect_stdout: "PASS"
|
|
||||||
}
|
|
||||||
|
|
||||||
issue_1670_4: {
|
|
||||||
options = {
|
|
||||||
conditionals: true,
|
|
||||||
dead_code: true,
|
|
||||||
evaluate: true,
|
|
||||||
passes: 2,
|
|
||||||
reduce_funcs: true,
|
|
||||||
reduce_vars: true,
|
|
||||||
side_effects: true,
|
|
||||||
switches: true,
|
|
||||||
unused: true,
|
|
||||||
}
|
|
||||||
input: {
|
|
||||||
(function f() {
|
|
||||||
switch (1) {
|
|
||||||
case 0:
|
|
||||||
var a = true;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
if (typeof a === "undefined") console.log("PASS");
|
|
||||||
else console.log("FAIL");
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
}
|
|
||||||
expect: {
|
|
||||||
(function() {
|
|
||||||
console.log("PASS");
|
|
||||||
})();
|
|
||||||
}
|
|
||||||
expect_stdout: "PASS"
|
|
||||||
}
|
|
||||||
|
|
||||||
issue_1670_5: {
|
|
||||||
options = {
|
options = {
|
||||||
conditionals: true,
|
conditionals: true,
|
||||||
dead_code: true,
|
dead_code: true,
|
||||||
@@ -2168,7 +2102,7 @@ issue_1670_5: {
|
|||||||
expect_stdout: "1"
|
expect_stdout: "1"
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_1670_6: {
|
issue_1670_4: {
|
||||||
options = {
|
options = {
|
||||||
conditionals: true,
|
conditionals: true,
|
||||||
dead_code: true,
|
dead_code: true,
|
||||||
|
|||||||
@@ -1156,3 +1156,23 @@ issue_4882_3: {
|
|||||||
]
|
]
|
||||||
node_version: ">=8"
|
node_version: ">=8"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5006: {
|
||||||
|
options = {
|
||||||
|
arguments: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(function(b, c) {
|
||||||
|
c = "FAIL 2";
|
||||||
|
return arguments[1];
|
||||||
|
}(...[], "FAIL 1") || "PASS");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(function(b, c) {
|
||||||
|
c = "FAIL 2";
|
||||||
|
return arguments[1];
|
||||||
|
}(...[], "FAIL 1") || "PASS");
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ constant_switch_5: {
|
|||||||
// the break inside the if ruins our job
|
// the break inside the if ruins our job
|
||||||
// we can still get rid of irrelevant cases.
|
// we can still get rid of irrelevant cases.
|
||||||
switch (1) {
|
switch (1) {
|
||||||
case 1:
|
default:
|
||||||
x();
|
x();
|
||||||
if (foo) break;
|
if (foo) break;
|
||||||
y();
|
y();
|
||||||
@@ -300,6 +300,37 @@ drop_default_2: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
drop_default_3: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
switches: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f() {
|
||||||
|
console.log("PASS");
|
||||||
|
return 42;
|
||||||
|
}
|
||||||
|
switch (42) {
|
||||||
|
case f():
|
||||||
|
break;
|
||||||
|
case void console.log("FAIL"):
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f() {
|
||||||
|
console.log("PASS");
|
||||||
|
return 42;
|
||||||
|
}
|
||||||
|
switch (42) {
|
||||||
|
case f():
|
||||||
|
case void console.log("FAIL"):
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
keep_default: {
|
keep_default: {
|
||||||
options = {
|
options = {
|
||||||
dead_code: true,
|
dead_code: true,
|
||||||
@@ -423,7 +454,6 @@ drop_case_3: {
|
|||||||
switch ({}.p) {
|
switch ({}.p) {
|
||||||
default:
|
default:
|
||||||
case void 0:
|
case void 0:
|
||||||
break;
|
|
||||||
case c = "FAIL":
|
case c = "FAIL":
|
||||||
}
|
}
|
||||||
console.log(c);
|
console.log(c);
|
||||||
@@ -454,7 +484,168 @@ drop_case_4: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
keep_case: {
|
drop_case_5: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
switches: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
switch (42) {
|
||||||
|
case void console.log("PASS 1"):
|
||||||
|
console.log("FAIL 1");
|
||||||
|
case 42:
|
||||||
|
case console.log("FAIL 2"):
|
||||||
|
console.log("PASS 2");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
switch (42) {
|
||||||
|
default:
|
||||||
|
void console.log("PASS 1");
|
||||||
|
console.log("PASS 2");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"PASS 1",
|
||||||
|
"PASS 2",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
drop_case_6: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
switches: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
switch (console.log("PASS 1"), 2) {
|
||||||
|
case 0:
|
||||||
|
console.log("FAIL 1");
|
||||||
|
case (console.log("PASS 2"), 1):
|
||||||
|
console.log("FAIL 2");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
switch (console.log("PASS 1"), 2) {
|
||||||
|
case (console.log("PASS 2"), 1):
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"PASS 1",
|
||||||
|
"PASS 2",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
drop_case_7: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
switches: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
switch (2) {
|
||||||
|
case 0:
|
||||||
|
console.log("FAIL 1");
|
||||||
|
case (console.log("PASS 1"), 1):
|
||||||
|
console.log("FAIL 2");
|
||||||
|
case 2:
|
||||||
|
console.log("PASS 2");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
switch (2) {
|
||||||
|
default:
|
||||||
|
console.log("PASS 1"), 1;
|
||||||
|
console.log("PASS 2");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"PASS 1",
|
||||||
|
"PASS 2",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
drop_case_8: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
switches: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function log(msg) {
|
||||||
|
console.log(msg);
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
switch (log("foo")) {
|
||||||
|
case "bar":
|
||||||
|
log("moo");
|
||||||
|
break;
|
||||||
|
case log("baz"):
|
||||||
|
log("moo");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
log("moo");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function log(msg) {
|
||||||
|
console.log(msg);
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
switch (log("foo")) {
|
||||||
|
case "bar":
|
||||||
|
case log("baz"):
|
||||||
|
default:
|
||||||
|
log("moo");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"foo",
|
||||||
|
"baz",
|
||||||
|
"moo",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
drop_case_9: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
switches: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function log(msg) {
|
||||||
|
console.log(msg);
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
switch (log("foo")) {
|
||||||
|
case log("bar"):
|
||||||
|
log("moo");
|
||||||
|
break;
|
||||||
|
case "baz":
|
||||||
|
log("moo");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
log("moo");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function log(msg) {
|
||||||
|
console.log(msg);
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
switch (log("foo")) {
|
||||||
|
default:
|
||||||
|
log("bar");
|
||||||
|
log("moo");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"foo",
|
||||||
|
"bar",
|
||||||
|
"moo",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
keep_case_1: {
|
||||||
options = {
|
options = {
|
||||||
dead_code: true,
|
dead_code: true,
|
||||||
switches: true,
|
switches: true,
|
||||||
@@ -474,6 +665,76 @@ keep_case: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
keep_case_2: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
switches: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
switch ("foo") {
|
||||||
|
case console.log("bar"):
|
||||||
|
case console.log("baz"), "moo":
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
switch ("foo") {
|
||||||
|
case console.log("bar"):
|
||||||
|
case console.log("baz"), "moo":
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"bar",
|
||||||
|
"baz",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
keep_case_3: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
switches: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a;
|
||||||
|
switch (void console.log("PASS")) {
|
||||||
|
case a:
|
||||||
|
case console.log("FAIL"), 42:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a;
|
||||||
|
switch (void console.log("PASS")) {
|
||||||
|
case a:
|
||||||
|
case console.log("FAIL"), 42:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
keep_case_4: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
switches: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a;
|
||||||
|
switch (void console.log("PASS")) {
|
||||||
|
case a:
|
||||||
|
case void console.log("FAIL"):
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a;
|
||||||
|
switch (void console.log("PASS")) {
|
||||||
|
case a:
|
||||||
|
case void console.log("FAIL"):
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
issue_376: {
|
issue_376: {
|
||||||
options = {
|
options = {
|
||||||
dead_code: true,
|
dead_code: true,
|
||||||
@@ -661,7 +922,7 @@ issue_1680_1: {
|
|||||||
case f(0):
|
case f(0):
|
||||||
case f(1):
|
case f(1):
|
||||||
f(2);
|
f(2);
|
||||||
case 2:
|
default:
|
||||||
f(5);
|
f(5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -924,7 +1185,6 @@ issue_2535: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
w(), 42;
|
w(), 42;
|
||||||
42;
|
|
||||||
y();
|
y();
|
||||||
z();
|
z();
|
||||||
}
|
}
|
||||||
@@ -950,7 +1210,6 @@ issue_1750: {
|
|||||||
expect: {
|
expect: {
|
||||||
var a = 0, b = 1;
|
var a = 0, b = 1;
|
||||||
true;
|
true;
|
||||||
a, true;
|
|
||||||
b = 2;
|
b = 2;
|
||||||
console.log(a, b);
|
console.log(a, b);
|
||||||
}
|
}
|
||||||
@@ -1088,7 +1347,8 @@ drop_switch_6: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
A === B;
|
A;
|
||||||
|
B;
|
||||||
x();
|
x();
|
||||||
C !== D;
|
C !== D;
|
||||||
y();
|
y();
|
||||||
@@ -1181,3 +1441,170 @@ issue_4059: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5008_1: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
switches: true,
|
||||||
|
unsafe: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(function f() {
|
||||||
|
switch (f) {
|
||||||
|
case f:
|
||||||
|
return "PASS";
|
||||||
|
default:
|
||||||
|
return "FAIL";
|
||||||
|
}
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(function f() {
|
||||||
|
switch (f) {
|
||||||
|
default:
|
||||||
|
return "PASS";
|
||||||
|
}
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5008_2: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
switches: true,
|
||||||
|
unsafe: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(function(a) {
|
||||||
|
switch (a) {
|
||||||
|
case a:
|
||||||
|
return "PASS";
|
||||||
|
default:
|
||||||
|
return "FAIL";
|
||||||
|
}
|
||||||
|
}([]));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(function(a) {
|
||||||
|
switch (a) {
|
||||||
|
default:
|
||||||
|
return "PASS";
|
||||||
|
}
|
||||||
|
}([]));
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5008_3: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
switches: true,
|
||||||
|
unsafe: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(function(a) {
|
||||||
|
switch (a) {
|
||||||
|
case a:
|
||||||
|
return "PASS";
|
||||||
|
default:
|
||||||
|
return "FAIL";
|
||||||
|
}
|
||||||
|
}({}));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(function(a) {
|
||||||
|
switch (a) {
|
||||||
|
default:
|
||||||
|
return "PASS";
|
||||||
|
}
|
||||||
|
}({}));
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5008_4: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
switches: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(function(a) {
|
||||||
|
switch (a) {
|
||||||
|
case a:
|
||||||
|
return "PASS";
|
||||||
|
default:
|
||||||
|
return "FAIL";
|
||||||
|
}
|
||||||
|
}(/foo/));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(function(a) {
|
||||||
|
switch (a) {
|
||||||
|
default:
|
||||||
|
return "PASS";
|
||||||
|
}
|
||||||
|
}(/foo/));
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5010: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
switches: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a;
|
||||||
|
switch (42) {
|
||||||
|
case console.log("PASS"):
|
||||||
|
case a:
|
||||||
|
console.log("FAIL");
|
||||||
|
case 42:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a;
|
||||||
|
switch (42) {
|
||||||
|
case console.log("PASS"):
|
||||||
|
case a:
|
||||||
|
console.log("FAIL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5012: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
switches: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
switch (void 0) {
|
||||||
|
case console.log("PASS"):
|
||||||
|
break;
|
||||||
|
case void 0:
|
||||||
|
case 42:
|
||||||
|
console.log("FAIL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
switch (void 0) {
|
||||||
|
case console.log("PASS"):
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
console.log("FAIL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
@@ -1083,3 +1083,166 @@ issue_4769_2: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=6"
|
node_version: ">=6"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5019_1: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(function(a) {
|
||||||
|
return a = function*() {
|
||||||
|
console.log(typeof a);
|
||||||
|
}();
|
||||||
|
})().next();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(function(a) {
|
||||||
|
return a = function*() {
|
||||||
|
console.log(typeof a);
|
||||||
|
}();
|
||||||
|
})().next();
|
||||||
|
}
|
||||||
|
expect_stdout: "object"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5019_2: {
|
||||||
|
options = {
|
||||||
|
inline: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = [];
|
||||||
|
for (var b in "foo")
|
||||||
|
a.push(function(c) {
|
||||||
|
return function*() {
|
||||||
|
console.log(c);
|
||||||
|
}();
|
||||||
|
}(b));
|
||||||
|
a.map(function(d) {
|
||||||
|
return d.next();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = [];
|
||||||
|
for (var b in "foo")
|
||||||
|
a.push(function(c) {
|
||||||
|
return function*() {
|
||||||
|
console.log(c);
|
||||||
|
}();
|
||||||
|
}(b));
|
||||||
|
a.map(function(d) {
|
||||||
|
return d.next();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"0",
|
||||||
|
"1",
|
||||||
|
"2",
|
||||||
|
]
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5032_normal: {
|
||||||
|
options = {
|
||||||
|
merge_vars: true,
|
||||||
|
webkit: false,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function log(value) {
|
||||||
|
console.log(value);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
function *f(a) {
|
||||||
|
var b = log(a), c = b;
|
||||||
|
log(b);
|
||||||
|
log(c);
|
||||||
|
}
|
||||||
|
f("PASS").next();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function log(value) {
|
||||||
|
console.log(value);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
function *f(c) {
|
||||||
|
var b = log(c), c = b;
|
||||||
|
log(b);
|
||||||
|
log(c);
|
||||||
|
}
|
||||||
|
f("PASS").next();
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"PASS",
|
||||||
|
"PASS",
|
||||||
|
"PASS",
|
||||||
|
]
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5032_webkit: {
|
||||||
|
options = {
|
||||||
|
merge_vars: true,
|
||||||
|
webkit: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function log(value) {
|
||||||
|
console.log(value);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
function *f(a) {
|
||||||
|
var b = log(a), c = b;
|
||||||
|
log(b);
|
||||||
|
log(c);
|
||||||
|
}
|
||||||
|
f("PASS").next();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function log(value) {
|
||||||
|
console.log(value);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
function *f(a) {
|
||||||
|
var b = log(a), c = b;
|
||||||
|
log(b);
|
||||||
|
log(c);
|
||||||
|
}
|
||||||
|
f("PASS").next();
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"PASS",
|
||||||
|
"PASS",
|
||||||
|
"PASS",
|
||||||
|
]
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5034: {
|
||||||
|
options = {
|
||||||
|
functions: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(function() {
|
||||||
|
var yield = function f() {
|
||||||
|
return function*() {
|
||||||
|
return f;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
return yield()().next().value === yield;
|
||||||
|
}() ? "PASS" : "FAIL");
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(function() {
|
||||||
|
var yield = function f() {
|
||||||
|
return function*() {
|
||||||
|
return f;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
return yield()().next().value === yield;
|
||||||
|
}() ? "PASS" : "FAIL");
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|||||||
@@ -58,22 +58,29 @@ if (typeof phantom == "undefined") {
|
|||||||
}).listen();
|
}).listen();
|
||||||
server.on("listening", function() {
|
server.on("listening", function() {
|
||||||
var port = server.address().port;
|
var port = server.address().port;
|
||||||
if (debug) {
|
if (debug) return console.log("http://localhost:" + port + "/");
|
||||||
console.log("http://localhost:" + port + "/");
|
var cmd = process.platform == "win32" ? "npm.cmd" : "npm";
|
||||||
} else (function install() {
|
|
||||||
child_process.spawn(process.platform == "win32" ? "npm.cmd" : "npm", [
|
function npm(args, done) {
|
||||||
|
child_process.spawn(cmd, args, { stdio: [ "ignore", 1, 2 ] }).on("exit", done);
|
||||||
|
}
|
||||||
|
|
||||||
|
(function install() {
|
||||||
|
npm([
|
||||||
"install",
|
"install",
|
||||||
"phantomjs-prebuilt@2.1.14",
|
"phantomjs-prebuilt@2.1.14",
|
||||||
"--no-audit",
|
"--no-audit",
|
||||||
"--no-optional",
|
"--no-optional",
|
||||||
"--no-save",
|
"--no-save",
|
||||||
"--no-update-notifier",
|
"--no-update-notifier",
|
||||||
], {
|
], function(code) {
|
||||||
stdio: [ "ignore", 1, 2 ]
|
|
||||||
}).on("exit", function(code) {
|
|
||||||
if (code) {
|
if (code) {
|
||||||
console.log("npm install failed with code", code);
|
console.log("npm install failed with code", code);
|
||||||
return install();
|
return npm([
|
||||||
|
"cache",
|
||||||
|
"clean",
|
||||||
|
"--force",
|
||||||
|
], install);
|
||||||
}
|
}
|
||||||
var program = require("phantomjs-prebuilt").exec(process.argv[1], port);
|
var program = require("phantomjs-prebuilt").exec(process.argv[1], port);
|
||||||
program.stdout.pipe(process.stdout);
|
program.stdout.pipe(process.stdout);
|
||||||
|
|||||||
@@ -14,6 +14,13 @@ minify_in_situ() {
|
|||||||
uglify-js $ARGS
|
uglify-js $ARGS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
npm_install() {
|
||||||
|
PKG="$1"
|
||||||
|
while !(npm install $PKG); do
|
||||||
|
while !(npm cache clean --force); do echo "'npm cache clean' failed - retrying..."; done
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
rm -rf tmp/acorn \
|
rm -rf tmp/acorn \
|
||||||
&& git clone https://github.com/acornjs/acorn.git tmp/acorn \
|
&& git clone https://github.com/acornjs/acorn.git tmp/acorn \
|
||||||
&& cd tmp/acorn \
|
&& cd tmp/acorn \
|
||||||
@@ -89,7 +96,7 @@ minify_in_situ "acorn/src" \
|
|||||||
&& minify_in_situ "acorn-loose/src" \
|
&& minify_in_situ "acorn-loose/src" \
|
||||||
&& minify_in_situ "acorn-walk/src" \
|
&& minify_in_situ "acorn-walk/src" \
|
||||||
&& rm -rf node_modules \
|
&& rm -rf node_modules \
|
||||||
&& npm install \
|
&& npm_install \
|
||||||
&& rm -rf acorn/dist acorn-loose/dist acorn-walk/dist \
|
&& rm -rf acorn/dist acorn-loose/dist acorn-walk/dist \
|
||||||
&& npm run build \
|
&& npm run build \
|
||||||
&& minify_in_situ "acorn/dist" \
|
&& minify_in_situ "acorn/dist" \
|
||||||
|
|||||||
@@ -14,6 +14,13 @@ minify_in_situ() {
|
|||||||
uglify-js $ARGS
|
uglify-js $ARGS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
npm_install() {
|
||||||
|
PKG="$1"
|
||||||
|
while !(npm install $PKG); do
|
||||||
|
while !(npm cache clean --force); do echo "'npm cache clean' failed - retrying..."; done
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
rm -rf tmp/bootstrap \
|
rm -rf tmp/bootstrap \
|
||||||
&& git clone --depth 1 --branch v5.0.0-beta2 https://github.com/twbs/bootstrap.git tmp/bootstrap \
|
&& git clone --depth 1 --branch v5.0.0-beta2 https://github.com/twbs/bootstrap.git tmp/bootstrap \
|
||||||
&& cd tmp/bootstrap \
|
&& cd tmp/bootstrap \
|
||||||
@@ -171,7 +178,7 @@ rm -rf tmp/bootstrap \
|
|||||||
EOF
|
EOF
|
||||||
ERR=$?; if [ "$ERR" != "0" ]; then echo "Error: $ERR"; exit $ERR; fi
|
ERR=$?; if [ "$ERR" != "0" ]; then echo "Error: $ERR"; exit $ERR; fi
|
||||||
rm -rf node_modules \
|
rm -rf node_modules \
|
||||||
&& npm ci \
|
&& npm_install \
|
||||||
&& minify_in_situ "node_modules/@popperjs/core" \
|
&& minify_in_situ "node_modules/@popperjs/core" \
|
||||||
&& rm -rf dist/js/* \
|
&& rm -rf dist/js/* \
|
||||||
&& minify_in_situ "build" \
|
&& minify_in_situ "build" \
|
||||||
|
|||||||
@@ -14,6 +14,13 @@ minify_in_situ() {
|
|||||||
uglify-js $ARGS
|
uglify-js $ARGS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
npm_install() {
|
||||||
|
PKG="$1"
|
||||||
|
while !(npm install $PKG); do
|
||||||
|
while !(npm cache clean --force); do echo "'npm cache clean' failed - retrying..."; done
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
rm -rf tmp/buble \
|
rm -rf tmp/buble \
|
||||||
&& git clone https://github.com/bublejs/buble.git tmp/buble \
|
&& git clone https://github.com/bublejs/buble.git tmp/buble \
|
||||||
&& cd tmp/buble \
|
&& cd tmp/buble \
|
||||||
@@ -38,7 +45,7 @@ EOF
|
|||||||
ERR=$?; if [ "$ERR" != "0" ]; then echo "Error: $ERR"; exit $ERR; fi
|
ERR=$?; if [ "$ERR" != "0" ]; then echo "Error: $ERR"; exit $ERR; fi
|
||||||
minify_in_situ "src" \
|
minify_in_situ "src" \
|
||||||
&& rm -rf node_modules \
|
&& rm -rf node_modules \
|
||||||
&& npm ci \
|
&& npm_install \
|
||||||
&& rm -rf dist \
|
&& rm -rf dist \
|
||||||
&& npm run build \
|
&& npm run build \
|
||||||
&& minify_in_situ "dist" \
|
&& minify_in_situ "dist" \
|
||||||
|
|||||||
@@ -14,6 +14,13 @@ minify_in_situ() {
|
|||||||
uglify-js $ARGS
|
uglify-js $ARGS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
npm_install() {
|
||||||
|
PKG="$1"
|
||||||
|
while !(npm install $PKG); do
|
||||||
|
while !(npm cache clean --force); do echo "'npm cache clean' failed - retrying..."; done
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
rm -rf tmp/butternut \
|
rm -rf tmp/butternut \
|
||||||
&& git clone https://github.com/Rich-Harris/butternut.git tmp/butternut \
|
&& git clone https://github.com/Rich-Harris/butternut.git tmp/butternut \
|
||||||
&& cd tmp/butternut \
|
&& cd tmp/butternut \
|
||||||
@@ -38,7 +45,7 @@ EOF
|
|||||||
ERR=$?; if [ "$ERR" != "0" ]; then echo "Error: $ERR"; exit $ERR; fi
|
ERR=$?; if [ "$ERR" != "0" ]; then echo "Error: $ERR"; exit $ERR; fi
|
||||||
minify_in_situ "src" \
|
minify_in_situ "src" \
|
||||||
&& rm -rf node_modules \
|
&& rm -rf node_modules \
|
||||||
&& npm install \
|
&& npm_install \
|
||||||
&& rm -rf dist \
|
&& rm -rf dist \
|
||||||
&& npm run build \
|
&& npm run build \
|
||||||
&& minify_in_situ "dist" \
|
&& minify_in_situ "dist" \
|
||||||
|
|||||||
@@ -36,7 +36,9 @@ EOF
|
|||||||
}
|
}
|
||||||
if [ $NATIVE ]; then unset -f timeout; fi
|
if [ $NATIVE ]; then unset -f timeout; fi
|
||||||
|
|
||||||
git clone --branch v1.6.0 --depth 1 https://github.com/jasongin/nvs.git ~/.nvs
|
while !(git clone --branch v1.6.0 --depth 1 https://github.com/jasongin/nvs.git ~/.nvs); do
|
||||||
|
rm -rf ~/.nvs
|
||||||
|
done
|
||||||
while ! timeout 60 bash -c ". ~/.nvs/nvs.sh add $NODE && nvs use $NODE"; do
|
while ! timeout 60 bash -c ". ~/.nvs/nvs.sh add $NODE && nvs use $NODE"; do
|
||||||
cd ~/.nvs
|
cd ~/.nvs
|
||||||
while !(git clean -xdf); do echo "'git clean' failed - retrying..."; done
|
while !(git clean -xdf); do echo "'git clean' failed - retrying..."; done
|
||||||
@@ -51,4 +53,6 @@ npm config set save false
|
|||||||
npm config set strict-ssl false
|
npm config set strict-ssl false
|
||||||
npm config set update-notifier false
|
npm config set update-notifier false
|
||||||
npm --version
|
npm --version
|
||||||
while !(npm install); do echo "'npm install' failed - retrying..."; done
|
while !(npm install); do
|
||||||
|
while !(npm cache clean --force); do echo "'npm cache clean' failed - retrying..."; done
|
||||||
|
done
|
||||||
|
|||||||
@@ -18,6 +18,13 @@ minify_in_situ() {
|
|||||||
uglify-js $ARGS
|
uglify-js $ARGS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
npm_install() {
|
||||||
|
PKG="$1"
|
||||||
|
while !(npm install $PKG); do
|
||||||
|
while !(npm cache clean --force); do echo "'npm cache clean' failed - retrying..."; done
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
rm -rf tmp/mathjs \
|
rm -rf tmp/mathjs \
|
||||||
&& git clone --depth 1 --branch v9.2.0 https://github.com/josdejong/mathjs.git tmp/mathjs \
|
&& git clone --depth 1 --branch v9.2.0 https://github.com/josdejong/mathjs.git tmp/mathjs \
|
||||||
&& cd tmp/mathjs \
|
&& cd tmp/mathjs \
|
||||||
@@ -191,7 +198,7 @@ minify_in_situ "bin" \
|
|||||||
&& minify_in_situ "test" \
|
&& minify_in_situ "test" \
|
||||||
&& minify_in_situ "tools" \
|
&& minify_in_situ "tools" \
|
||||||
&& rm -rf node_modules \
|
&& rm -rf node_modules \
|
||||||
&& npm ci \
|
&& npm_install \
|
||||||
&& rm -rf lib \
|
&& rm -rf lib \
|
||||||
&& npm run build \
|
&& npm run build \
|
||||||
&& minify_in_situ "lib" \
|
&& minify_in_situ "lib" \
|
||||||
|
|||||||
@@ -14,6 +14,13 @@ minify_in_situ() {
|
|||||||
uglify-js $ARGS
|
uglify-js $ARGS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
npm_install() {
|
||||||
|
PKG="$1"
|
||||||
|
while !(npm install $PKG); do
|
||||||
|
while !(npm cache clean --force); do echo "'npm cache clean' failed - retrying..."; done
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
rm -rf tmp/rollup \
|
rm -rf tmp/rollup \
|
||||||
&& git clone https://github.com/rollup/rollup.git tmp/rollup \
|
&& git clone https://github.com/rollup/rollup.git tmp/rollup \
|
||||||
&& cd tmp/rollup \
|
&& cd tmp/rollup \
|
||||||
@@ -77,7 +84,7 @@ minify_in_situ "bin" \
|
|||||||
&& minify_in_situ "browser" \
|
&& minify_in_situ "browser" \
|
||||||
&& minify_in_situ "src" \
|
&& minify_in_situ "src" \
|
||||||
&& rm -rf node_modules \
|
&& rm -rf node_modules \
|
||||||
&& npm ci \
|
&& npm_install \
|
||||||
&& rm -rf dist \
|
&& rm -rf dist \
|
||||||
&& npm run build \
|
&& npm run build \
|
||||||
&& minify_in_situ "dist" \
|
&& minify_in_situ "dist" \
|
||||||
|
|||||||
@@ -24,6 +24,13 @@ EOF
|
|||||||
uglify-js $ARGS
|
uglify-js $ARGS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
npm_install() {
|
||||||
|
PKG="$1"
|
||||||
|
while !(npm install $PKG); do
|
||||||
|
while !(npm cache clean --force); do echo "'npm cache clean' failed - retrying..."; done
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
rm -rf tmp/rollup \
|
rm -rf tmp/rollup \
|
||||||
&& git clone --depth 1 --branch v2.39.1 https://github.com/rollup/rollup.git tmp/rollup \
|
&& git clone --depth 1 --branch v2.39.1 https://github.com/rollup/rollup.git tmp/rollup \
|
||||||
&& cd tmp/rollup \
|
&& cd tmp/rollup \
|
||||||
@@ -36,6 +43,9 @@ rm -rf tmp/rollup \
|
|||||||
- "postpublish": "pinst --enable",
|
- "postpublish": "pinst --enable",
|
||||||
- "prepare": "npm run build",
|
- "prepare": "npm run build",
|
||||||
- "prepublishOnly": "pinst --disable && npm ci && npm run lint:nofix && npm run security && npm run build:bootstrap && npm run test:all",
|
- "prepublishOnly": "pinst --disable && npm ci && npm run lint:nofix && npm run security && npm run build:bootstrap && npm run test:all",
|
||||||
|
@@ -93 +89 @@
|
||||||
|
- "is-reference": "lukastaegert/is-reference#update-class-features",
|
||||||
|
+ "is-reference": "3.0.0",
|
||||||
--- a/test/cli/index.js
|
--- a/test/cli/index.js
|
||||||
+++ b/test/cli/index.js
|
+++ b/test/cli/index.js
|
||||||
@@ -13,0 +14,3 @@ sander.rimrafSync(__dirname, 'node_modules');
|
@@ -13,0 +14,3 @@ sander.rimrafSync(__dirname, 'node_modules');
|
||||||
@@ -44,11 +54,11 @@ rm -rf tmp/rollup \
|
|||||||
+sander.rimrafSync(__dirname, 'samples', 'watch', 'watch-config-initial-error');
|
+sander.rimrafSync(__dirname, 'samples', 'watch', 'watch-config-initial-error');
|
||||||
EOF
|
EOF
|
||||||
ERR=$?; if [ "$ERR" != "0" ]; then echo "Error: $ERR"; exit $ERR; fi
|
ERR=$?; if [ "$ERR" != "0" ]; then echo "Error: $ERR"; exit $ERR; fi
|
||||||
npm install esbuild-wasm@0.8.56 \
|
npm_install esbuild-wasm@0.8.56 \
|
||||||
&& minify_in_situ "cli" \
|
&& minify_in_situ "cli" \
|
||||||
&& minify_in_situ "src" \
|
&& minify_in_situ "src" \
|
||||||
&& rm -rf node_modules \
|
&& rm -rf node_modules \
|
||||||
&& npm ci \
|
&& npm_install \
|
||||||
&& rm -rf dist \
|
&& rm -rf dist \
|
||||||
&& npm run build \
|
&& npm run build \
|
||||||
&& minify_in_situ "dist" \
|
&& minify_in_situ "dist" \
|
||||||
|
|||||||
@@ -28,6 +28,13 @@ EOF
|
|||||||
uglify-js $ARGS
|
uglify-js $ARGS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
npm_install() {
|
||||||
|
PKG="$1"
|
||||||
|
while !(npm install $PKG); do
|
||||||
|
while !(npm cache clean --force); do echo "'npm cache clean' failed - retrying..."; done
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
rm -rf tmp/sucrase \
|
rm -rf tmp/sucrase \
|
||||||
&& git clone https://github.com/alangpierce/sucrase.git tmp/sucrase \
|
&& git clone https://github.com/alangpierce/sucrase.git tmp/sucrase \
|
||||||
&& cd tmp/sucrase \
|
&& cd tmp/sucrase \
|
||||||
@@ -83,10 +90,10 @@ rm -rf tmp/sucrase \
|
|||||||
+export { getJSXPragmaInfo as HACK };
|
+export { getJSXPragmaInfo as HACK };
|
||||||
EOF
|
EOF
|
||||||
ERR=$?; if [ "$ERR" != "0" ]; then echo "Error: $ERR"; exit $ERR; fi
|
ERR=$?; if [ "$ERR" != "0" ]; then echo "Error: $ERR"; exit $ERR; fi
|
||||||
npm install esbuild-wasm@0.8.56 \
|
npm_install esbuild-wasm@0.8.56 \
|
||||||
&& minify_in_situ "src" \
|
&& minify_in_situ "src" \
|
||||||
&& rm -rf node_modules \
|
&& rm -rf node_modules \
|
||||||
&& npm install \
|
&& npm_install \
|
||||||
&& npm run clean \
|
&& npm run clean \
|
||||||
&& npm run build \
|
&& npm run build \
|
||||||
&& minify_in_situ "dist" \
|
&& minify_in_situ "dist" \
|
||||||
|
|||||||
@@ -14,6 +14,13 @@ minify_in_situ() {
|
|||||||
uglify-js $ARGS
|
uglify-js $ARGS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
npm_install() {
|
||||||
|
PKG="$1"
|
||||||
|
while !(npm install $PKG); do
|
||||||
|
while !(npm cache clean --force); do echo "'npm cache clean' failed - retrying..."; done
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
rm -rf tmp/web-tooling-benchmark \
|
rm -rf tmp/web-tooling-benchmark \
|
||||||
&& git clone --depth 1 --branch v0.5.3 https://github.com/v8/web-tooling-benchmark.git tmp/web-tooling-benchmark \
|
&& git clone --depth 1 --branch v0.5.3 https://github.com/v8/web-tooling-benchmark.git tmp/web-tooling-benchmark \
|
||||||
&& cd tmp/web-tooling-benchmark \
|
&& cd tmp/web-tooling-benchmark \
|
||||||
@@ -47,7 +54,7 @@ ERR=$?; if [ "$ERR" != "0" ]; then echo "Error: $ERR"; exit $ERR; fi
|
|||||||
minify_in_situ "src" \
|
minify_in_situ "src" \
|
||||||
&& minify_in_situ "third_party" \
|
&& minify_in_situ "third_party" \
|
||||||
&& rm -rf node_modules \
|
&& rm -rf node_modules \
|
||||||
&& npm ci \
|
&& npm_install \
|
||||||
&& rm -rf build/* \
|
&& rm -rf build/* \
|
||||||
&& npm run build:terser-bundled \
|
&& npm run build:terser-bundled \
|
||||||
&& npm run build:uglify-js-bundled \
|
&& npm run build:uglify-js-bundled \
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
var get = require("https").get;
|
var get = require("https").get;
|
||||||
var parse = require("url").parse;
|
var parse = require("url").parse;
|
||||||
|
|
||||||
var base, token, run_number, eldest = true;
|
var base, token, run_number;
|
||||||
exports.init = function(url, auth, num) {
|
exports.init = function(url, auth, num) {
|
||||||
base = url;
|
base = url;
|
||||||
token = auth;
|
token = auth;
|
||||||
@@ -19,14 +19,14 @@ exports.should_stop = function(callback) {
|
|||||||
do {
|
do {
|
||||||
workflow = runs.pop();
|
workflow = runs.pop();
|
||||||
if (!workflow) return;
|
if (!workflow) return;
|
||||||
if (workflow.event == "schedule" && workflow.run_number == run_number) found = true;
|
if (is_cron(workflow) && workflow.run_number == run_number) found = true;
|
||||||
} while (!found && workflow.status == "completed");
|
} while (!found && workflow.status == "completed");
|
||||||
read(workflow.jobs_url, function(reply) {
|
read(workflow.jobs_url, function(reply) {
|
||||||
if (!reply || !Array.isArray(reply.jobs)) return;
|
if (!reply || !Array.isArray(reply.jobs)) return;
|
||||||
if (!reply.jobs.every(function(job) {
|
if (!reply.jobs.every(function(job) {
|
||||||
if (job.status == "completed") return true;
|
if (job.status == "completed") return true;
|
||||||
remaining--;
|
remaining--;
|
||||||
return found || workflow.event != "schedule";
|
return found || !is_cron(workflow);
|
||||||
})) return;
|
})) return;
|
||||||
if (remaining >= 0) {
|
if (remaining >= 0) {
|
||||||
next();
|
next();
|
||||||
@@ -38,6 +38,10 @@ exports.should_stop = function(callback) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function is_cron(workflow) {
|
||||||
|
return /^(schedule|workflow_dispatch|workflow_run)$/.test(workflow.event);
|
||||||
|
}
|
||||||
|
|
||||||
function read(url, callback) {
|
function read(url, callback) {
|
||||||
var done = function(reply) {
|
var done = function(reply) {
|
||||||
done = function() {};
|
done = function() {};
|
||||||
@@ -56,7 +60,7 @@ function read(url, callback) {
|
|||||||
}).on("end", function() {
|
}).on("end", function() {
|
||||||
var reply;
|
var reply;
|
||||||
try {
|
try {
|
||||||
reply = JSON.parse(chunks.join(""))
|
reply = JSON.parse(chunks.join(""));
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
done(reply);
|
done(reply);
|
||||||
}).on("error", function() {
|
}).on("error", function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user