1f8289059a
ci / build (ubuntu) (push) Has been cancelled
ci / unit + fmt (push) Has been cancelled
ci / examples (push) Has been cancelled
ci / goldens + tools (push) Has been cancelled
ci / apps (push) Has been cancelled
ci / selfhost smoke (push) Has been cancelled
ci / macos smoke (push) Has been cancelled
ci / windows smoke (push) Has been cancelled
ci / CI gate (push) Has been cancelled
selfhost-loop / bootstrap determinism (push) Has been cancelled
Replaced fixed-size locals (c0..c7) with O(n^2) linked-list walk that handles arbitrary case counts via reverse-index traversal. Added switch.bux test with 11 and 10 cases.
64 lines
1.2 KiB
Plaintext
64 lines
1.2 KiB
Plaintext
// switch.bux — Test switch with many cases (>8)
|
|
|
|
import Std::Io::{PrintLine, PrintInt};
|
|
|
|
func Main() -> int {
|
|
var x: int = 7;
|
|
|
|
switch x {
|
|
case 0:
|
|
PrintLine("zero");
|
|
case 1:
|
|
PrintLine("one");
|
|
case 2:
|
|
PrintLine("two");
|
|
case 3:
|
|
PrintLine("three");
|
|
case 4:
|
|
PrintLine("four");
|
|
case 5:
|
|
PrintLine("five");
|
|
case 6:
|
|
PrintLine("six");
|
|
case 7:
|
|
PrintLine("seven");
|
|
case 8:
|
|
PrintLine("eight");
|
|
case 9:
|
|
PrintLine("nine");
|
|
case 10:
|
|
PrintLine("ten");
|
|
default:
|
|
PrintLine("other");
|
|
}
|
|
|
|
// Test with match at end
|
|
x = 15;
|
|
switch x {
|
|
case 0:
|
|
PrintLine("a");
|
|
case 1:
|
|
PrintLine("b");
|
|
case 5:
|
|
PrintLine("c");
|
|
case 10:
|
|
PrintLine("d");
|
|
case 15:
|
|
PrintLine("fifteen-ok");
|
|
case 20:
|
|
PrintLine("e");
|
|
case 25:
|
|
PrintLine("f");
|
|
case 30:
|
|
PrintLine("g");
|
|
case 35:
|
|
PrintLine("h");
|
|
case 40:
|
|
PrintLine("i");
|
|
default:
|
|
PrintLine("default");
|
|
}
|
|
|
|
return 0;
|
|
}
|