always keep declarations found in unreachable code

a few more tests and some cleanups.
This commit is contained in:
Mihai Bazon
2012-09-07 15:18:32 +03:00
parent b77574ea1c
commit 919b2733ab
5 changed files with 226 additions and 49 deletions

View File

@@ -57,3 +57,33 @@ dead_code_2_should_warn: {
}
}
}
dead_code_constant_boolean_should_warn_more: {
options = {
dead_code : true,
loops : true,
booleans : true,
conditionals : true,
evaluate : true
};
input: {
while (!((foo && bar) || (x + "0"))) {
console.log("unreachable");
var foo;
function bar() {}
}
for (var x = 10; x && (y || x) && (!typeof x); ++x) {
asdf();
foo();
var moo;
}
}
expect: {
var foo;
function bar() {}
// nothing for the while
// as for the for, it should keep:
var x = 10;
var moo;
}
}