Files
codeql/javascript/ql/test/query-tests/Statements/UnreachableStatement/tst.js
Asger F 10a7294327 JS: Accept trivial test changes
This adds Alert annotations for alerts that seem intentional by the test
but has not been annotated with 'NOT OK', or the comment was in the wrong
place.

In a few cases I included 'Source' expectations to make it easier to see
what happened. Other 'Source' expectations will be added in bulk a later
commit.
2025-02-28 13:27:43 +01:00

82 lines
905 B
JavaScript

;
function f() {
return 23;
var a = 42; // $ Alert
}
function g(x) {
switch(x) {
case 0:
return 23;
break;
default:
return 42;
}
}
function h(i) {
while(true) {
if (!f(i++)) {
break;;
}
}
}
function k() {
try {
h();
} catch(e) {
;
}
for (var p in {});
for (var i=0; i<10; ++i);
}
throw new Error();
f(); // $ Alert
function l(x) {
switch(x) {
default:
return 42;
case 0:
return 23;
}
}
function m(x) {
switch(x) {
case 0:
return 23;
default:
return 42;
case 1:
return 56;
}
}
if (true)
x;
else
y; // $ Alert
function f(){
if (x) {
return;; // trailing ';' is unreachable, but alert is squelched
}
if (x) {
return y;
} else {
return z;
}; // ';' is unreachable, but alert is squelched
}
// test for unreachable throws
function z() {
return 10;
throw new Error(); // this throws is unreachable, but alert should not be produced
}