1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
function f() { switch(2) { case 1: return 1; case 2: return 2; default: return -1; } } assertEq(f(), 2); function g() { switch(3.14) { case 3: return 3; case 4: return 4; default: return -1; } } assertEq(g(), -1);