265bda850d
Add golden tests for: structs, generics, algebraic_enums, enums, methods, strings. Each test captures the expected C output from the bootstrap compiler for regression detection. Also remove leftover 'PARSER FIX V2 ACTIVE' debug print from parser.bux.
35 lines
574 B
Plaintext
35 lines
574 B
Plaintext
// Enums - Enumeration types
|
|
import Std::Io::{PrintLine, PrintInt};
|
|
|
|
|
|
enum Color {
|
|
Red,
|
|
Green,
|
|
Blue
|
|
}
|
|
|
|
func ColorName(c: Color) -> String {
|
|
if c == Color::Red {
|
|
return "Red";
|
|
}
|
|
if c == Color::Green {
|
|
return "Green";
|
|
}
|
|
if c == Color::Blue {
|
|
return "Blue";
|
|
}
|
|
return "Unknown";
|
|
}
|
|
|
|
func Main() -> int {
|
|
let myColor: Color = Color::Green;
|
|
|
|
PrintLine("My color is:");
|
|
PrintLine(ColorName(myColor));
|
|
PrintLine("Color value:");
|
|
PrintInt(myColor as int);
|
|
PrintLine("");
|
|
|
|
return 0;
|
|
}
|