75 lines
1.3 KiB
JavaScript
75 lines
1.3 KiB
JavaScript
ifs_1: {
|
|
options = {
|
|
conditionals: true
|
|
};
|
|
input: {
|
|
if (foo) bar();
|
|
if (!foo); else bar();
|
|
if (foo); else bar();
|
|
if (foo); else;
|
|
}
|
|
expect: {
|
|
foo&&bar();
|
|
foo&&bar();
|
|
foo||bar();
|
|
foo;
|
|
}
|
|
}
|
|
|
|
ifs_2: {
|
|
options = {
|
|
conditionals: true
|
|
};
|
|
input: {
|
|
if (foo) {
|
|
x();
|
|
} else if (bar) {
|
|
y();
|
|
} else if (baz) {
|
|
z();
|
|
}
|
|
|
|
if (foo) {
|
|
x();
|
|
} else if (bar) {
|
|
y();
|
|
} else if (baz) {
|
|
z();
|
|
} else {
|
|
t();
|
|
}
|
|
}
|
|
expect: {
|
|
foo ? x() : bar ? y() : baz && z();
|
|
foo ? x() : bar ? y() : baz ? z() : t();
|
|
}
|
|
}
|
|
|
|
ifs_3_should_warn: {
|
|
options = {
|
|
conditionals : true,
|
|
dead_code : true,
|
|
evaluate : true,
|
|
booleans : true
|
|
};
|
|
input: {
|
|
if (x && !(x + "1") && y) { // 1
|
|
var qq;
|
|
foo();
|
|
} else {
|
|
bar();
|
|
}
|
|
|
|
if (x || !!(x + "1") || y) { // 2
|
|
foo();
|
|
} else {
|
|
var jj;
|
|
bar();
|
|
}
|
|
}
|
|
expect: {
|
|
var qq; bar(); // 1
|
|
var jj; foo(); // 2
|
|
}
|
|
}
|