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,38 @@
|
||||
// Methods - Struct with methods using extend
|
||||
import Std::Io::{PrintLine, PrintInt};
|
||||
|
||||
|
||||
struct Rectangle {
|
||||
width: int;
|
||||
height: int;
|
||||
}
|
||||
|
||||
extend Rectangle {
|
||||
func Area(self: Rectangle) -> int {
|
||||
return self.width * self.height;
|
||||
}
|
||||
|
||||
func Perimeter(self: Rectangle) -> int {
|
||||
return 2 * (self.width + self.height);
|
||||
}
|
||||
}
|
||||
|
||||
func Main() -> int {
|
||||
let rect: Rectangle = Rectangle { width: 10, height: 5 };
|
||||
|
||||
PrintLine("Rectangle:");
|
||||
PrintLine("Width = ");
|
||||
PrintInt(rect.width);
|
||||
PrintLine("");
|
||||
PrintLine("Height = ");
|
||||
PrintInt(rect.height);
|
||||
PrintLine("");
|
||||
PrintLine("Area = ");
|
||||
PrintInt(rect.Area());
|
||||
PrintLine("");
|
||||
PrintLine("Perimeter = ");
|
||||
PrintInt(rect.Perimeter());
|
||||
PrintLine("");
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user