60 lines
1.2 KiB
JavaScript
60 lines
1.2 KiB
JavaScript
dead_code_1: {
|
|
options = {
|
|
dead_code: true
|
|
};
|
|
input: {
|
|
function f() {
|
|
a();
|
|
b();
|
|
x = 10;
|
|
return;
|
|
if (x) {
|
|
y();
|
|
}
|
|
}
|
|
}
|
|
expect: {
|
|
function f() {
|
|
a();
|
|
b();
|
|
x = 10;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
dead_code_2_should_warn: {
|
|
options = {
|
|
dead_code: true
|
|
};
|
|
input: {
|
|
function f() {
|
|
g();
|
|
x = 10;
|
|
throw "foo";
|
|
// completely discarding the `if` would introduce some
|
|
// bugs. UglifyJS v1 doesn't deal with this issue; in v2
|
|
// we copy any declarations to the upper scope.
|
|
if (x) {
|
|
y();
|
|
var x;
|
|
function g(){};
|
|
// but nested declarations should not be kept.
|
|
(function(){
|
|
var q;
|
|
function y(){};
|
|
})();
|
|
}
|
|
}
|
|
}
|
|
expect: {
|
|
function f() {
|
|
g();
|
|
x = 10;
|
|
throw "foo";
|
|
var x;
|
|
function g(){};
|
|
}
|
|
}
|
|
}
|