From bb4f7835286f047fc596715101ee0318c8e7f924 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 28 Jan 2016 16:45:17 -0700 Subject: ability to refer to member function directly See #14 --- test/run_tests.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'test/run_tests.cpp') 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"); } -- cgit v1.2.3