1#unittest { 2 name: "Switch flow control."; 3 error: NONE; 4 result: "^1244??STR2"; 5} 6 7func test(x) { 8 var value = "^"; 9 switch (x) { 10 case 0: 11 break; 12 case 1: 13 return "1"; 14 case 2: 15 value = "2"; 16 break; 17 case 3: 18 value = "3"; 19 case 4: 20 value = "4"; 21 break; 22 case "str2": 23 value = "STR2" 24 break; 25 default: 26 return "?"; 27 } 28 return value; 29} 30 31func main() { 32 var result = ""; 33 for (var i in 0...5) { 34 result += test(i); 35 } 36 result += test("str1"); 37 result += test("str2"); 38 return result; 39} 40 41