aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-01-28 16:45:17 -0700
committerAndrew Kelley <superjoe30@gmail.com>2016-01-28 16:45:17 -0700
commitbb4f7835286f047fc596715101ee0318c8e7f924 (patch)
tree4860d7b895c592e11ca32f451a256e4720d956ba /test
parent13220ccb51b7d2cf7b8d72a662eece95784116c3 (diff)
downloadzig-bb4f7835286f047fc596715101ee0318c8e7f924.tar.gz
zig-bb4f7835286f047fc596715101ee0318c8e7f924.zip
ability to refer to member function directly
See #14
Diffstat (limited to 'test')
-rw-r--r--test/run_tests.cpp20
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");
}