mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 04:48:20 +00:00
parent
8ebcca6734
commit
b7914d901c
@ -1,3 +1,12 @@
|
||||
test "zig fmt: top-level fields" {
|
||||
try testCanonical(
|
||||
\\a: did_you_know,
|
||||
\\b: all_files_are,
|
||||
\\structs: ?x,
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: decl between fields" {
|
||||
try testError(
|
||||
\\const S = struct {
|
||||
|
||||
@ -11,6 +11,16 @@ const StructWithNoFields = struct {
|
||||
};
|
||||
const empty_global_instance = StructWithNoFields{};
|
||||
|
||||
top_level_field: i32,
|
||||
|
||||
test "top level fields" {
|
||||
var instance = @This(){
|
||||
.top_level_field = 1234,
|
||||
};
|
||||
instance.top_level_field += 1;
|
||||
expectEqual(@as(i32, 1235), instance.top_level_field);
|
||||
}
|
||||
|
||||
test "call struct static method" {
|
||||
const result = StructWithNoFields.add(3, 4);
|
||||
expect(result == 7);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user