suicmez/tests/codegen/test_comprehensive.sui
2025-12-19 18:53:41 +02:00

36 lines
709 B
Text

struct Point
x: int,
y: int,
end
enum Status
Ok,
Error,
end
fn add(a: int, b: int) -> int do
a + b
end
fn main() -> int do
# Test stack-allocated types (copyable)
let x = 10;
let y = 20;
let sum = add(x, y);
# Test struct (stack-allocated for now, but declared as such in language)
let p = Point { x: 5, y: 15 };
let point_sum = p.x + p.y;
# Test enum (stack-allocated for now)
let status = Status::Ok();
# Test array (heap-allocated), no way to preinit an array with a length rn
let arr = [1, 2, 3, 4, 5];
let first = arr[0];
# Test string (heap-allocated)
let msg = "hello";
sum + point_sum + first
end