diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-12-22 00:12:27 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-12-22 00:12:27 -0500 |
| commit | 56cc2e2b24f50975591de02e8a556eee4ac45bf7 (patch) | |
| tree | 623cb79aafad44459e9d1ad590f9f218331864eb /test/cases3/struct.zig | |
| parent | d544672ed4cb8d8054665c9491d019dabac454e7 (diff) | |
| download | zig-56cc2e2b24f50975591de02e8a556eee4ac45bf7.tar.gz zig-56cc2e2b24f50975591de02e8a556eee4ac45bf7.zip | |
migrate all the temporary tests to new test file
Diffstat (limited to 'test/cases3/struct.zig')
| -rw-r--r-- | test/cases3/struct.zig | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/cases3/struct.zig b/test/cases3/struct.zig new file mode 100644 index 0000000000..de703f0b40 --- /dev/null +++ b/test/cases3/struct.zig @@ -0,0 +1,30 @@ +const StructWithNoFields = struct { + fn add(a: i32, b: i32) -> i32 { a + b } +}; +const empty_global_instance = StructWithNoFields {}; + +fn callStructStaticMethod() { + @setFnTest(this); + const result = StructWithNoFields.add(3, 4); + assert(result == 7); +} + +fn returnEmptyStructInstance() -> StructWithNoFields { + @setFnTest(this); + return empty_global_instance; +} + +const should_be_11 = StructWithNoFields.add(5, 6); + +fn invokeStaticMethodInGlobalScope() { + @setFnTest(this); + assert(should_be_11 == 11); +} + + + +// TODO const assert = @import("std").debug.assert; +fn assert(ok: bool) { + if (!ok) + @unreachable(); +} |
