michael@0: var typedSwitch0 = function (a) { michael@0: switch (a) { michael@0: case null: michael@0: return 0; michael@0: case 1.1: michael@0: return 1; michael@0: case "2": michael@0: return 2; michael@0: case 3: michael@0: return 3; michael@0: } michael@0: return 4; michael@0: }; michael@0: michael@0: // reuse the same function for testing with different inputs & type. michael@0: var typedSwitch1 = eval(typedSwitch0.toSource()); michael@0: var typedSwitch2 = eval(typedSwitch0.toSource()); michael@0: var typedSwitch3 = eval(typedSwitch0.toSource()); michael@0: var typedSwitch4 = eval(typedSwitch0.toSource()); michael@0: michael@0: for (var i = 0; i < 100; i++) { michael@0: assertEq(typedSwitch0(null), 0); michael@0: assertEq(typedSwitch1(1.1), 1); michael@0: assertEq(typedSwitch2("2"), 2); michael@0: assertEq(typedSwitch3(3), 3); michael@0: assertEq(typedSwitch4(undefined), 4); michael@0: }