authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-02-01 21:55:34+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-02-02 10:48:21+01:00
log521bd2e94a3b32382b2d1de1e6185149032b49db
tree8e7983f584d73ba60757b72283a0cb58cd3881d6
parent0cccd8a88762dde3995702020dd3c39771cf8fd4

x86_64: pass more behaviour tests


2 files changed, 25 insertions(+), 1 deletions(-)

test/behavior.zig+1-1
......@@ -34,6 +34,7 @@ test {
3434 _ = @import("behavior/slice_sentinel_comptime.zig");
3535 _ = @import("behavior/type.zig");
3636 _ = @import("behavior/truncate.zig");
37 _ = @import("behavior/struct.zig");
3738
3839 if (builtin.zig_backend != .stage2_arm and builtin.zig_backend != .stage2_x86_64) {
3940 // Tests that pass for stage1, llvm backend, C backend, wasm backend.
......@@ -69,7 +70,6 @@ test {
6970 _ = @import("behavior/ptrcast.zig");
7071 _ = @import("behavior/ref_var_in_if_after_if_2nd_switch_prong.zig");
7172 _ = @import("behavior/src.zig");
72 _ = @import("behavior/struct.zig");
7373 _ = @import("behavior/this.zig");
7474 _ = @import("behavior/try.zig");
7575 _ = @import("behavior/type_info.zig");
test/behavior/struct.zig+24
......@@ -9,6 +9,8 @@ const maxInt = std.math.maxInt;
99top_level_field: i32,
1010
1111test "top level fields" {
12 if (builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
13
1214 var instance = @This(){
1315 .top_level_field = 1234,
1416 };
......@@ -29,6 +31,8 @@ const StructFoo = struct {
2931};
3032
3133test "structs" {
34 if (builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
35
3236 var foo: StructFoo = undefined;
3337 @memset(@ptrCast([*]u8, &foo), 0, @sizeOf(StructFoo));
3438 foo.a += 1;
......@@ -45,6 +49,8 @@ fn testMutation(foo: *StructFoo) void {
4549}
4650
4751test "struct byval assign" {
52 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
53
4854 var foo1: StructFoo = undefined;
4955 var foo2: StructFoo = undefined;
5056
......@@ -56,6 +62,8 @@ test "struct byval assign" {
5662}
5763
5864test "call struct static method" {
65 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
66
5967 const result = StructWithNoFields.add(3, 4);
6068 try expect(result == 7);
6169}
......@@ -85,6 +93,8 @@ const Val = struct {
8593};
8694
8795test "fn call of struct field" {
96 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
97
8898 const Foo = struct {
8999 ptr: fn () i32,
90100 };
......@@ -114,12 +124,16 @@ const MemberFnTestFoo = struct {
114124};
115125
116126test "call member function directly" {
127 if (builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
128
117129 const instance = MemberFnTestFoo{ .x = 1234 };
118130 const result = MemberFnTestFoo.member(instance);
119131 try expect(result == 1234);
120132}
121133
122134test "store member function in variable" {
135 if (builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
136
123137 const instance = MemberFnTestFoo{ .x = 1234 };
124138 const memberFn = MemberFnTestFoo.member;
125139 const result = memberFn(instance);
......@@ -127,6 +141,8 @@ test "store member function in variable" {
127141}
128142
129143test "member functions" {
144 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
145
130146 const r = MemberFnRand{ .seed = 1234 };
131147 try expect(r.getSeed() == 1234);
132148}
......@@ -138,6 +154,8 @@ const MemberFnRand = struct {
138154};
139155
140156test "return struct byval from function" {
157 if (builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
158
141159 const bar = makeBar2(1234, 5678);
142160 try expect(bar.y == 5678);
143161}
......@@ -153,6 +171,8 @@ fn makeBar2(x: i32, y: i32) Bar {
153171}
154172
155173test "call method with mutable reference to struct with no fields" {
174 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
175
156176 const S = struct {
157177 fn doC(s: *const @This()) bool {
158178 _ = s;
......@@ -172,6 +192,8 @@ test "call method with mutable reference to struct with no fields" {
172192}
173193
174194test "usingnamespace within struct scope" {
195 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
196
175197 const S = struct {
176198 usingnamespace struct {
177199 pub fn inner() i32 {
......@@ -183,6 +205,8 @@ test "usingnamespace within struct scope" {
183205}
184206
185207test "struct field init with catch" {
208 if (builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
209
186210 const S = struct {
187211 fn doTheTest() !void {
188212 var x: anyerror!isize = 1;