summaryrefslogtreecommitdiff
path: root/tests/features/test_alias.zc
diff options
context:
space:
mode:
authorZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-16 12:43:51 +0000
committerZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-16 12:43:51 +0000
commite77725b55190b8ec6dcab46aa137c32652ea004b (patch)
treea80e237f1f65873f908f5819488c1c32683aff74 /tests/features/test_alias.zc
parent2e1aa3d8853f3b49e93b1d50b1b6e60e8238d79c (diff)
Support for 'alias' + test. Improved formatting and '.gitignore'.
Diffstat (limited to 'tests/features/test_alias.zc')
-rw-r--r--tests/features/test_alias.zc41
1 files changed, 41 insertions, 0 deletions
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");
+}