1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
var C1 = 1; function f(x) { var s = ""; switch(x) { case 0: s += "0"; case C1: s += "1"; } return s; } assertEq(f(0), "01"); assertEq(f(1), "1"); assertEq(f(2), ""); assertEq(f(true), ""); assertEq(f(Math), "");