diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-01-28 16:55:54 -0700 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-01-28 16:55:54 -0700 |
| commit | 974d69ea3d0db71b97af00e325fdfb421c0906c2 (patch) | |
| tree | 05c145b633277b78735765d8f9c15f78d504b2ed /test/run_tests.cpp | |
| parent | bb4f7835286f047fc596715101ee0318c8e7f924 (diff) | |
| download | zig-974d69ea3d0db71b97af00e325fdfb421c0906c2.tar.gz zig-974d69ea3d0db71b97af00e325fdfb421c0906c2.zip | |
ability to call member functions directly
see #14
Diffstat (limited to 'test/run_tests.cpp')
| -rw-r--r-- | test/run_tests.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/run_tests.cpp b/test/run_tests.cpp index b15f6e2ec4..84704d5f64 100644 --- a/test/run_tests.cpp +++ b/test/run_tests.cpp @@ -1409,6 +1409,22 @@ pub fn main(args: [][]u8) -> %void { %%stdout.printf("OK\n"); } )SOURCE", "OK\n"); + + add_simple_case("call member function directly", 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 result = Foo.member(instance); + if (result != 1234) { + %%stdout.printf("BAD\n"); + } + %%stdout.printf("OK\n"); +} + )SOURCE", "OK\n"); } |
