UglifyJS/test/compress/transform-optimize.js
alexlamsl 7550c53fd6 fix usage of transform() vs optimize()
Given the current `OPT()` node:
- `optimize(compressor)` works on the same level, and will only `descend()` if returned instance is different
- `transform(compressor)` works on child nodes, and will always `descend()`

Other fixes
- `loopcontrol_target()` should compare against `compressor.self()` since the current node may have already been displaced
- remove obsolete optimisation in `AST_Binary` after #1477

fixes #1592
2017-03-11 05:08:30 +08:00

69 lines
1.2 KiB
JavaScript

booleans_evaluate: {
options = {
booleans: true,
evaluate: true,
}
input: {
console.log(typeof void 0 != "undefined");
console.log(1 == 1, 1 === 1)
console.log(1 != 1, 1 !== 1)
}
expect: {
console.log(!1);
console.log(!0, !0);
console.log(!1, !1);
}
}
booleans_global_defs: {
options = {
booleans: true,
evaluate: true,
global_defs: {
A: true,
},
}
input: {
console.log(A == 1);
}
expect: {
console.log(!0);
}
}
condition_evaluate: {
options = {
booleans: true,
dead_code: false,
evaluate: true,
loops: false,
}
input: {
while (1 === 2);
for (; 1 == true;);
if (void 0 == null);
}
expect: {
while (!1);
for (; !0;);
if (!0);
}
}
while_if_break: {
options = {
conditionals: true,
loops: true,
sequences: true,
}
input: {
while (a) {
if (b) if(c) d;
if (e) break;
}
}
expect: {
for(; a && (b && c && d, !e););
}
}