diff options
| author | SAJJA EASWAR <eshwarsajja20@gmail.com> | 2026-01-25 22:59:36 +0530 |
|---|---|---|
| committer | SAJJA EASWAR <eshwarsajja20@gmail.com> | 2026-01-25 22:59:36 +0530 |
| commit | ebc8b94baa6bc694cb4829e2eb2934a1f17fa6a1 (patch) | |
| tree | 71b952ad455bf17d5bdea01472f0e2297f25eabe /tests/functions/test_raw_func_ptr.zc | |
| parent | 863118c95caac0d69a35f6ae4d2e83844734a8a1 (diff) | |
| parent | 489336b2101bf16edeec7bfc4379408eb19b936e (diff) | |
Merge branch 'main' into pr-109
Diffstat (limited to 'tests/functions/test_raw_func_ptr.zc')
| -rw-r--r-- | tests/functions/test_raw_func_ptr.zc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/functions/test_raw_func_ptr.zc b/tests/functions/test_raw_func_ptr.zc new file mode 100644 index 0000000..115e421 --- /dev/null +++ b/tests/functions/test_raw_func_ptr.zc @@ -0,0 +1,27 @@ + +fn print_msg(msg: char*) { + puts(msg); +} + +fn run_callback(cb: fn*(char*), arg: char*) { + cb(arg); +} + +fn get_printer() -> fn*(char*) { + return print_msg; +} + +test "raw_func_ptr_basic" { + run_callback(print_msg, "Hello Raw Ptr"); +} + +test "raw_func_ptr_return_explicit" { + let p: fn*(char*) = get_printer(); + p("Returned Ptr Explicit works"); +} + +test "fn_ptr_ptr" { + let p: fn*(char*) = print_msg; + let pp: fn**(char*) = &p; + (*pp)("Double Pointer works"); +} |
