linkname ""; int main() { int i = 2; var int state = 0; // Integer switch switch i { case 1 { assert :false; } case 2 { state = 1; } case 3 { assert :false; } } assert state == 1; // Integer switch with default switch i { case 1 { assert :false; } case 2 { state = 2; } case 3 { assert :false; } default { assert :false; } } assert state == 2; // Integer switch with reached default switch i { case 1 { assert :false; } case 3 { assert :false; } default { state = 3; } } assert state == 3; // Integer switch with "with" statements var int bug = 0; switch i { case 0 with bug = 10 { assert :false; } case 1 with bug = 11 case 2 with state = 4 case 3 with bug = 12 { assert state == 4; state = 5; } case 4 with bug = 13 { assert :false; } default { assert :false; } } assert bug == 0; assert state == 5; //////////////////////////////////////////////////////////////////////// // Now we test the same with an array value instead of int byte#[2] arr = [1, 2]; state = 0; // Array switch switch arr { case [1,0] { assert :false; } case [1,2] { state = 1; } case [2,1] { assert :false; } } assert state == 1; // Integer switch with default switch arr { case [1,0] { assert :false; } case [1,2] { state = 2; } case [2,1] { assert :false; } default { assert :false; } } assert state == 2; // Array switch with reached default switch arr { case [1,0] { assert :false; } case [2,1] { assert :false; } default { state = 3; } } assert state == 3; // Array switch with "with" statements bug = 0; switch arr { case [0,0] with bug = 10 { assert :false; } case [1,0] with bug = 11 case [1,2] with state = 4 case [2,1] with bug = 12 { assert state == 4; state = 5; } case [4,4] with bug = 13 { assert :false; } default { assert :false; } } assert bug == 0; assert state == 5; return 0; }