Commit b7914d901c
Changed files (2)
lib
std
test
stage1
behavior
lib/std/zig/parser_test.zig
@@ -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 {
test/stage1/behavior/struct.zig
@@ -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);