migrate all the temporary tests to new test file
This commit is contained in:
30
test/cases3/struct.zig
Normal file
30
test/cases3/struct.zig
Normal file
@@ -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();
|
||||
}
|
||||
Reference in New Issue
Block a user