From e77725b55190b8ec6dcab46aa137c32652ea004b Mon Sep 17 00:00:00 2001 From: Zuhaitz Méndez Fernández de Aránguiz Date: Fri, 16 Jan 2026 12:43:51 +0000 Subject: Support for 'alias' + test. Improved formatting and '.gitignore'. --- tests/features/test_alias.zc | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 tests/features/test_alias.zc (limited to 'tests/features/test_alias.zc') diff --git a/tests/features/test_alias.zc b/tests/features/test_alias.zc new file mode 100644 index 0000000..f7bc42a --- /dev/null +++ b/tests/features/test_alias.zc @@ -0,0 +1,41 @@ + +struct Point { + x: int; + y: int; +} + +alias MyIntPtr = int*; +alias MyInt = int; + +fn process(val: MyInt) -> MyInt { + return val + 1; +} + +alias BinOp = fn(int, int) -> int; + +fn add(a: int, b: int) -> int { + return a + b; +} + +test "alias basic" { + var x: MyInt = 10; + var ptr: MyIntPtr = &x; + + assert(x == 10, "Basic alias failed"); + assert(*ptr == 10, "Pointer alias failed"); + + var res = process(x); + assert(res == 11, "Function with alias arg failed"); +} + + p.x = 100; + p.y = 200; + + assert(p.x == 100, "Struct alias access failed"); +} + +test "alias function pointer" { + // var op: BinOp; + // Assignment currently not supported for function types without casting op = add; + // assert(op(1, 2) == 3, "Function alias"); +} -- cgit v1.2.3