js/src/jit-test/tests/ion/bug825599.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:d661937959b3
1 var typedSwitch0 = function (a) {
2 switch (a) {
3 case null:
4 return 0;
5 case 1.1:
6 return 1;
7 case "2":
8 return 2;
9 case 3:
10 return 3;
11 }
12 return 4;
13 };
14
15 // reuse the same function for testing with different inputs & type.
16 var typedSwitch1 = eval(typedSwitch0.toSource());
17 var typedSwitch2 = eval(typedSwitch0.toSource());
18 var typedSwitch3 = eval(typedSwitch0.toSource());
19 var typedSwitch4 = eval(typedSwitch0.toSource());
20
21 for (var i = 0; i < 100; i++) {
22 assertEq(typedSwitch0(null), 0);
23 assertEq(typedSwitch1(1.1), 1);
24 assertEq(typedSwitch2("2"), 2);
25 assertEq(typedSwitch3(3), 3);
26 assertEq(typedSwitch4(undefined), 4);
27 }

mercurial