blob: c92d4c27588e6d7c75880c995c4d07eb3aa57fc0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
// Tests for JSOP_TABLESWITCHX.
function test1() {
var src =
"var a = 0;\n" +
"switch(x) {\n";
for (var i=-1; i<4; i++) {
src += (i >= 0) ?
"case " + i + ":\n" :
"default:\n";
for (var j=0; j<1500; j++) {
src += "a = " + i + ";";
}
src += "break;\n";
}
src += "}\n";
src += "return a;";
var f = new Function("x", src);
assertEq(f(0), 0);
assertEq(f(4), -1);
assertEq(f(), -1);
assertEq(f(1.1), -1);
assertEq(f(3), 3);
}
test1();
|