diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-01-28 16:45:17 -0700 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-01-28 16:45:17 -0700 |
| commit | bb4f7835286f047fc596715101ee0318c8e7f924 (patch) | |
| tree | 4860d7b895c592e11ca32f451a256e4720d956ba /test/run_tests.cpp | |
| parent | 13220ccb51b7d2cf7b8d72a662eece95784116c3 (diff) | |
| download | zig-bb4f7835286f047fc596715101ee0318c8e7f924.tar.gz zig-bb4f7835286f047fc596715101ee0318c8e7f924.zip | |
ability to refer to member function directly
See #14
Diffstat (limited to 'test/run_tests.cpp')
| -rw-r--r-- | test/run_tests.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/test/run_tests.cpp b/test/run_tests.cpp index 5b4f5a5694..b15f6e2ec4 100644 --- a/test/run_tests.cpp +++ b/test/run_tests.cpp @@ -1386,9 +1386,27 @@ pub fn main(args: [][]u8) -> %void { if (*ptr != 6) { %%stdout.printf("BAD\n"); } - %%stdout.printf("OK\n"); free(ptr); + + %%stdout.printf("OK\n"); +} + )SOURCE", "OK\n"); + + add_simple_case("store member function in variable", R"SOURCE( +import "std.zig"; +struct Foo { + x: i32, + fn member(foo: Foo) -> i32 { foo.x } +} +pub fn main(args: [][]u8) -> %void { + const instance = Foo { .x = 1234, }; + const member_fn = Foo.member; + const result = member_fn(instance); + if (result != 1234) { + %%stdout.printf("BAD\n"); + } + %%stdout.printf("OK\n"); } )SOURCE", "OK\n"); } |
