- rename `screw_ie8` to `ie8` - rename `mangle.except` to `mangle.reserved` - rename `mangle.properties.ignore_quoted` to `mangle.properties.keep_quoted` - compact `sourceMap` options - more stringent verification on input `options` - toplevel shorthands - `ie8` - `keep_fnames` - `toplevel` - `warnings` - support arrays and unquoted string values on CLI - drop `fromString` from `minify()` - `minify()` no longer handles any `fs` operations - unify order of operations for `mangle_properties()` on CLI & API - `bin/uglifyjs` used to `mangle_properties()` before even `Compressor` - `minify()` used to `mangle_properties()` after `Compressor` but before `mangle_names()` - both will now do `Compressor`, `mangle_names()` then `mangle_properties()` - `options.parse` / `--parse` for parser options beyond `bare_returns` - add `mangle.properties.builtins` to disable built-in reserved list - disable with `--mangle-props builtins` on CLI - `warnings` now off by default - add `--warn` and `--verbose` on CLI - drop `--enclose` - drop `--export-all` - drop `--reserved-file` - use `--mangle reserved` instead - drop `--reserve-domprops` - enabled by default, disable with `--mangle-props domprops` - drop `--prefix` - use `--source-map base` instead - drop `--lint` - remove `bin/extract-props.js` - limit exposure of internal APIs - update documentations closes #96 closes #102 closes #136 closes #166 closes #243 closes #254 closes #261 closes #311 closes #700 closes #748 closes #912 closes #1072 closes #1366 fixes #101 fixes #123 fixes #124 fixes #263 fixes #379 fixes #419 fixes #423 fixes #461 fixes #465 fixes #576 fixes #737 fixes #772 fixes #958 fixes #1036 fixes #1142 fixes #1175 fixes #1220 fixes #1223 fixes #1280 fixes #1359 fixes #1368
483 lines
8.5 KiB
JavaScript
483 lines
8.5 KiB
JavaScript
while_becomes_for: {
|
|
options = { loops: true };
|
|
input: {
|
|
while (foo()) bar();
|
|
}
|
|
expect: {
|
|
for (; foo(); ) bar();
|
|
}
|
|
}
|
|
|
|
drop_if_break_1: {
|
|
options = { loops: true };
|
|
input: {
|
|
for (;;)
|
|
if (foo()) break;
|
|
}
|
|
expect: {
|
|
for (; !foo(););
|
|
}
|
|
}
|
|
|
|
drop_if_break_2: {
|
|
options = { loops: true };
|
|
input: {
|
|
for (;bar();)
|
|
if (foo()) break;
|
|
}
|
|
expect: {
|
|
for (; bar() && !foo(););
|
|
}
|
|
}
|
|
|
|
drop_if_break_3: {
|
|
options = { loops: true };
|
|
input: {
|
|
for (;bar();) {
|
|
if (foo()) break;
|
|
stuff1();
|
|
stuff2();
|
|
}
|
|
}
|
|
expect: {
|
|
for (; bar() && !foo();) {
|
|
stuff1();
|
|
stuff2();
|
|
}
|
|
}
|
|
}
|
|
|
|
drop_if_break_4: {
|
|
options = { loops: true, sequences: true };
|
|
input: {
|
|
for (;bar();) {
|
|
x();
|
|
y();
|
|
if (foo()) break;
|
|
z();
|
|
k();
|
|
}
|
|
}
|
|
expect: {
|
|
for (; bar() && (x(), y(), !foo());) z(), k();
|
|
}
|
|
}
|
|
|
|
drop_if_else_break_1: {
|
|
options = { loops: true };
|
|
input: {
|
|
for (;;) if (foo()) bar(); else break;
|
|
}
|
|
expect: {
|
|
for (; foo(); ) bar();
|
|
}
|
|
}
|
|
|
|
drop_if_else_break_2: {
|
|
options = { loops: true };
|
|
input: {
|
|
for (;bar();) {
|
|
if (foo()) baz();
|
|
else break;
|
|
}
|
|
}
|
|
expect: {
|
|
for (; bar() && foo();) baz();
|
|
}
|
|
}
|
|
|
|
drop_if_else_break_3: {
|
|
options = { loops: true };
|
|
input: {
|
|
for (;bar();) {
|
|
if (foo()) baz();
|
|
else break;
|
|
stuff1();
|
|
stuff2();
|
|
}
|
|
}
|
|
expect: {
|
|
for (; bar() && foo();) {
|
|
baz();
|
|
stuff1();
|
|
stuff2();
|
|
}
|
|
}
|
|
}
|
|
|
|
drop_if_else_break_4: {
|
|
options = { loops: true, sequences: true };
|
|
input: {
|
|
for (;bar();) {
|
|
x();
|
|
y();
|
|
if (foo()) baz();
|
|
else break;
|
|
z();
|
|
k();
|
|
}
|
|
}
|
|
expect: {
|
|
for (; bar() && (x(), y(), foo());) baz(), z(), k();
|
|
}
|
|
}
|
|
|
|
parse_do_while_with_semicolon: {
|
|
options = { loops: false };
|
|
input: {
|
|
do {
|
|
x();
|
|
} while (false);y()
|
|
}
|
|
expect: {
|
|
do x(); while (false);y();
|
|
}
|
|
}
|
|
|
|
parse_do_while_without_semicolon: {
|
|
options = { loops: false };
|
|
input: {
|
|
do {
|
|
x();
|
|
} while (false)y()
|
|
}
|
|
expect: {
|
|
do x(); while (false);y();
|
|
}
|
|
}
|
|
|
|
|
|
keep_collapse_const_in_own_block_scope: {
|
|
options = {
|
|
join_vars: true,
|
|
loops: true
|
|
}
|
|
input: {
|
|
var i=2;
|
|
const c=5;
|
|
while(i--)
|
|
console.log(i);
|
|
console.log(c);
|
|
}
|
|
expect: {
|
|
var i=2;
|
|
const c=5;
|
|
for(;i--;)
|
|
console.log(i);
|
|
console.log(c);
|
|
}
|
|
expect_stdout: true
|
|
}
|
|
|
|
keep_collapse_const_in_own_block_scope_2: {
|
|
options = {
|
|
join_vars: true,
|
|
loops: true
|
|
}
|
|
input: {
|
|
const c=5;
|
|
var i=2; // Moves to loop, while it did not in previous test
|
|
while(i--)
|
|
console.log(i);
|
|
console.log(c);
|
|
}
|
|
expect: {
|
|
const c=5;
|
|
for(var i=2;i--;)
|
|
console.log(i);
|
|
console.log(c);
|
|
}
|
|
expect_stdout: true
|
|
}
|
|
|
|
evaluate: {
|
|
options = {
|
|
loops: true,
|
|
dead_code: true,
|
|
evaluate: true,
|
|
};
|
|
input: {
|
|
while (true) {
|
|
a();
|
|
}
|
|
while (false) {
|
|
b();
|
|
}
|
|
do {
|
|
c();
|
|
} while (true);
|
|
do {
|
|
d();
|
|
} while (false);
|
|
}
|
|
expect: {
|
|
for(;;)
|
|
a();
|
|
for(;;)
|
|
c();
|
|
d();
|
|
}
|
|
}
|
|
|
|
issue_1532: {
|
|
options = {
|
|
evaluate: true,
|
|
loops: true,
|
|
}
|
|
input: {
|
|
function f(x, y) {
|
|
do {
|
|
if (x) break;
|
|
foo();
|
|
} while (false);
|
|
}
|
|
}
|
|
expect: {
|
|
function f(x, y) {
|
|
do {
|
|
if (x) break;
|
|
foo();
|
|
} while (false);
|
|
}
|
|
}
|
|
}
|
|
|
|
issue_186: {
|
|
beautify = {
|
|
beautify: false,
|
|
ie8: false,
|
|
}
|
|
input: {
|
|
var x = 3;
|
|
if (foo())
|
|
do
|
|
do
|
|
alert(x);
|
|
while (--x);
|
|
while (x);
|
|
else
|
|
bar();
|
|
}
|
|
expect_exact: 'var x=3;if(foo())do{do{alert(x)}while(--x)}while(x);else bar();'
|
|
}
|
|
|
|
issue_186_ie8: {
|
|
beautify = {
|
|
beautify: false,
|
|
ie8: true,
|
|
}
|
|
input: {
|
|
var x = 3;
|
|
if (foo())
|
|
do
|
|
do
|
|
alert(x);
|
|
while (--x);
|
|
while (x);
|
|
else
|
|
bar();
|
|
}
|
|
expect_exact: 'var x=3;if(foo()){do{do{alert(x)}while(--x)}while(x)}else bar();'
|
|
}
|
|
|
|
issue_186_beautify: {
|
|
beautify = {
|
|
beautify: true,
|
|
ie8: false,
|
|
}
|
|
input: {
|
|
var x = 3;
|
|
if (foo())
|
|
do
|
|
do
|
|
alert(x);
|
|
while (--x);
|
|
while (x);
|
|
else
|
|
bar();
|
|
}
|
|
expect_exact: [
|
|
'var x = 3;',
|
|
'',
|
|
'if (foo()) do {',
|
|
' do {',
|
|
' alert(x);',
|
|
' } while (--x);',
|
|
'} while (x); else bar();',
|
|
]
|
|
}
|
|
|
|
issue_186_beautify_ie8: {
|
|
beautify = {
|
|
beautify: true,
|
|
ie8: true,
|
|
}
|
|
input: {
|
|
var x = 3;
|
|
if (foo())
|
|
do
|
|
do
|
|
alert(x);
|
|
while (--x);
|
|
while (x);
|
|
else
|
|
bar();
|
|
}
|
|
expect_exact: [
|
|
'var x = 3;',
|
|
'',
|
|
'if (foo()) {',
|
|
' do {',
|
|
' do {',
|
|
' alert(x);',
|
|
' } while (--x);',
|
|
' } while (x);',
|
|
'} else bar();',
|
|
]
|
|
}
|
|
|
|
issue_186_bracketize: {
|
|
beautify = {
|
|
beautify: false,
|
|
bracketize: true,
|
|
ie8: false,
|
|
}
|
|
input: {
|
|
var x = 3;
|
|
if (foo())
|
|
do
|
|
do
|
|
alert(x);
|
|
while (--x);
|
|
while (x);
|
|
else
|
|
bar();
|
|
}
|
|
expect_exact: 'var x=3;if(foo()){do{do{alert(x)}while(--x)}while(x)}else{bar()}'
|
|
}
|
|
|
|
issue_186_bracketize_ie8: {
|
|
beautify = {
|
|
beautify: false,
|
|
bracketize: true,
|
|
ie8: true,
|
|
}
|
|
input: {
|
|
var x = 3;
|
|
if (foo())
|
|
do
|
|
do
|
|
alert(x);
|
|
while (--x);
|
|
while (x);
|
|
else
|
|
bar();
|
|
}
|
|
expect_exact: 'var x=3;if(foo()){do{do{alert(x)}while(--x)}while(x)}else{bar()}'
|
|
}
|
|
|
|
issue_186_beautify_bracketize: {
|
|
beautify = {
|
|
beautify: true,
|
|
bracketize: true,
|
|
ie8: false,
|
|
}
|
|
input: {
|
|
var x = 3;
|
|
if (foo())
|
|
do
|
|
do
|
|
alert(x);
|
|
while (--x);
|
|
while (x);
|
|
else
|
|
bar();
|
|
}
|
|
expect_exact: [
|
|
'var x = 3;',
|
|
'',
|
|
'if (foo()) {',
|
|
' do {',
|
|
' do {',
|
|
' alert(x);',
|
|
' } while (--x);',
|
|
' } while (x);',
|
|
'} else {',
|
|
' bar();',
|
|
'}',
|
|
]
|
|
}
|
|
|
|
issue_186_beautify_bracketize_ie8: {
|
|
beautify = {
|
|
beautify: true,
|
|
bracketize: true,
|
|
ie8: true,
|
|
}
|
|
input: {
|
|
var x = 3;
|
|
if (foo())
|
|
do
|
|
do
|
|
alert(x);
|
|
while (--x);
|
|
while (x);
|
|
else
|
|
bar();
|
|
}
|
|
expect_exact: [
|
|
'var x = 3;',
|
|
'',
|
|
'if (foo()) {',
|
|
' do {',
|
|
' do {',
|
|
' alert(x);',
|
|
' } while (--x);',
|
|
' } while (x);',
|
|
'} else {',
|
|
' bar();',
|
|
'}',
|
|
]
|
|
}
|
|
|
|
issue_1648: {
|
|
options = {
|
|
join_vars: true,
|
|
loops: true,
|
|
passes: 2,
|
|
sequences: true,
|
|
unused: true,
|
|
}
|
|
input: {
|
|
function f() {
|
|
x();
|
|
var b = 1;
|
|
while (1);
|
|
}
|
|
}
|
|
expect_exact: "function f(){for(x();1;);}"
|
|
}
|
|
|
|
do_switch: {
|
|
options = {
|
|
evaluate: true,
|
|
loops: true,
|
|
}
|
|
input: {
|
|
do {
|
|
switch (a) {
|
|
case b:
|
|
continue;
|
|
}
|
|
} while (false);
|
|
}
|
|
expect: {
|
|
do {
|
|
switch (a) {
|
|
case b:
|
|
continue;
|
|
}
|
|
} while (false);
|
|
}
|
|
}
|