authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-05-02 14:53:20-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-05-02 14:53:20-04:00
logb7914d901c8c5761457a4774858f1004febc2d3a
tree9732a5d55258950910d38ba1689b831ee96cdd58
parent8ebcca6734e07aea29098ca4c63c0216b3099d0e

add test coverage for top level fields

closes #2022

2 files changed, 19 insertions(+), 0 deletions(-)

lib/std/zig/parser_test.zig+9
......@@ -1,3 +1,12 @@
1test "zig fmt: top-level fields" {
2 try testCanonical(
3 \\a: did_you_know,
4 \\b: all_files_are,
5 \\structs: ?x,
6 \\
7 );
8}
9
110test "zig fmt: decl between fields" {
211 try testError(
312 \\const S = struct {
test/stage1/behavior/struct.zig+10
......@@ -11,6 +11,16 @@ const StructWithNoFields = struct {
1111};
1212const empty_global_instance = StructWithNoFields{};
1313
14top_level_field: i32,
15
16test "top level fields" {
17 var instance = @This(){
18 .top_level_field = 1234,
19 };
20 instance.top_level_field += 1;
21 expectEqual(@as(i32, 1235), instance.top_level_field);
22}
23
1424test "call struct static method" {
1525 const result = StructWithNoFields.add(3, 4);
1626 expect(result == 7);