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 {...@@ -34,6 +34,7 @@ test {
34 _ = @import("behavior/slice_sentinel_comptime.zig");34 _ = @import("behavior/slice_sentinel_comptime.zig");
35 _ = @import("behavior/type.zig");35 _ = @import("behavior/type.zig");
36 _ = @import("behavior/truncate.zig");36 _ = @import("behavior/truncate.zig");
37 _ = @import("behavior/struct.zig");
3738
38 if (builtin.zig_backend != .stage2_arm and builtin.zig_backend != .stage2_x86_64) {39 if (builtin.zig_backend != .stage2_arm and builtin.zig_backend != .stage2_x86_64) {
39 // Tests that pass for stage1, llvm backend, C backend, wasm backend.40 // Tests that pass for stage1, llvm backend, C backend, wasm backend.
...@@ -69,7 +70,6 @@ test {...@@ -69,7 +70,6 @@ test {
69 _ = @import("behavior/ptrcast.zig");70 _ = @import("behavior/ptrcast.zig");
70 _ = @import("behavior/ref_var_in_if_after_if_2nd_switch_prong.zig");71 _ = @import("behavior/ref_var_in_if_after_if_2nd_switch_prong.zig");
71 _ = @import("behavior/src.zig");72 _ = @import("behavior/src.zig");
72 _ = @import("behavior/struct.zig");
73 _ = @import("behavior/this.zig");73 _ = @import("behavior/this.zig");
74 _ = @import("behavior/try.zig");74 _ = @import("behavior/try.zig");
75 _ = @import("behavior/type_info.zig");75 _ = @import("behavior/type_info.zig");
test/behavior/struct.zig+24
...@@ -9,6 +9,8 @@ const maxInt = std.math.maxInt;...@@ -9,6 +9,8 @@ const maxInt = std.math.maxInt;
9top_level_field: i32,9top_level_field: i32,
1010
11test "top level fields" {11test "top level fields" {
12 if (builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
13
12 var instance = @This(){14 var instance = @This(){
13 .top_level_field = 1234,15 .top_level_field = 1234,
14 };16 };
...@@ -29,6 +31,8 @@ const StructFoo = struct {...@@ -29,6 +31,8 @@ const StructFoo = struct {
29};31};
3032
31test "structs" {33test "structs" {
34 if (builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
35
32 var foo: StructFoo = undefined;36 var foo: StructFoo = undefined;
33 @memset(@ptrCast([*]u8, &foo), 0, @sizeOf(StructFoo));37 @memset(@ptrCast([*]u8, &foo), 0, @sizeOf(StructFoo));
34 foo.a += 1;38 foo.a += 1;
...@@ -45,6 +49,8 @@ fn testMutation(foo: *StructFoo) void {...@@ -45,6 +49,8 @@ fn testMutation(foo: *StructFoo) void {
45}49}
4650
47test "struct byval assign" {51test "struct byval assign" {
52 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
53
48 var foo1: StructFoo = undefined;54 var foo1: StructFoo = undefined;
49 var foo2: StructFoo = undefined;55 var foo2: StructFoo = undefined;
5056
...@@ -56,6 +62,8 @@ test "struct byval assign" {...@@ -56,6 +62,8 @@ test "struct byval assign" {
56}62}
5763
58test "call struct static method" {64test "call struct static method" {
65 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
66
59 const result = StructWithNoFields.add(3, 4);67 const result = StructWithNoFields.add(3, 4);
60 try expect(result == 7);68 try expect(result == 7);
61}69}
...@@ -85,6 +93,8 @@ const Val = struct {...@@ -85,6 +93,8 @@ const Val = struct {
85};93};
8694
87test "fn call of struct field" {95test "fn call of struct field" {
96 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
97
88 const Foo = struct {98 const Foo = struct {
89 ptr: fn () i32,99 ptr: fn () i32,
90 };100 };
...@@ -114,12 +124,16 @@ const MemberFnTestFoo = struct {...@@ -114,12 +124,16 @@ const MemberFnTestFoo = struct {
114};124};
115125
116test "call member function directly" {126test "call member function directly" {
127 if (builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
128
117 const instance = MemberFnTestFoo{ .x = 1234 };129 const instance = MemberFnTestFoo{ .x = 1234 };
118 const result = MemberFnTestFoo.member(instance);130 const result = MemberFnTestFoo.member(instance);
119 try expect(result == 1234);131 try expect(result == 1234);
120}132}
121133
122test "store member function in variable" {134test "store member function in variable" {
135 if (builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
136
123 const instance = MemberFnTestFoo{ .x = 1234 };137 const instance = MemberFnTestFoo{ .x = 1234 };
124 const memberFn = MemberFnTestFoo.member;138 const memberFn = MemberFnTestFoo.member;
125 const result = memberFn(instance);139 const result = memberFn(instance);
...@@ -127,6 +141,8 @@ test "store member function in variable" {...@@ -127,6 +141,8 @@ test "store member function in variable" {
127}141}
128142
129test "member functions" {143test "member functions" {
144 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
145
130 const r = MemberFnRand{ .seed = 1234 };146 const r = MemberFnRand{ .seed = 1234 };
131 try expect(r.getSeed() == 1234);147 try expect(r.getSeed() == 1234);
132}148}
...@@ -138,6 +154,8 @@ const MemberFnRand = struct {...@@ -138,6 +154,8 @@ const MemberFnRand = struct {
138};154};
139155
140test "return struct byval from function" {156test "return struct byval from function" {
157 if (builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
158
141 const bar = makeBar2(1234, 5678);159 const bar = makeBar2(1234, 5678);
142 try expect(bar.y == 5678);160 try expect(bar.y == 5678);
143}161}
...@@ -153,6 +171,8 @@ fn makeBar2(x: i32, y: i32) Bar {...@@ -153,6 +171,8 @@ fn makeBar2(x: i32, y: i32) Bar {
153}171}
154172
155test "call method with mutable reference to struct with no fields" {173test "call method with mutable reference to struct with no fields" {
174 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
175
156 const S = struct {176 const S = struct {
157 fn doC(s: *const @This()) bool {177 fn doC(s: *const @This()) bool {
158 _ = s;178 _ = s;
...@@ -172,6 +192,8 @@ test "call method with mutable reference to struct with no fields" {...@@ -172,6 +192,8 @@ test "call method with mutable reference to struct with no fields" {
172}192}
173193
174test "usingnamespace within struct scope" {194test "usingnamespace within struct scope" {
195 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
196
175 const S = struct {197 const S = struct {
176 usingnamespace struct {198 usingnamespace struct {
177 pub fn inner() i32 {199 pub fn inner() i32 {
...@@ -183,6 +205,8 @@ test "usingnamespace within struct scope" {...@@ -183,6 +205,8 @@ test "usingnamespace within struct scope" {
183}205}
184206
185test "struct field init with catch" {207test "struct field init with catch" {
208 if (builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
209
186 const S = struct {210 const S = struct {
187 fn doTheTest() !void {211 fn doTheTest() !void {
188 var x: anyerror!isize = 1;212 var x: anyerror!isize = 1;