aboutsummaryrefslogtreecommitdiff
path: root/test/run_tests.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/run_tests.cpp')
-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");
}