michael@0: // Tests for JSOP_TABLESWITCHX. michael@0: function test1() { michael@0: var src = michael@0: "var a = 0;\n" + michael@0: "switch(x) {\n"; michael@0: for (var i=-1; i<4; i++) { michael@0: src += (i >= 0) ? michael@0: "case " + i + ":\n" : michael@0: "default:\n"; michael@0: for (var j=0; j<1500; j++) { michael@0: src += "a = " + i + ";"; michael@0: } michael@0: src += "break;\n"; michael@0: } michael@0: src += "}\n"; michael@0: src += "return a;"; michael@0: michael@0: var f = new Function("x", src); michael@0: assertEq(f(0), 0); michael@0: assertEq(f(4), -1); michael@0: assertEq(f(), -1); michael@0: assertEq(f(1.1), -1); michael@0: assertEq(f(3), 3); michael@0: } michael@0: test1();