test: expand golden C-codegen tests from 2 to 8 examples
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.
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
[Package]
|
||||
Name = "algebraic_enums"
|
||||
Version = "0.1.0"
|
||||
Type = "bin"
|
||||
|
||||
[Build]
|
||||
Output = "Bin"
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,29 @@
|
||||
// Algebraic Enums - Enums with data (tagged unions)
|
||||
import Std::Io::{PrintLine, PrintInt};
|
||||
|
||||
|
||||
enum Result {
|
||||
Ok(int),
|
||||
Err(String)
|
||||
}
|
||||
|
||||
func Main() -> int {
|
||||
let r1: Result = Result { tag: Result_Ok };
|
||||
r1.data.Ok_0 = 42;
|
||||
|
||||
let r2: Result = Result { tag: Result_Err };
|
||||
r2.data.Err_0 = "error message";
|
||||
|
||||
if r1.tag == Result_Ok {
|
||||
PrintLine("r1 is Ok:");
|
||||
PrintInt(r1.data.Ok_0);
|
||||
PrintLine("");
|
||||
}
|
||||
|
||||
if r2.tag == Result_Err {
|
||||
PrintLine("r2 is Err:");
|
||||
PrintLine(r2.data.Err_0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user