Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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 };
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());
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 }