diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-01-18 16:42:45 -0700 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-01-18 16:42:45 -0700 |
| commit | 32821e7098ba29c30e458f555f62954ce54dcb1a (patch) | |
| tree | efc8326896f255c9ba6f12e28c4e83612242271c /test/run_tests.cpp | |
| parent | 3a326d50051ad8b65639e5e2bbe45e41a8b35591 (diff) | |
| download | zig-32821e7098ba29c30e458f555f62954ce54dcb1a.tar.gz zig-32821e7098ba29c30e458f555f62954ce54dcb1a.zip | |
add function pointer support
See #14
Diffstat (limited to 'test/run_tests.cpp')
| -rw-r--r-- | test/run_tests.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/run_tests.cpp b/test/run_tests.cpp index c5b816e91d..0e032c64d3 100644 --- a/test/run_tests.cpp +++ b/test/run_tests.cpp @@ -1162,6 +1162,24 @@ pub fn main(args: [][]u8) i32 => { return 0; } )SOURCE", "9\n8\n7\n6\n0\n1\n2\n3\n9\n8\n7\n6\n0\n1\n2\n3\n"); + + add_simple_case("function pointers", R"SOURCE( +import "std.zig"; + +pub fn main(args: [][]u8) i32 => { + const fns = []@typeof(fn1) { fn1, fn2, fn3, fn4, }; + for (f, fns) { + print_u64(f()); + print_str("\n"); + } + return 0; +} + +fn fn1() u32 => {5} +fn fn2() u32 => {6} +fn fn3() u32 => {7} +fn fn4() u32 => {8} + )SOURCE", "5\n6\n7\n8\n"); } |
