ability to call member functions directly

see #14
This commit is contained in:
Andrew Kelley
2016-01-28 16:55:54 -07:00
parent bb4f783528
commit 974d69ea3d
3 changed files with 50 additions and 13 deletions

View File

@@ -1407,6 +1407,22 @@ pub fn main(args: [][]u8) -> %void {
%%stdout.printf("BAD\n");
}
%%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");
}