authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-02-22 14:15:09+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-02-22 21:57:42+01:00
log25e4b16e25502ca5e76e4049ed9f727168782dde
tree947799ee1d22e621937c95842370cc7aee679412
parenta94267b2906e90aadf397b3f524e1069721fb496

Port more behavior tests


40 files changed, 832 insertions(+), 140 deletions(-)

test/behavior.zig+110-110
...@@ -9,12 +9,16 @@ test {...@@ -9,12 +9,16 @@ test {
9 _ = @import("behavior/bitcast.zig");9 _ = @import("behavior/bitcast.zig");
10 _ = @import("behavior/bitreverse.zig");10 _ = @import("behavior/bitreverse.zig");
11 _ = @import("behavior/byteswap.zig");11 _ = @import("behavior/byteswap.zig");
12 _ = @import("behavior/byval_arg_var.zig");
12 _ = @import("behavior/bool.zig");13 _ = @import("behavior/bool.zig");
13 _ = @import("behavior/bugs/394.zig");14 _ = @import("behavior/bugs/394.zig");
15 _ = @import("behavior/bugs/624.zig");
14 _ = @import("behavior/bugs/655.zig");16 _ = @import("behavior/bugs/655.zig");
15 _ = @import("behavior/bugs/656.zig");17 _ = @import("behavior/bugs/656.zig");
16 _ = @import("behavior/bugs/679.zig");18 _ = @import("behavior/bugs/679.zig");
19 _ = @import("behavior/bugs/704.zig");
17 _ = @import("behavior/bugs/1025.zig");20 _ = @import("behavior/bugs/1025.zig");
21 _ = @import("behavior/bugs/1076.zig");
18 _ = @import("behavior/bugs/1111.zig");22 _ = @import("behavior/bugs/1111.zig");
19 _ = @import("behavior/bugs/1277.zig");23 _ = @import("behavior/bugs/1277.zig");
20 _ = @import("behavior/bugs/1310.zig");24 _ = @import("behavior/bugs/1310.zig");
...@@ -27,149 +31,145 @@ test {...@@ -27,149 +31,145 @@ test {
27 _ = @import("behavior/bugs/2006.zig");31 _ = @import("behavior/bugs/2006.zig");
28 _ = @import("behavior/bugs/2346.zig");32 _ = @import("behavior/bugs/2346.zig");
29 _ = @import("behavior/bugs/2578.zig");33 _ = @import("behavior/bugs/2578.zig");
34 _ = @import("behavior/bugs/2692.zig");
35 _ = @import("behavior/bugs/2889.zig");
30 _ = @import("behavior/bugs/3007.zig");36 _ = @import("behavior/bugs/3007.zig");
37 _ = @import("behavior/bugs/3046.zig");
31 _ = @import("behavior/bugs/3112.zig");38 _ = @import("behavior/bugs/3112.zig");
32 _ = @import("behavior/bugs/3367.zig");39 _ = @import("behavior/bugs/3367.zig");
40 _ = @import("behavior/bugs/3586.zig");
41 _ = @import("behavior/bugs/4560.zig");
42 _ = @import("behavior/bugs/4769_a.zig");
43 _ = @import("behavior/bugs/4769_b.zig");
44 _ = @import("behavior/bugs/4954.zig");
33 _ = @import("behavior/bugs/6850.zig");45 _ = @import("behavior/bugs/6850.zig");
34 _ = @import("behavior/bugs/7250.zig");46 _ = @import("behavior/bugs/7250.zig");
47 _ = @import("behavior/call.zig");
35 _ = @import("behavior/cast.zig");48 _ = @import("behavior/cast.zig");
36 _ = @import("behavior/comptime_memory.zig");49 _ = @import("behavior/comptime_memory.zig");
50 _ = @import("behavior/defer.zig");
51 _ = @import("behavior/enum.zig");
52 _ = @import("behavior/error.zig");
53 _ = @import("behavior/fn.zig");
37 _ = @import("behavior/fn_delegation.zig");54 _ = @import("behavior/fn_delegation.zig");
38 _ = @import("behavior/fn_in_struct_in_comptime.zig");55 _ = @import("behavior/fn_in_struct_in_comptime.zig");
56 _ = @import("behavior/for.zig");
57 _ = @import("behavior/generics.zig");
39 _ = @import("behavior/hasdecl.zig");58 _ = @import("behavior/hasdecl.zig");
40 _ = @import("behavior/hasfield.zig");59 _ = @import("behavior/hasfield.zig");
60 _ = @import("behavior/if.zig");
61 _ = @import("behavior/import.zig");
62 _ = @import("behavior/incomplete_struct_param_tld.zig");
63 _ = @import("behavior/int_div.zig");
64 _ = @import("behavior/inttoptr.zig");
41 _ = @import("behavior/ir_block_deps.zig");65 _ = @import("behavior/ir_block_deps.zig");
66 _ = @import("behavior/member_func.zig");
42 _ = @import("behavior/namespace_depends_on_compile_var.zig");67 _ = @import("behavior/namespace_depends_on_compile_var.zig");
68 _ = @import("behavior/null.zig");
43 _ = @import("behavior/optional.zig");69 _ = @import("behavior/optional.zig");
44 _ = @import("behavior/prefetch.zig");70 _ = @import("behavior/prefetch.zig");
71 _ = @import("behavior/pointers.zig");
45 _ = @import("behavior/pub_enum.zig");72 _ = @import("behavior/pub_enum.zig");
73 _ = @import("behavior/ptrcast.zig");
46 _ = @import("behavior/reflection.zig");74 _ = @import("behavior/reflection.zig");
75 _ = @import("behavior/ref_var_in_if_after_if_2nd_switch_prong.zig");
47 _ = @import("behavior/slice.zig");76 _ = @import("behavior/slice.zig");
48 _ = @import("behavior/slice_sentinel_comptime.zig");77 _ = @import("behavior/slice_sentinel_comptime.zig");
49 _ = @import("behavior/struct.zig");78 _ = @import("behavior/struct.zig");
79 _ = @import("behavior/src.zig");
80 _ = @import("behavior/this.zig");
50 _ = @import("behavior/truncate.zig");81 _ = @import("behavior/truncate.zig");
82 _ = @import("behavior/try.zig");
51 _ = @import("behavior/tuple.zig");83 _ = @import("behavior/tuple.zig");
52 _ = @import("behavior/type.zig");84 _ = @import("behavior/type.zig");
85 _ = @import("behavior/type_info.zig");
86 _ = @import("behavior/undefined.zig");
87 _ = @import("behavior/underscore.zig");
88 _ = @import("behavior/union.zig");
89 _ = @import("behavior/usingnamespace.zig");
53 _ = @import("behavior/var_args.zig");90 _ = @import("behavior/var_args.zig");
54 _ = @import("behavior/int_div.zig");91 _ = @import("behavior/void.zig");
92 _ = @import("behavior/while.zig");
5593
56 // tests that don't pass for stage194 // tests that don't pass for stage1
57 if (builtin.zig_backend != .stage1) {95 if (builtin.zig_backend != .stage1) {
58 _ = @import("behavior/decltest.zig");96 _ = @import("behavior/decltest.zig");
59 }97 }
6098
61 if (builtin.zig_backend != .stage2_arm and builtin.zig_backend != .stage2_x86_64 and builtin.zig_backend != .stage2_aarch64) {99 if (builtin.zig_backend != .stage2_arm and
62 // Tests that pass (partly) for stage1, llvm backend, C backend, wasm backend.100 builtin.zig_backend != .stage2_x86_64 and
63 _ = @import("behavior/bugs/624.zig");101 builtin.zig_backend != .stage2_aarch64 and
64 _ = @import("behavior/bugs/704.zig");102 builtin.zig_backend != .stage2_wasm)
65 _ = @import("behavior/bugs/1076.zig");103 {
66 _ = @import("behavior/bugs/2692.zig");104 // Tests that pass for stage1, llvm backend, C backend
67 _ = @import("behavior/bugs/2889.zig");105 _ = @import("behavior/bugs/9584.zig");
68 _ = @import("behavior/bugs/3046.zig");106 _ = @import("behavior/cast_int.zig");
69 _ = @import("behavior/bugs/3586.zig");107 _ = @import("behavior/eval.zig");
70 _ = @import("behavior/bugs/4560.zig");108 _ = @import("behavior/int128.zig");
71 _ = @import("behavior/bugs/4769_a.zig");109 _ = @import("behavior/merge_error_sets.zig");
72 _ = @import("behavior/bugs/4769_b.zig");110 _ = @import("behavior/translate_c_macros.zig");
73 _ = @import("behavior/bugs/4954.zig");
74 _ = @import("behavior/byval_arg_var.zig");
75 _ = @import("behavior/call.zig");
76 _ = @import("behavior/defer.zig");
77 _ = @import("behavior/enum.zig");
78 _ = @import("behavior/error.zig");
79 _ = @import("behavior/fn.zig");
80 _ = @import("behavior/for.zig");
81 _ = @import("behavior/generics.zig");
82 _ = @import("behavior/if.zig");
83 _ = @import("behavior/import.zig");
84 _ = @import("behavior/incomplete_struct_param_tld.zig");
85 _ = @import("behavior/inttoptr.zig");
86 _ = @import("behavior/member_func.zig");
87 _ = @import("behavior/null.zig");
88 _ = @import("behavior/pointers.zig");
89 _ = @import("behavior/ptrcast.zig");
90 _ = @import("behavior/ref_var_in_if_after_if_2nd_switch_prong.zig");
91 _ = @import("behavior/src.zig");
92 _ = @import("behavior/this.zig");
93 _ = @import("behavior/try.zig");
94 _ = @import("behavior/type_info.zig");
95 _ = @import("behavior/undefined.zig");
96 _ = @import("behavior/underscore.zig");
97 _ = @import("behavior/union.zig");
98 _ = @import("behavior/usingnamespace.zig");
99 _ = @import("behavior/void.zig");
100 _ = @import("behavior/while.zig");
101111
102 if (builtin.zig_backend != .stage2_wasm) {112 if (builtin.zig_backend != .stage2_c) {
103 // Tests that pass for stage1, llvm backend, C backend113 // Tests that pass for stage1 and the llvm backend.
104 _ = @import("behavior/bugs/9584.zig");114 _ = @import("behavior/atomics.zig");
105 _ = @import("behavior/cast_int.zig");115 _ = @import("behavior/floatop.zig");
106 _ = @import("behavior/eval.zig");116 _ = @import("behavior/math.zig");
107 _ = @import("behavior/int128.zig");117 _ = @import("behavior/maximum_minimum.zig");
108 _ = @import("behavior/merge_error_sets.zig");118 _ = @import("behavior/popcount.zig");
109 _ = @import("behavior/translate_c_macros.zig");119 _ = @import("behavior/saturating_arithmetic.zig");
120 _ = @import("behavior/sizeof_and_typeof.zig");
121 _ = @import("behavior/switch.zig");
122 _ = @import("behavior/widening.zig");
110123
111 if (builtin.zig_backend != .stage2_c) {124 if (builtin.zig_backend == .stage1) {
112 // Tests that pass for stage1 and the llvm backend.125 // Tests that only pass for the stage1 backend.
113 _ = @import("behavior/atomics.zig");126 if (builtin.os.tag != .wasi) {
114 _ = @import("behavior/floatop.zig");127 _ = @import("behavior/asm.zig");
115 _ = @import("behavior/math.zig");128 _ = @import("behavior/async_fn.zig");
116 _ = @import("behavior/maximum_minimum.zig");129 }
117 _ = @import("behavior/popcount.zig");130 _ = @import("behavior/await_struct.zig");
118 _ = @import("behavior/saturating_arithmetic.zig");131 _ = @import("behavior/bugs/421.zig");
119 _ = @import("behavior/sizeof_and_typeof.zig");132 _ = @import("behavior/bugs/529.zig");
120 _ = @import("behavior/switch.zig");133 _ = @import("behavior/bugs/718.zig");
121 _ = @import("behavior/widening.zig");134 _ = @import("behavior/bugs/726.zig");
135 _ = @import("behavior/bugs/828.zig");
136 _ = @import("behavior/bugs/920.zig");
137 _ = @import("behavior/bugs/1120.zig");
138 _ = @import("behavior/bugs/1421.zig");
122 _ = @import("behavior/bugs/1442.zig");139 _ = @import("behavior/bugs/1442.zig");
123140 _ = @import("behavior/bugs/1607.zig");
124 if (builtin.zig_backend == .stage1) {141 _ = @import("behavior/bugs/1851.zig");
125 // Tests that only pass for the stage1 backend.142 _ = @import("behavior/bugs/2114.zig");
126 if (builtin.os.tag != .wasi) {143 _ = @import("behavior/bugs/3384.zig");
127 _ = @import("behavior/asm.zig");144 _ = @import("behavior/bugs/3742.zig");
128 _ = @import("behavior/async_fn.zig");145 _ = @import("behavior/bugs/3779.zig");
129 }146 _ = @import("behavior/bugs/4328.zig");
130 _ = @import("behavior/await_struct.zig");147 _ = @import("behavior/bugs/5398.zig");
131 _ = @import("behavior/bugs/421.zig");148 _ = @import("behavior/bugs/5413.zig");
132 _ = @import("behavior/bugs/529.zig");149 _ = @import("behavior/bugs/5474.zig");
133 _ = @import("behavior/bugs/718.zig");150 _ = @import("behavior/bugs/5487.zig");
134 _ = @import("behavior/bugs/726.zig");151 _ = @import("behavior/bugs/6456.zig");
135 _ = @import("behavior/bugs/828.zig");152 _ = @import("behavior/bugs/6781.zig");
136 _ = @import("behavior/bugs/920.zig");153 _ = @import("behavior/bugs/7003.zig");
137 _ = @import("behavior/bugs/1120.zig");154 _ = @import("behavior/bugs/7027.zig");
138 _ = @import("behavior/bugs/1421.zig");155 _ = @import("behavior/bugs/7047.zig");
139 _ = @import("behavior/bugs/1607.zig");156 _ = @import("behavior/bugs/10147.zig");
140 _ = @import("behavior/bugs/1851.zig");157 _ = @import("behavior/const_slice_child.zig");
141 _ = @import("behavior/bugs/2114.zig");158 _ = @import("behavior/export_self_referential_type_info.zig");
142 _ = @import("behavior/bugs/3384.zig");159 _ = @import("behavior/field_parent_ptr.zig");
143 _ = @import("behavior/bugs/3742.zig");160 _ = @import("behavior/misc.zig");
144 _ = @import("behavior/bugs/3779.zig");161 _ = @import("behavior/muladd.zig");
145 _ = @import("behavior/bugs/4328.zig");162 _ = @import("behavior/select.zig");
146 _ = @import("behavior/bugs/5398.zig");163 _ = @import("behavior/shuffle.zig");
147 _ = @import("behavior/bugs/5413.zig");164 _ = @import("behavior/struct_contains_null_ptr_itself.zig");
148 _ = @import("behavior/bugs/5474.zig");165 _ = @import("behavior/struct_contains_slice_of_itself.zig");
149 _ = @import("behavior/bugs/5487.zig");166 _ = @import("behavior/switch_prong_err_enum.zig");
150 _ = @import("behavior/bugs/6456.zig");167 _ = @import("behavior/switch_prong_implicit_cast.zig");
151 _ = @import("behavior/bugs/6781.zig");168 _ = @import("behavior/typename.zig");
152 _ = @import("behavior/bugs/7003.zig");169 _ = @import("behavior/union_with_members.zig");
153 _ = @import("behavior/bugs/7027.zig");170 _ = @import("behavior/vector.zig");
154 _ = @import("behavior/bugs/7047.zig");171 if (builtin.target.cpu.arch == .wasm32) {
155 _ = @import("behavior/bugs/10147.zig");172 _ = @import("behavior/wasm.zig");
156 _ = @import("behavior/const_slice_child.zig");
157 _ = @import("behavior/export_self_referential_type_info.zig");
158 _ = @import("behavior/field_parent_ptr.zig");
159 _ = @import("behavior/misc.zig");
160 _ = @import("behavior/muladd.zig");
161 _ = @import("behavior/select.zig");
162 _ = @import("behavior/shuffle.zig");
163 _ = @import("behavior/struct_contains_null_ptr_itself.zig");
164 _ = @import("behavior/struct_contains_slice_of_itself.zig");
165 _ = @import("behavior/switch_prong_err_enum.zig");
166 _ = @import("behavior/switch_prong_implicit_cast.zig");
167 _ = @import("behavior/typename.zig");
168 _ = @import("behavior/union_with_members.zig");
169 _ = @import("behavior/vector.zig");
170 if (builtin.target.cpu.arch == .wasm32) {
171 _ = @import("behavior/wasm.zig");
172 }
173 }173 }
174 }174 }
175 }175 }
test/behavior/align.zig-6
...@@ -180,8 +180,6 @@ fn noop4() align(4) void {}...@@ -180,8 +180,6 @@ fn noop4() align(4) void {}
180test "function alignment" {180test "function alignment" {
181 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;181 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
182 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;182 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
183 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
184 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
185 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;183 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
186184
187 // function alignment is a compile error on wasm32/wasm64185 // function alignment is a compile error on wasm32/wasm64
...@@ -199,7 +197,6 @@ test "implicitly decreasing fn alignment" {...@@ -199,7 +197,6 @@ test "implicitly decreasing fn alignment" {
199 if (builtin.zig_backend == .stage1) return error.SkipZigTest;197 if (builtin.zig_backend == .stage1) return error.SkipZigTest;
200 if (builtin.zig_backend == .stage2_llvm) return error.SkipZigTest;198 if (builtin.zig_backend == .stage2_llvm) return error.SkipZigTest;
201 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;199 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
202 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
203 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;200 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
204 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;201 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
205202
...@@ -226,8 +223,6 @@ test "@alignCast functions" {...@@ -226,8 +223,6 @@ test "@alignCast functions" {
226 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;223 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
227 if (builtin.zig_backend == .stage1) return error.SkipZigTest;224 if (builtin.zig_backend == .stage1) return error.SkipZigTest;
228 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;225 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
229 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
230 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
231 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;226 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
232227
233 // function alignment is a compile error on wasm32/wasm64228 // function alignment is a compile error on wasm32/wasm64
...@@ -250,7 +245,6 @@ test "generic function with align param" {...@@ -250,7 +245,6 @@ test "generic function with align param" {
250 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;245 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
251 if (builtin.zig_backend == .stage2_llvm) return error.SkipZigTest;246 if (builtin.zig_backend == .stage2_llvm) return error.SkipZigTest;
252 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;247 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
253 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
254 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;248 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
255 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;249 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
256250
test/behavior/array.zig+6-4
...@@ -49,7 +49,7 @@ fn getArrayLen(a: []const u32) usize {...@@ -49,7 +49,7 @@ fn getArrayLen(a: []const u32) usize {
4949
50test "array init with mult" {50test "array init with mult" {
51 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;51 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
52 if (builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_arm) return error.SkipZigTest;52 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
5353
54 const a = 'a';54 const a = 'a';
55 var i: [8]u8 = [2]u8{ a, 'b' } ** 4;55 var i: [8]u8 = [2]u8{ a, 'b' } ** 4;
...@@ -112,7 +112,7 @@ test "array len field" {...@@ -112,7 +112,7 @@ test "array len field" {
112112
113test "array with sentinels" {113test "array with sentinels" {
114 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;114 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
115 if (builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_arm) return error.SkipZigTest;115 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
116116
117 const S = struct {117 const S = struct {
118 fn doTheTest(is_ct: bool) !void {118 fn doTheTest(is_ct: bool) !void {
...@@ -179,7 +179,8 @@ fn plusOne(x: u32) u32 {...@@ -179,7 +179,8 @@ fn plusOne(x: u32) u32 {
179179
180test "single-item pointer to array indexing and slicing" {180test "single-item pointer to array indexing and slicing" {
181 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;181 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
182 if (builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_arm) return error.SkipZigTest;182 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
183 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
183184
184 try testSingleItemPtrArrayIndexSlice();185 try testSingleItemPtrArrayIndexSlice();
185 comptime try testSingleItemPtrArrayIndexSlice();186 comptime try testSingleItemPtrArrayIndexSlice();
...@@ -205,7 +206,8 @@ fn doSomeMangling(array: *[4]u8) void {...@@ -205,7 +206,8 @@ fn doSomeMangling(array: *[4]u8) void {
205206
206test "implicit cast zero sized array ptr to slice" {207test "implicit cast zero sized array ptr to slice" {
207 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;208 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
208 if (builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_arm) return error.SkipZigTest;209 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
210 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
209211
210 {212 {
211 var b = "".*;213 var b = "".*;
test/behavior/basic.zig-6
...@@ -117,7 +117,6 @@ fn first4KeysOfHomeRow() []const u8 {...@@ -117,7 +117,6 @@ fn first4KeysOfHomeRow() []const u8 {
117test "return string from function" {117test "return string from function" {
118 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;118 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
119 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;119 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
120 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
121120
122 try expect(mem.eql(u8, first4KeysOfHomeRow(), "aoeu"));121 try expect(mem.eql(u8, first4KeysOfHomeRow(), "aoeu"));
123}122}
...@@ -231,7 +230,6 @@ test "compile time global reinterpret" {...@@ -231,7 +230,6 @@ test "compile time global reinterpret" {
231230
232test "cast undefined" {231test "cast undefined" {
233 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;232 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
234 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
235233
236 const array: [100]u8 = undefined;234 const array: [100]u8 = undefined;
237 const slice = @as([]const u8, &array);235 const slice = @as([]const u8, &array);
...@@ -303,7 +301,6 @@ test "call function pointer in struct" {...@@ -303,7 +301,6 @@ test "call function pointer in struct" {
303 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;301 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
304 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;302 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
305 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;303 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
306
307 if (builtin.zig_backend == .stage1) return error.SkipZigTest;304 if (builtin.zig_backend == .stage1) return error.SkipZigTest;
308305
309 try expect(mem.eql(u8, f3(true), "a"));306 try expect(mem.eql(u8, f3(true), "a"));
...@@ -382,7 +379,6 @@ fn testMemcpyMemset() !void {...@@ -382,7 +379,6 @@ fn testMemcpyMemset() !void {
382test "variable is allowed to be a pointer to an opaque type" {379test "variable is allowed to be a pointer to an opaque type" {
383 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;380 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
384 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;381 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
385 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
386 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO382 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
387383
388 var x: i32 = 1234;384 var x: i32 = 1234;
...@@ -425,7 +421,6 @@ test "array 2D const double ptr" {...@@ -425,7 +421,6 @@ test "array 2D const double ptr" {
425 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;421 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
426 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;422 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
427 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;423 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
428
429 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO424 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
430425
431 const rect_2d_vertexes = [_][1]f32{426 const rect_2d_vertexes = [_][1]f32{
...@@ -476,7 +471,6 @@ fn testArray2DConstDoublePtr(ptr: *const f32) !void {...@@ -476,7 +471,6 @@ fn testArray2DConstDoublePtr(ptr: *const f32) !void {
476test "double implicit cast in same expression" {471test "double implicit cast in same expression" {
477 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;472 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
478 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;473 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
479 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
480474
481 var x = @as(i32, @as(u16, nine()));475 var x = @as(i32, @as(u16, nine()));
482 try expect(x == 9);476 try expect(x == 9);
test/behavior/bugs/1076.zig+5
...@@ -1,8 +1,13 @@...@@ -1,8 +1,13 @@
1const std = @import("std");1const std = @import("std");
2const builtin = @import("builtin");
2const mem = std.mem;3const mem = std.mem;
3const expect = std.testing.expect;4const expect = std.testing.expect;
45
5test "comptime code should not modify constant data" {6test "comptime code should not modify constant data" {
7 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
8 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
9 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
10
6 try testCastPtrOfArrayToSliceAndPtr();11 try testCastPtrOfArrayToSliceAndPtr();
7 comptime try testCastPtrOfArrayToSliceAndPtr();12 comptime try testCastPtrOfArrayToSliceAndPtr();
8}13}
test/behavior/bugs/1442.zig+3
...@@ -1,4 +1,5 @@...@@ -1,4 +1,5 @@
1const std = @import("std");1const std = @import("std");
2const builtin = @import("builtin");
23
3const Union = union(enum) {4const Union = union(enum) {
4 Text: []const u8,5 Text: []const u8,
...@@ -6,6 +7,8 @@ const Union = union(enum) {...@@ -6,6 +7,8 @@ const Union = union(enum) {
6};7};
78
8test "const error union field alignment" {9test "const error union field alignment" {
10 if (builtin.zig_backend != .stage1) return error.SkipZigTest;
11
9 var union_or_err: anyerror!Union = Union{ .Color = 1234 };12 var union_or_err: anyerror!Union = Union{ .Color = 1234 };
10 try std.testing.expect((union_or_err catch unreachable).Color == 1234);13 try std.testing.expect((union_or_err catch unreachable).Color == 1234);
11}14}
test/behavior/bugs/2692.zig+5
...@@ -1,8 +1,13 @@...@@ -1,8 +1,13 @@
1const builtin = @import("builtin");
2
1fn foo(a: []u8) void {3fn foo(a: []u8) void {
2 _ = a;4 _ = a;
3}5}
46
5test "address of 0 length array" {7test "address of 0 length array" {
8 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
9 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
10
6 var pt: [0]u8 = undefined;11 var pt: [0]u8 = undefined;
7 foo(&pt);12 foo(&pt);
8}13}
test/behavior/bugs/2889.zig+5
...@@ -1,4 +1,5 @@...@@ -1,4 +1,5 @@
1const std = @import("std");1const std = @import("std");
2const builtin = @import("builtin");
23
3const source = "A-";4const source = "A-";
45
...@@ -26,6 +27,10 @@ fn parseNote() ?i32 {...@@ -26,6 +27,10 @@ fn parseNote() ?i32 {
26}27}
2728
28test "fixed" {29test "fixed" {
30 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
31 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
32 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
33
29 const result = parseNote();34 const result = parseNote();
30 try std.testing.expect(result.? == 9);35 try std.testing.expect(result.? == 9);
31}36}
test/behavior/bugs/3046.zig+5-1
...@@ -1,4 +1,5 @@...@@ -1,4 +1,5 @@
1const std = @import("std");1const std = @import("std");
2const builtin = @import("builtin");
2const expect = std.testing.expect;3const expect = std.testing.expect;
34
4const SomeStruct = struct {5const SomeStruct = struct {
...@@ -12,7 +13,10 @@ fn couldFail() anyerror!i32 {...@@ -12,7 +13,10 @@ fn couldFail() anyerror!i32 {
12var some_struct: SomeStruct = undefined;13var some_struct: SomeStruct = undefined;
1314
14test "fixed" {15test "fixed" {
15 if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest; // TODO16 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
17 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
18 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
19 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
1620
17 some_struct = SomeStruct{21 some_struct = SomeStruct{
18 .field = couldFail() catch @as(i32, 0),22 .field = couldFail() catch @as(i32, 0),
test/behavior/bugs/3586.zig+5
...@@ -1,3 +1,5 @@...@@ -1,3 +1,5 @@
1const builtin = @import("builtin");
2
1const NoteParams = struct {};3const NoteParams = struct {};
24
3const Container = struct {5const Container = struct {
...@@ -5,6 +7,9 @@ const Container = struct {...@@ -5,6 +7,9 @@ const Container = struct {
5};7};
68
7test "fixed" {9test "fixed" {
10 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
11 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
12
8 var ctr = Container{13 var ctr = Container{
9 .params = NoteParams{},14 .params = NoteParams{},
10 };15 };
test/behavior/bugs/4560.zig+4
...@@ -1,6 +1,10 @@...@@ -1,6 +1,10 @@
1const std = @import("std");1const std = @import("std");
2const builtin = @import("builtin");
23
3test "fixed" {4test "fixed" {
5 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
6 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
7
4 var s: S = .{8 var s: S = .{
5 .a = 1,9 .a = 1,
6 .b = .{10 .b = .{
test/behavior/bugs/4954.zig+6
...@@ -1,8 +1,14 @@...@@ -1,8 +1,14 @@
1const builtin = @import("builtin");
2
1fn f(buf: []u8) void {3fn f(buf: []u8) void {
2 _ = &buf[@sizeOf(u32)];4 _ = &buf[@sizeOf(u32)];
3}5}
46
5test "crash" {7test "crash" {
8 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
9 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
10 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
11
6 var buf: [4096]u8 = undefined;12 var buf: [4096]u8 = undefined;
7 f(&buf);13 f(&buf);
8}14}
test/behavior/bugs/624.zig+4
...@@ -1,4 +1,5 @@...@@ -1,4 +1,5 @@
1const std = @import("std");1const std = @import("std");
2const builtin = @import("builtin");
2const expect = std.testing.expect;3const expect = std.testing.expect;
34
4const TestContext = struct {5const TestContext = struct {
...@@ -19,6 +20,9 @@ fn MemoryPool(comptime T: type) type {...@@ -19,6 +20,9 @@ fn MemoryPool(comptime T: type) type {
19}20}
2021
21test "foo" {22test "foo" {
23 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
24 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
25
22 var allocator = ContextAllocator{ .n = 10 };26 var allocator = ContextAllocator{ .n = 10 };
23 try expect(allocator.n == 10);27 try expect(allocator.n == 10);
24}28}
test/behavior/bugs/704.zig+5
...@@ -1,9 +1,14 @@...@@ -1,9 +1,14 @@
1const builtin = @import("builtin");
2
1const xxx = struct {3const xxx = struct {
2 pub fn bar(self: *xxx) void {4 pub fn bar(self: *xxx) void {
3 _ = self;5 _ = self;
4 }6 }
5};7};
6test "bug 704" {8test "bug 704" {
9 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
10 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
11
7 var x: xxx = undefined;12 var x: xxx = undefined;
8 x.bar();13 x.bar();
9}14}
test/behavior/byval_arg_var.zig+5
...@@ -1,8 +1,13 @@...@@ -1,8 +1,13 @@
1const std = @import("std");1const std = @import("std");
2const builtin = @import("builtin");
23
3var result: []const u8 = "wrong";4var result: []const u8 = "wrong";
45
5test "pass string literal byvalue to a generic var param" {6test "pass string literal byvalue to a generic var param" {
7 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
8 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
9 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
10
6 start();11 start();
7 blowUpStack(10);12 blowUpStack(10);
813
test/behavior/defer.zig+13
...@@ -5,6 +5,9 @@ const expectEqual = std.testing.expectEqual;...@@ -5,6 +5,9 @@ const expectEqual = std.testing.expectEqual;
5const expectError = std.testing.expectError;5const expectError = std.testing.expectError;
66
7test "break and continue inside loop inside defer expression" {7test "break and continue inside loop inside defer expression" {
8 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
9 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
10
8 testBreakContInDefer(10);11 testBreakContInDefer(10);
9 comptime testBreakContInDefer(10);12 comptime testBreakContInDefer(10);
10}13}
...@@ -21,6 +24,9 @@ fn testBreakContInDefer(x: usize) void {...@@ -21,6 +24,9 @@ fn testBreakContInDefer(x: usize) void {
21}24}
2225
23test "defer and labeled break" {26test "defer and labeled break" {
27 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
28 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
29
24 var i = @as(usize, 0);30 var i = @as(usize, 0);
2531
26 blk: {32 blk: {
...@@ -32,6 +38,9 @@ test "defer and labeled break" {...@@ -32,6 +38,9 @@ test "defer and labeled break" {
32}38}
3339
34test "errdefer does not apply to fn inside fn" {40test "errdefer does not apply to fn inside fn" {
41 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
42 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
43
35 if (testNestedFnErrDefer()) |_| @panic("expected error") else |e| try expect(e == error.Bad);44 if (testNestedFnErrDefer()) |_| @panic("expected error") else |e| try expect(e == error.Bad);
36}45}
3746
...@@ -47,6 +56,10 @@ fn testNestedFnErrDefer() anyerror!void {...@@ -47,6 +56,10 @@ fn testNestedFnErrDefer() anyerror!void {
47}56}
4857
49test "return variable while defer expression in scope to modify it" {58test "return variable while defer expression in scope to modify it" {
59 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
60 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
61 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
62
50 const S = struct {63 const S = struct {
51 fn doTheTest() !void {64 fn doTheTest() !void {
52 try expect(notNull().? == 1);65 try expect(notNull().? == 1);
test/behavior/enum.zig+110
...@@ -11,6 +11,9 @@ fn shouldEqual(n: Number, expected: u3) !void {...@@ -11,6 +11,9 @@ fn shouldEqual(n: Number, expected: u3) !void {
11}11}
1212
13test "enum to int" {13test "enum to int" {
14 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
15 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
16
14 try shouldEqual(Number.Zero, 0);17 try shouldEqual(Number.Zero, 0);
15 try shouldEqual(Number.One, 1);18 try shouldEqual(Number.One, 1);
16 try shouldEqual(Number.Two, 2);19 try shouldEqual(Number.Two, 2);
...@@ -24,6 +27,9 @@ fn testIntToEnumEval(x: i32) !void {...@@ -24,6 +27,9 @@ fn testIntToEnumEval(x: i32) !void {
24const IntToEnumNumber = enum { Zero, One, Two, Three, Four };27const IntToEnumNumber = enum { Zero, One, Two, Three, Four };
2528
26test "int to enum" {29test "int to enum" {
30 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
31 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
32
27 try testIntToEnumEval(3);33 try testIntToEnumEval(3);
28}34}
2935
...@@ -553,6 +559,9 @@ const ValueCount257 = enum {...@@ -553,6 +559,9 @@ const ValueCount257 = enum {
553};559};
554560
555test "enum sizes" {561test "enum sizes" {
562 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
563 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
564
556 comptime {565 comptime {
557 try expect(@sizeOf(ValueCount1) == 0);566 try expect(@sizeOf(ValueCount1) == 0);
558 try expect(@sizeOf(ValueCount2) == 1);567 try expect(@sizeOf(ValueCount2) == 1);
...@@ -562,6 +571,9 @@ test "enum sizes" {...@@ -562,6 +571,9 @@ test "enum sizes" {
562}571}
563572
564test "enum literal equality" {573test "enum literal equality" {
574 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
575 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
576
565 const x = .hi;577 const x = .hi;
566 const y = .ok;578 const y = .ok;
567 const z = .hi;579 const z = .hi;
...@@ -571,6 +583,9 @@ test "enum literal equality" {...@@ -571,6 +583,9 @@ test "enum literal equality" {
571}583}
572584
573test "enum literal cast to enum" {585test "enum literal cast to enum" {
586 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
587 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
588
574 const Color = enum { Auto, Off, On };589 const Color = enum { Auto, Off, On };
575590
576 var color1: Color = .Auto;591 var color1: Color = .Auto;
...@@ -579,6 +594,9 @@ test "enum literal cast to enum" {...@@ -579,6 +594,9 @@ test "enum literal cast to enum" {
579}594}
580595
581test "peer type resolution with enum literal" {596test "peer type resolution with enum literal" {
597 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
598 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
599
582 const Items = enum { one, two };600 const Items = enum { one, two };
583601
584 try expect(Items.two == .two);602 try expect(Items.two == .two);
...@@ -603,11 +621,19 @@ fn testEnumWithSpecifiedTagValues(x: MultipleChoice) !void {...@@ -603,11 +621,19 @@ fn testEnumWithSpecifiedTagValues(x: MultipleChoice) !void {
603}621}
604622
605test "enum with specified tag values" {623test "enum with specified tag values" {
624 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
625 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
626 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
627
606 try testEnumWithSpecifiedTagValues(MultipleChoice.C);628 try testEnumWithSpecifiedTagValues(MultipleChoice.C);
607 comptime try testEnumWithSpecifiedTagValues(MultipleChoice.C);629 comptime try testEnumWithSpecifiedTagValues(MultipleChoice.C);
608}630}
609631
610test "non-exhaustive enum" {632test "non-exhaustive enum" {
633 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
634 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
635 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
636
611 const S = struct {637 const S = struct {
612 const E = enum(u8) { a, b, _ };638 const E = enum(u8) { a, b, _ };
613639
...@@ -649,6 +675,9 @@ test "non-exhaustive enum" {...@@ -649,6 +675,9 @@ test "non-exhaustive enum" {
649}675}
650676
651test "empty non-exhaustive enum" {677test "empty non-exhaustive enum" {
678 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
679 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
680
652 const S = struct {681 const S = struct {
653 const E = enum(u8) { _ };682 const E = enum(u8) { _ };
654683
...@@ -668,6 +697,10 @@ test "empty non-exhaustive enum" {...@@ -668,6 +697,10 @@ test "empty non-exhaustive enum" {
668}697}
669698
670test "single field non-exhaustive enum" {699test "single field non-exhaustive enum" {
700 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
701 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
702 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
703
671 const S = struct {704 const S = struct {
672 const E = enum(u8) { a, _ };705 const E = enum(u8) { a, _ };
673 fn doTheTest(y: u8) !void {706 fn doTheTest(y: u8) !void {
...@@ -708,6 +741,9 @@ const EnumWithTagValues = enum(u4) {...@@ -708,6 +741,9 @@ const EnumWithTagValues = enum(u4) {
708 D = 1 << 3,741 D = 1 << 3,
709};742};
710test "enum with tag values don't require parens" {743test "enum with tag values don't require parens" {
744 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
745 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
746
711 try expect(@enumToInt(EnumWithTagValues.C) == 0b0100);747 try expect(@enumToInt(EnumWithTagValues.C) == 0b0100);
712}748}
713749
...@@ -724,11 +760,18 @@ const MultipleChoice2 = enum(u32) {...@@ -724,11 +760,18 @@ const MultipleChoice2 = enum(u32) {
724};760};
725761
726test "cast integer literal to enum" {762test "cast integer literal to enum" {
763 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
764 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
765
727 try expect(@intToEnum(MultipleChoice2, 0) == MultipleChoice2.Unspecified1);766 try expect(@intToEnum(MultipleChoice2, 0) == MultipleChoice2.Unspecified1);
728 try expect(@intToEnum(MultipleChoice2, 40) == MultipleChoice2.B);767 try expect(@intToEnum(MultipleChoice2, 40) == MultipleChoice2.B);
729}768}
730769
731test "enum with specified and unspecified tag values" {770test "enum with specified and unspecified tag values" {
771 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
772 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
773 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
774
732 try testEnumWithSpecifiedAndUnspecifiedTagValues(MultipleChoice2.D);775 try testEnumWithSpecifiedAndUnspecifiedTagValues(MultipleChoice2.D);
733 comptime try testEnumWithSpecifiedAndUnspecifiedTagValues(MultipleChoice2.D);776 comptime try testEnumWithSpecifiedAndUnspecifiedTagValues(MultipleChoice2.D);
734}777}
...@@ -752,6 +795,9 @@ const Small2 = enum(u2) { One, Two };...@@ -752,6 +795,9 @@ const Small2 = enum(u2) { One, Two };
752const Small = enum(u2) { One, Two, Three, Four };795const Small = enum(u2) { One, Two, Three, Four };
753796
754test "set enum tag type" {797test "set enum tag type" {
798 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
799 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
800
755 {801 {
756 var x = Small.One;802 var x = Small.One;
757 x = Small.Two;803 x = Small.Two;
...@@ -765,6 +811,9 @@ test "set enum tag type" {...@@ -765,6 +811,9 @@ test "set enum tag type" {
765}811}
766812
767test "casting enum to its tag type" {813test "casting enum to its tag type" {
814 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
815 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
816
768 try testCastEnumTag(Small2.Two);817 try testCastEnumTag(Small2.Two);
769 comptime try testCastEnumTag(Small2.Two);818 comptime try testCastEnumTag(Small2.Two);
770}819}
...@@ -774,6 +823,9 @@ fn testCastEnumTag(value: Small2) !void {...@@ -774,6 +823,9 @@ fn testCastEnumTag(value: Small2) !void {
774}823}
775824
776test "enum with 1 field but explicit tag type should still have the tag type" {825test "enum with 1 field but explicit tag type should still have the tag type" {
826 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
827 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
828
777 const Enum = enum(u8) {829 const Enum = enum(u8) {
778 B = 2,830 B = 2,
779 };831 };
...@@ -781,6 +833,9 @@ test "enum with 1 field but explicit tag type should still have the tag type" {...@@ -781,6 +833,9 @@ test "enum with 1 field but explicit tag type should still have the tag type" {
781}833}
782834
783test "signed integer as enum tag" {835test "signed integer as enum tag" {
836 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
837 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
838
784 const SignedEnum = enum(i2) {839 const SignedEnum = enum(i2) {
785 A0 = -1,840 A0 = -1,
786 A1 = 0,841 A1 = 0,
...@@ -793,6 +848,9 @@ test "signed integer as enum tag" {...@@ -793,6 +848,9 @@ test "signed integer as enum tag" {
793}848}
794849
795test "enum with one member and custom tag type" {850test "enum with one member and custom tag type" {
851 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
852 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
853
796 const E = enum(u2) {854 const E = enum(u2) {
797 One,855 One,
798 };856 };
...@@ -804,6 +862,9 @@ test "enum with one member and custom tag type" {...@@ -804,6 +862,9 @@ test "enum with one member and custom tag type" {
804}862}
805863
806test "enum with one member and u1 tag type @enumToInt" {864test "enum with one member and u1 tag type @enumToInt" {
865 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
866 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
867
807 const Enum = enum(u1) {868 const Enum = enum(u1) {
808 Test,869 Test,
809 };870 };
...@@ -811,6 +872,9 @@ test "enum with one member and u1 tag type @enumToInt" {...@@ -811,6 +872,9 @@ test "enum with one member and u1 tag type @enumToInt" {
811}872}
812873
813test "enum with comptime_int tag type" {874test "enum with comptime_int tag type" {
875 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
876 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
877
814 const Enum = enum(comptime_int) {878 const Enum = enum(comptime_int) {
815 One = 3,879 One = 3,
816 Two = 2,880 Two = 2,
...@@ -820,6 +884,9 @@ test "enum with comptime_int tag type" {...@@ -820,6 +884,9 @@ test "enum with comptime_int tag type" {
820}884}
821885
822test "enum with one member default to u0 tag type" {886test "enum with one member default to u0 tag type" {
887 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
888 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
889
823 const E0 = enum { X };890 const E0 = enum { X };
824 comptime try expect(Tag(E0) == u0);891 comptime try expect(Tag(E0) == u0);
825}892}
...@@ -836,11 +903,17 @@ fn doALoopThing(id: EnumWithOneMember) void {...@@ -836,11 +903,17 @@ fn doALoopThing(id: EnumWithOneMember) void {
836}903}
837904
838test "comparison operator on enum with one member is comptime known" {905test "comparison operator on enum with one member is comptime known" {
906 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
907 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
908
839 doALoopThing(EnumWithOneMember.Eof);909 doALoopThing(EnumWithOneMember.Eof);
840}910}
841911
842const State = enum { Start };912const State = enum { Start };
843test "switch on enum with one member is comptime known" {913test "switch on enum with one member is comptime known" {
914 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
915 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
916
844 var state = State.Start;917 var state = State.Start;
845 switch (state) {918 switch (state) {
846 State.Start => return,919 State.Start => return,
...@@ -849,6 +922,9 @@ test "switch on enum with one member is comptime known" {...@@ -849,6 +922,9 @@ test "switch on enum with one member is comptime known" {
849}922}
850923
851test "method call on an enum" {924test "method call on an enum" {
925 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
926 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
927
852 const S = struct {928 const S = struct {
853 const E = enum {929 const E = enum {
854 one,930 one,
...@@ -885,6 +961,10 @@ test "enum value allocation" {...@@ -885,6 +961,10 @@ test "enum value allocation" {
885}961}
886962
887test "enum literal casting to tagged union" {963test "enum literal casting to tagged union" {
964 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
965 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
966 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
967
888 const Arch = union(enum) {968 const Arch = union(enum) {
889 x86_64,969 x86_64,
890 arm: Arm32,970 arm: Arm32,
...@@ -930,6 +1010,11 @@ test "exporting enum type and value" {...@@ -930,6 +1010,11 @@ test "exporting enum type and value" {
930}1010}
9311011
932test "constant enum initialization with differing sizes" {1012test "constant enum initialization with differing sizes" {
1013 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1014 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
1015 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
1016 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
1017
933 try test3_1(test3_foo);1018 try test3_1(test3_foo);
934 try test3_2(test3_bar);1019 try test3_2(test3_bar);
935}1020}
...@@ -970,6 +1055,9 @@ fn test3_2(f: Test3Foo) !void {...@@ -970,6 +1055,9 @@ fn test3_2(f: Test3Foo) !void {
970test "@tagName" {1055test "@tagName" {
971 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO1056 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
972 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO1057 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
1058 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1059 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
1060 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
9731061
974 try expect(mem.eql(u8, testEnumTagNameBare(BareNumber.Three), "Three"));1062 try expect(mem.eql(u8, testEnumTagNameBare(BareNumber.Three), "Three"));
975 comptime try expect(mem.eql(u8, testEnumTagNameBare(BareNumber.Three), "Three"));1063 comptime try expect(mem.eql(u8, testEnumTagNameBare(BareNumber.Three), "Three"));
...@@ -984,6 +1072,9 @@ const BareNumber = enum { One, Two, Three };...@@ -984,6 +1072,9 @@ const BareNumber = enum { One, Two, Three };
984test "@tagName non-exhaustive enum" {1072test "@tagName non-exhaustive enum" {
985 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO1073 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
986 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO1074 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
1075 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1076 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
1077 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
9871078
988 try expect(mem.eql(u8, testEnumTagNameBare(NonExhaustive.B), "B"));1079 try expect(mem.eql(u8, testEnumTagNameBare(NonExhaustive.B), "B"));
989 comptime try expect(mem.eql(u8, testEnumTagNameBare(NonExhaustive.B), "B"));1080 comptime try expect(mem.eql(u8, testEnumTagNameBare(NonExhaustive.B), "B"));
...@@ -993,6 +1084,9 @@ const NonExhaustive = enum(u8) { A, B, _ };...@@ -993,6 +1084,9 @@ const NonExhaustive = enum(u8) { A, B, _ };
993test "@tagName is null-terminated" {1084test "@tagName is null-terminated" {
994 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO1085 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
995 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO1086 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
1087 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1088 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
1089 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
9961090
997 const S = struct {1091 const S = struct {
998 fn doTheTest(n: BareNumber) !void {1092 fn doTheTest(n: BareNumber) !void {
...@@ -1006,6 +1100,9 @@ test "@tagName is null-terminated" {...@@ -1006,6 +1100,9 @@ test "@tagName is null-terminated" {
1006test "tag name with assigned enum values" {1100test "tag name with assigned enum values" {
1007 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO1101 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
1008 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO1102 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
1103 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1104 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
1105 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
10091106
1010 const LocalFoo = enum(u8) {1107 const LocalFoo = enum(u8) {
1011 A = 1,1108 A = 1,
...@@ -1016,11 +1113,18 @@ test "tag name with assigned enum values" {...@@ -1016,11 +1113,18 @@ test "tag name with assigned enum values" {
1016}1113}
10171114
1018test "@tagName on enum literals" {1115test "@tagName on enum literals" {
1116 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
1117 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
1118
1019 try expect(mem.eql(u8, @tagName(.FooBar), "FooBar"));1119 try expect(mem.eql(u8, @tagName(.FooBar), "FooBar"));
1020 comptime try expect(mem.eql(u8, @tagName(.FooBar), "FooBar"));1120 comptime try expect(mem.eql(u8, @tagName(.FooBar), "FooBar"));
1021}1121}
10221122
1023test "enum literal casting to optional" {1123test "enum literal casting to optional" {
1124 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1125 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
1126 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
1127
1024 var bar: ?Bar = undefined;1128 var bar: ?Bar = undefined;
1025 bar = .B;1129 bar = .B;
10261130
...@@ -1045,6 +1149,9 @@ const bit_field_1 = BitFieldOfEnums{...@@ -1045,6 +1149,9 @@ const bit_field_1 = BitFieldOfEnums{
10451149
1046test "bit field access with enum fields" {1150test "bit field access with enum fields" {
1047 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO1151 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
1152 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1153 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
1154 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
10481155
1049 var data = bit_field_1;1156 var data = bit_field_1;
1050 try expect(getA(&data) == A.Two);1157 try expect(getA(&data) == A.Two);
...@@ -1073,6 +1180,9 @@ fn getC(data: *const BitFieldOfEnums) C {...@@ -1073,6 +1180,9 @@ fn getC(data: *const BitFieldOfEnums) C {
1073}1180}
10741181
1075test "enum literal in array literal" {1182test "enum literal in array literal" {
1183 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
1184 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
1185
1076 const Items = enum { one, two };1186 const Items = enum { one, two };
1077 const array = [_]Items{ .one, .two };1187 const array = [_]Items{ .one, .two };
10781188
test/behavior/error.zig+48
...@@ -6,12 +6,18 @@ const expectEqual = std.testing.expectEqual;...@@ -6,12 +6,18 @@ const expectEqual = std.testing.expectEqual;
6const mem = std.mem;6const mem = std.mem;
77
8test "error values" {8test "error values" {
9 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
10 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
11
9 const a = @errorToInt(error.err1);12 const a = @errorToInt(error.err1);
10 const b = @errorToInt(error.err2);13 const b = @errorToInt(error.err2);
11 try expect(a != b);14 try expect(a != b);
12}15}
1316
14test "redefinition of error values allowed" {17test "redefinition of error values allowed" {
18 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
19 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
20
15 shouldBeNotEqual(error.AnError, error.SecondError);21 shouldBeNotEqual(error.AnError, error.SecondError);
16}22}
17fn shouldBeNotEqual(a: anyerror, b: anyerror) void {23fn shouldBeNotEqual(a: anyerror, b: anyerror) void {
...@@ -19,6 +25,10 @@ fn shouldBeNotEqual(a: anyerror, b: anyerror) void {...@@ -19,6 +25,10 @@ fn shouldBeNotEqual(a: anyerror, b: anyerror) void {
19}25}
2026
21test "error binary operator" {27test "error binary operator" {
28 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
29 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
30 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
31
22 const a = errBinaryOperatorG(true) catch 3;32 const a = errBinaryOperatorG(true) catch 3;
23 const b = errBinaryOperatorG(false) catch 3;33 const b = errBinaryOperatorG(false) catch 3;
24 try expect(a == 3);34 try expect(a == 3);
...@@ -29,6 +39,9 @@ fn errBinaryOperatorG(x: bool) anyerror!isize {...@@ -29,6 +39,9 @@ fn errBinaryOperatorG(x: bool) anyerror!isize {
29}39}
3040
31test "empty error union" {41test "empty error union" {
42 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
43 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
44
32 const x = error{} || error{};45 const x = error{} || error{};
33 _ = x;46 _ = x;
34}47}
...@@ -48,10 +61,18 @@ pub fn baz() anyerror!i32 {...@@ -48,10 +61,18 @@ pub fn baz() anyerror!i32 {
48}61}
4962
50test "error wrapping" {63test "error wrapping" {
64 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
65 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
66 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
67
51 try expect((baz() catch unreachable) == 15);68 try expect((baz() catch unreachable) == 15);
52}69}
5370
54test "unwrap simple value from error" {71test "unwrap simple value from error" {
72 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
73 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
74 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
75
55 const i = unwrapSimpleValueFromErrorDo() catch unreachable;76 const i = unwrapSimpleValueFromErrorDo() catch unreachable;
56 try expect(i == 13);77 try expect(i == 13);
57}78}
...@@ -60,6 +81,10 @@ fn unwrapSimpleValueFromErrorDo() anyerror!isize {...@@ -60,6 +81,10 @@ fn unwrapSimpleValueFromErrorDo() anyerror!isize {
60}81}
6182
62test "error return in assignment" {83test "error return in assignment" {
84 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
85 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
86 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
87
63 doErrReturnInAssignment() catch unreachable;88 doErrReturnInAssignment() catch unreachable;
64}89}
6590
...@@ -73,12 +98,19 @@ fn makeANonErr() anyerror!i32 {...@@ -73,12 +98,19 @@ fn makeANonErr() anyerror!i32 {
73}98}
7499
75test "syntax: optional operator in front of error union operator" {100test "syntax: optional operator in front of error union operator" {
101 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
102 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
103
76 comptime {104 comptime {
77 try expect(?(anyerror!i32) == ?(anyerror!i32));105 try expect(?(anyerror!i32) == ?(anyerror!i32));
78 }106 }
79}107}
80108
81test "widen cast integer payload of error union function call" {109test "widen cast integer payload of error union function call" {
110 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
111 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
112 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
113
82 const S = struct {114 const S = struct {
83 fn errorable() !u64 {115 fn errorable() !u64 {
84 var x = @as(u64, try number());116 var x = @as(u64, try number());
...@@ -93,12 +125,19 @@ test "widen cast integer payload of error union function call" {...@@ -93,12 +125,19 @@ test "widen cast integer payload of error union function call" {
93}125}
94126
95test "debug info for optional error set" {127test "debug info for optional error set" {
128 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
129 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
130 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
131
96 const SomeError = error{Hello};132 const SomeError = error{Hello};
97 var a_local_variable: ?SomeError = null;133 var a_local_variable: ?SomeError = null;
98 _ = a_local_variable;134 _ = a_local_variable;
99}135}
100136
101test "implicit cast to optional to error union to return result loc" {137test "implicit cast to optional to error union to return result loc" {
138 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
139 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
140
102 const S = struct {141 const S = struct {
103 fn entry() !void {142 fn entry() !void {
104 var x: Foo = undefined;143 var x: Foo = undefined;
...@@ -118,6 +157,9 @@ test "implicit cast to optional to error union to return result loc" {...@@ -118,6 +157,9 @@ test "implicit cast to optional to error union to return result loc" {
118}157}
119158
120test "error: fn returning empty error set can be passed as fn returning any error" {159test "error: fn returning empty error set can be passed as fn returning any error" {
160 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
161 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
162
121 entry();163 entry();
122 comptime entry();164 comptime entry();
123}165}
...@@ -482,6 +524,9 @@ test "error union comptime caching" {...@@ -482,6 +524,9 @@ test "error union comptime caching" {
482test "@errorName" {524test "@errorName" {
483 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO525 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
484 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO526 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
527 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
528 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
529 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
485530
486 try expect(mem.eql(u8, @errorName(error.AnError), "AnError"));531 try expect(mem.eql(u8, @errorName(error.AnError), "AnError"));
487 try expect(mem.eql(u8, @errorName(error.ALongerErrorName), "ALongerErrorName"));532 try expect(mem.eql(u8, @errorName(error.ALongerErrorName), "ALongerErrorName"));
...@@ -494,6 +539,9 @@ fn gimmeItBroke() anyerror {...@@ -494,6 +539,9 @@ fn gimmeItBroke() anyerror {
494test "@errorName sentinel length matches slice length" {539test "@errorName sentinel length matches slice length" {
495 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO540 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
496 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO541 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
542 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
543 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
544 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
497545
498 const name = testBuiltinErrorName(error.FooBar);546 const name = testBuiltinErrorName(error.FooBar);
499 const length: usize = 6;547 const length: usize = 6;
test/behavior/fn.zig+71
...@@ -5,6 +5,9 @@ const expect = testing.expect;...@@ -5,6 +5,9 @@ const expect = testing.expect;
5const expectEqual = testing.expectEqual;5const expectEqual = testing.expectEqual;
66
7test "params" {7test "params" {
8 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
9 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
10
8 try expect(testParamsAdd(22, 11) == 33);11 try expect(testParamsAdd(22, 11) == 33);
9}12}
10fn testParamsAdd(a: i32, b: i32) i32 {13fn testParamsAdd(a: i32, b: i32) i32 {
...@@ -12,6 +15,9 @@ fn testParamsAdd(a: i32, b: i32) i32 {...@@ -12,6 +15,9 @@ fn testParamsAdd(a: i32, b: i32) i32 {
12}15}
1316
14test "local variables" {17test "local variables" {
18 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
19 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
20
15 testLocVars(2);21 testLocVars(2);
16}22}
17fn testLocVars(b: i32) void {23fn testLocVars(b: i32) void {
...@@ -20,6 +26,9 @@ fn testLocVars(b: i32) void {...@@ -20,6 +26,9 @@ fn testLocVars(b: i32) void {
20}26}
2127
22test "mutable local variables" {28test "mutable local variables" {
29 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
30 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
31
23 var zero: i32 = 0;32 var zero: i32 = 0;
24 try expect(zero == 0);33 try expect(zero == 0);
2534
...@@ -31,6 +40,9 @@ test "mutable local variables" {...@@ -31,6 +40,9 @@ test "mutable local variables" {
31}40}
3241
33test "separate block scopes" {42test "separate block scopes" {
43 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
44 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
45
34 {46 {
35 const no_conflict: i32 = 5;47 const no_conflict: i32 = 5;
36 try expect(no_conflict == 5);48 try expect(no_conflict == 5);
...@@ -47,10 +59,16 @@ fn @"weird function name"() i32 {...@@ -47,10 +59,16 @@ fn @"weird function name"() i32 {
47 return 1234;59 return 1234;
48}60}
49test "weird function name" {61test "weird function name" {
62 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
63 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
64
50 try expect(@"weird function name"() == 1234);65 try expect(@"weird function name"() == 1234);
51}66}
5267
53test "assign inline fn to const variable" {68test "assign inline fn to const variable" {
69 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
70 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
71
54 const a = inlineFn;72 const a = inlineFn;
55 a();73 a();
56}74}
...@@ -68,6 +86,9 @@ fn outer(y: u32) *const fn (u32) u32 {...@@ -68,6 +86,9 @@ fn outer(y: u32) *const fn (u32) u32 {
68}86}
6987
70test "return inner function which references comptime variable of outer function" {88test "return inner function which references comptime variable of outer function" {
89 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
90 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
91
71 if (builtin.zig_backend == .stage1) return error.SkipZigTest;92 if (builtin.zig_backend == .stage1) return error.SkipZigTest;
7293
73 var func = outer(10);94 var func = outer(10);
...@@ -76,6 +97,9 @@ test "return inner function which references comptime variable of outer function...@@ -76,6 +97,9 @@ test "return inner function which references comptime variable of outer function
7697
77test "discard the result of a function that returns a struct" {98test "discard the result of a function that returns a struct" {
78 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO99 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
100 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
101 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
102
79 const S = struct {103 const S = struct {
80 fn entry() void {104 fn entry() void {
81 _ = func();105 _ = func();
...@@ -97,6 +121,9 @@ test "discard the result of a function that returns a struct" {...@@ -97,6 +121,9 @@ test "discard the result of a function that returns a struct" {
97test "inline function call that calls optional function pointer, return pointer at callsite interacts correctly with callsite return type" {121test "inline function call that calls optional function pointer, return pointer at callsite interacts correctly with callsite return type" {
98 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO122 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
99 if (builtin.zig_backend == .stage1) return error.SkipZigTest;123 if (builtin.zig_backend == .stage1) return error.SkipZigTest;
124 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
125 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
126 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
100127
101 const S = struct {128 const S = struct {
102 field: u32,129 field: u32,
...@@ -129,6 +156,9 @@ test "inline function call that calls optional function pointer, return pointer...@@ -129,6 +156,9 @@ test "inline function call that calls optional function pointer, return pointer
129}156}
130157
131test "implicit cast function unreachable return" {158test "implicit cast function unreachable return" {
159 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
160 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
161
132 wantsFnWithVoid(fnWithUnreachable);162 wantsFnWithVoid(fnWithUnreachable);
133}163}
134164
...@@ -143,6 +173,8 @@ fn fnWithUnreachable() noreturn {...@@ -143,6 +173,8 @@ fn fnWithUnreachable() noreturn {
143test "extern struct with stdcallcc fn pointer" {173test "extern struct with stdcallcc fn pointer" {
144 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO174 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
145 if (builtin.zig_backend == .stage1) return error.SkipZigTest;175 if (builtin.zig_backend == .stage1) return error.SkipZigTest;
176 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
177 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
146178
147 const S = extern struct {179 const S = extern struct {
148 ptr: *const fn () callconv(if (builtin.target.cpu.arch == .i386) .Stdcall else .C) i32,180 ptr: *const fn () callconv(if (builtin.target.cpu.arch == .i386) .Stdcall else .C) i32,
...@@ -170,10 +202,16 @@ fn fComplexCallconvRet(x: u32) callconv(blk: {...@@ -170,10 +202,16 @@ fn fComplexCallconvRet(x: u32) callconv(blk: {
170}202}
171203
172test "function with complex callconv and return type expressions" {204test "function with complex callconv and return type expressions" {
205 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
206 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
207
173 try expect(fComplexCallconvRet(3).x == 9);208 try expect(fComplexCallconvRet(3).x == 9);
174}209}
175210
176test "pass by non-copying value" {211test "pass by non-copying value" {
212 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
213 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
214
177 try expect(addPointCoords(Point{ .x = 1, .y = 2 }) == 3);215 try expect(addPointCoords(Point{ .x = 1, .y = 2 }) == 3);
178}216}
179217
...@@ -187,6 +225,10 @@ fn addPointCoords(pt: Point) i32 {...@@ -187,6 +225,10 @@ fn addPointCoords(pt: Point) i32 {
187}225}
188226
189test "pass by non-copying value through var arg" {227test "pass by non-copying value through var arg" {
228 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
229 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
230 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
231
190 try expect((try addPointCoordsVar(Point{ .x = 1, .y = 2 })) == 3);232 try expect((try addPointCoordsVar(Point{ .x = 1, .y = 2 })) == 3);
191}233}
192234
...@@ -196,6 +238,9 @@ fn addPointCoordsVar(pt: anytype) !i32 {...@@ -196,6 +238,9 @@ fn addPointCoordsVar(pt: anytype) !i32 {
196}238}
197239
198test "pass by non-copying value as method" {240test "pass by non-copying value as method" {
241 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
242 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
243
199 var pt = Point2{ .x = 1, .y = 2 };244 var pt = Point2{ .x = 1, .y = 2 };
200 try expect(pt.addPointCoords() == 3);245 try expect(pt.addPointCoords() == 3);
201}246}
...@@ -210,6 +255,9 @@ const Point2 = struct {...@@ -210,6 +255,9 @@ const Point2 = struct {
210};255};
211256
212test "pass by non-copying value as method, which is generic" {257test "pass by non-copying value as method, which is generic" {
258 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
259 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
260
213 var pt = Point3{ .x = 1, .y = 2 };261 var pt = Point3{ .x = 1, .y = 2 };
214 try expect(pt.addPointCoords(i32) == 3);262 try expect(pt.addPointCoords(i32) == 3);
215}263}
...@@ -225,6 +273,9 @@ const Point3 = struct {...@@ -225,6 +273,9 @@ const Point3 = struct {
225};273};
226274
227test "pass by non-copying value as method, at comptime" {275test "pass by non-copying value as method, at comptime" {
276 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
277 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
278
228 comptime {279 comptime {
229 var pt = Point2{ .x = 1, .y = 2 };280 var pt = Point2{ .x = 1, .y = 2 };
230 try expect(pt.addPointCoords() == 3);281 try expect(pt.addPointCoords() == 3);
...@@ -232,6 +283,9 @@ test "pass by non-copying value as method, at comptime" {...@@ -232,6 +283,9 @@ test "pass by non-copying value as method, at comptime" {
232}283}
233284
234test "implicit cast fn call result to optional in field result" {285test "implicit cast fn call result to optional in field result" {
286 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
287 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
288
235 const S = struct {289 const S = struct {
236 fn entry() !void {290 fn entry() !void {
237 var x = Foo{291 var x = Foo{
...@@ -255,6 +309,10 @@ test "implicit cast fn call result to optional in field result" {...@@ -255,6 +309,10 @@ test "implicit cast fn call result to optional in field result" {
255}309}
256310
257test "void parameters" {311test "void parameters" {
312 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
313 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
314 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
315
258 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO316 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
259 try voidFun(1, void{}, 2, {});317 try voidFun(1, void{}, 2, {});
260}318}
...@@ -267,6 +325,9 @@ fn voidFun(a: i32, b: void, c: i32, d: void) !void {...@@ -267,6 +325,9 @@ fn voidFun(a: i32, b: void, c: i32, d: void) !void {
267}325}
268326
269test "call function with empty string" {327test "call function with empty string" {
328 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
329 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
330
270 acceptsString("");331 acceptsString("");
271}332}
272333
...@@ -301,6 +362,9 @@ fn fn4() u32 {...@@ -301,6 +362,9 @@ fn fn4() u32 {
301}362}
302363
303test "number literal as an argument" {364test "number literal as an argument" {
365 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
366 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
367
304 try numberLiteralArg(3);368 try numberLiteralArg(3);
305 comptime try numberLiteralArg(3);369 comptime try numberLiteralArg(3);
306}370}
...@@ -311,6 +375,10 @@ fn numberLiteralArg(a: anytype) !void {...@@ -311,6 +375,10 @@ fn numberLiteralArg(a: anytype) !void {
311375
312test "function call with anon list literal" {376test "function call with anon list literal" {
313 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO377 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
378 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
379 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
380 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
381
314 const S = struct {382 const S = struct {
315 fn doTheTest() !void {383 fn doTheTest() !void {
316 try consumeVec(.{ 9, 8, 7 });384 try consumeVec(.{ 9, 8, 7 });
...@@ -327,6 +395,9 @@ test "function call with anon list literal" {...@@ -327,6 +395,9 @@ test "function call with anon list literal" {
327}395}
328396
329test "ability to give comptime types and non comptime types to same parameter" {397test "ability to give comptime types and non comptime types to same parameter" {
398 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
399 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
400
330 const S = struct {401 const S = struct {
331 fn doTheTest() !void {402 fn doTheTest() !void {
332 var x: i32 = 1;403 var x: i32 = 1;
test/behavior/for.zig+23-1
...@@ -5,6 +5,9 @@ const expectEqual = std.testing.expectEqual;...@@ -5,6 +5,9 @@ const expectEqual = std.testing.expectEqual;
5const mem = std.mem;5const mem = std.mem;
66
7test "continue in for loop" {7test "continue in for loop" {
8 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
9 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
10
8 const array = [_]i32{ 1, 2, 3, 4, 5 };11 const array = [_]i32{ 1, 2, 3, 4, 5 };
9 var sum: i32 = 0;12 var sum: i32 = 0;
10 for (array) |x| {13 for (array) |x| {
...@@ -18,6 +21,9 @@ test "continue in for loop" {...@@ -18,6 +21,9 @@ test "continue in for loop" {
18}21}
1922
20test "break from outer for loop" {23test "break from outer for loop" {
24 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
25 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
26
21 try testBreakOuter();27 try testBreakOuter();
22 comptime try testBreakOuter();28 comptime try testBreakOuter();
23}29}
...@@ -35,6 +41,9 @@ fn testBreakOuter() !void {...@@ -35,6 +41,9 @@ fn testBreakOuter() !void {
35}41}
3642
37test "continue outer for loop" {43test "continue outer for loop" {
44 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
45 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
46
38 try testContinueOuter();47 try testContinueOuter();
39 comptime try testContinueOuter();48 comptime try testContinueOuter();
40}49}
...@@ -52,6 +61,9 @@ fn testContinueOuter() !void {...@@ -52,6 +61,9 @@ fn testContinueOuter() !void {
52}61}
5362
54test "ignore lval with underscore (for loop)" {63test "ignore lval with underscore (for loop)" {
64 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
65 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
66
55 for ([_]void{}) |_, i| {67 for ([_]void{}) |_, i| {
56 _ = i;68 _ = i;
57 for ([_]void{}) |_, j| {69 for ([_]void{}) |_, j| {
...@@ -63,7 +75,10 @@ test "ignore lval with underscore (for loop)" {...@@ -63,7 +75,10 @@ test "ignore lval with underscore (for loop)" {
63}75}
6476
65test "basic for loop" {77test "basic for loop" {
66 if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest; // TODO78 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
79 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
80 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
81 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
6782
68 const expected_result = [_]u8{ 9, 8, 7, 6, 0, 1, 2, 3 } ** 3;83 const expected_result = [_]u8{ 9, 8, 7, 6, 0, 1, 2, 3 } ** 3;
6984
...@@ -104,6 +119,10 @@ test "basic for loop" {...@@ -104,6 +119,10 @@ test "basic for loop" {
104}119}
105120
106test "for with null and T peer types and inferred result location type" {121test "for with null and T peer types and inferred result location type" {
122 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
123 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
124 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
125
107 const S = struct {126 const S = struct {
108 fn doTheTest(slice: []const u8) !void {127 fn doTheTest(slice: []const u8) !void {
109 if (for (slice) |item| {128 if (for (slice) |item| {
...@@ -121,6 +140,9 @@ test "for with null and T peer types and inferred result location type" {...@@ -121,6 +140,9 @@ test "for with null and T peer types and inferred result location type" {
121}140}
122141
123test "2 break statements and an else" {142test "2 break statements and an else" {
143 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
144 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
145
124 const S = struct {146 const S = struct {
125 fn entry(t: bool, f: bool) !void {147 fn entry(t: bool, f: bool) !void {
126 var buf: [10]u8 = undefined;148 var buf: [10]u8 = undefined;
test/behavior/generics.zig+41-2
...@@ -5,6 +5,9 @@ const expect = testing.expect;...@@ -5,6 +5,9 @@ const expect = testing.expect;
5const expectEqual = testing.expectEqual;5const expectEqual = testing.expectEqual;
66
7test "one param, explicit comptime" {7test "one param, explicit comptime" {
8 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
9 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
10
8 var x: usize = 0;11 var x: usize = 0;
9 x += checkSize(i32);12 x += checkSize(i32);
10 x += checkSize(bool);13 x += checkSize(bool);
...@@ -17,6 +20,9 @@ fn checkSize(comptime T: type) usize {...@@ -17,6 +20,9 @@ fn checkSize(comptime T: type) usize {
17}20}
1821
19test "simple generic fn" {22test "simple generic fn" {
23 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
24 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
25
20 try expect(max(i32, 3, -1) == 3);26 try expect(max(i32, 3, -1) == 3);
21 try expect(max(u8, 1, 100) == 100);27 try expect(max(u8, 1, 100) == 100);
22 if (builtin.zig_backend == .stage1) {28 if (builtin.zig_backend == .stage1) {
...@@ -37,6 +43,9 @@ fn add(comptime a: i32, b: i32) i32 {...@@ -37,6 +43,9 @@ fn add(comptime a: i32, b: i32) i32 {
3743
38const the_max = max(u32, 1234, 5678);44const the_max = max(u32, 1234, 5678);
39test "compile time generic eval" {45test "compile time generic eval" {
46 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
47 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
48
40 try expect(the_max == 5678);49 try expect(the_max == 5678);
41}50}
4251
...@@ -53,12 +62,20 @@ fn sameButWithFloats(a: f64, b: f64) f64 {...@@ -53,12 +62,20 @@ fn sameButWithFloats(a: f64, b: f64) f64 {
53}62}
5463
55test "fn with comptime args" {64test "fn with comptime args" {
65 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
66 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
67 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
68
56 try expect(gimmeTheBigOne(1234, 5678) == 5678);69 try expect(gimmeTheBigOne(1234, 5678) == 5678);
57 try expect(shouldCallSameInstance(34, 12) == 34);70 try expect(shouldCallSameInstance(34, 12) == 34);
58 try expect(sameButWithFloats(0.43, 0.49) == 0.49);71 try expect(sameButWithFloats(0.43, 0.49) == 0.49);
59}72}
6073
61test "anytype params" {74test "anytype params" {
75 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
76 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
77 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
78
62 try expect(max_i32(12, 34) == 34);79 try expect(max_i32(12, 34) == 34);
63 try expect(max_f64(1.2, 3.4) == 3.4);80 try expect(max_f64(1.2, 3.4) == 3.4);
64 comptime {81 comptime {
...@@ -80,6 +97,10 @@ fn max_f64(a: f64, b: f64) f64 {...@@ -80,6 +97,10 @@ fn max_f64(a: f64, b: f64) f64 {
80}97}
8198
82test "type constructed by comptime function call" {99test "type constructed by comptime function call" {
100 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
101 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
102 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
103
83 var l: SimpleList(10) = undefined;104 var l: SimpleList(10) = undefined;
84 l.array[0] = 10;105 l.array[0] = 10;
85 l.array[1] = 11;106 l.array[1] = 11;
...@@ -99,6 +120,9 @@ fn SimpleList(comptime L: usize) type {...@@ -99,6 +120,9 @@ fn SimpleList(comptime L: usize) type {
99}120}
100121
101test "function with return type type" {122test "function with return type type" {
123 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
124 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
125
102 var list: List(i32) = undefined;126 var list: List(i32) = undefined;
103 var list2: List(i32) = undefined;127 var list2: List(i32) = undefined;
104 list.length = 10;128 list.length = 10;
...@@ -120,6 +144,9 @@ pub fn SmallList(comptime T: type, comptime STATIC_SIZE: usize) type {...@@ -120,6 +144,9 @@ pub fn SmallList(comptime T: type, comptime STATIC_SIZE: usize) type {
120}144}
121145
122test "const decls in struct" {146test "const decls in struct" {
147 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
148 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
149
123 try expect(GenericDataThing(3).count_plus_one == 4);150 try expect(GenericDataThing(3).count_plus_one == 4);
124}151}
125fn GenericDataThing(comptime count: isize) type {152fn GenericDataThing(comptime count: isize) type {
...@@ -129,6 +156,9 @@ fn GenericDataThing(comptime count: isize) type {...@@ -129,6 +156,9 @@ fn GenericDataThing(comptime count: isize) type {
129}156}
130157
131test "use generic param in generic param" {158test "use generic param in generic param" {
159 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
160 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
161
132 try expect(aGenericFn(i32, 3, 4) == 7);162 try expect(aGenericFn(i32, 3, 4) == 7);
133}163}
134fn aGenericFn(comptime T: type, comptime a: T, b: T) T {164fn aGenericFn(comptime T: type, comptime a: T, b: T) T {
...@@ -136,6 +166,9 @@ fn aGenericFn(comptime T: type, comptime a: T, b: T) T {...@@ -136,6 +166,9 @@ fn aGenericFn(comptime T: type, comptime a: T, b: T) T {
136}166}
137167
138test "generic fn with implicit cast" {168test "generic fn with implicit cast" {
169 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
170 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
171
139 try expect(getFirstByte(u8, &[_]u8{13}) == 13);172 try expect(getFirstByte(u8, &[_]u8{13}) == 13);
140 try expect(getFirstByte(u16, &[_]u16{173 try expect(getFirstByte(u16, &[_]u16{
141 0,174 0,
...@@ -150,6 +183,9 @@ fn getFirstByte(comptime T: type, mem: []const T) u8 {...@@ -150,6 +183,9 @@ fn getFirstByte(comptime T: type, mem: []const T) u8 {
150}183}
151184
152test "generic fn keeps non-generic parameter types" {185test "generic fn keeps non-generic parameter types" {
186 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
187 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
188
153 const A = 128;189 const A = 128;
154190
155 const S = struct {191 const S = struct {
...@@ -165,8 +201,10 @@ test "generic fn keeps non-generic parameter types" {...@@ -165,8 +201,10 @@ test "generic fn keeps non-generic parameter types" {
165}201}
166202
167test "array of generic fns" {203test "array of generic fns" {
204 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
205 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
168 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;206 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
169 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;207
170 try expect(foos[0](true));208 try expect(foos[0](true));
171 try expect(!foos[1](true));209 try expect(!foos[1](true));
172}210}
...@@ -185,7 +223,8 @@ fn foo2(arg: anytype) bool {...@@ -185,7 +223,8 @@ fn foo2(arg: anytype) bool {
185223
186test "generic struct" {224test "generic struct" {
187 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;225 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
188 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;226 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
227 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
189 var a1 = GenNode(i32){228 var a1 = GenNode(i32){
190 .value = 13,229 .value = 13,
191 .next = null,230 .next = null,
test/behavior/if.zig+20
...@@ -4,6 +4,9 @@ const expect = std.testing.expect;...@@ -4,6 +4,9 @@ const expect = std.testing.expect;
4const expectEqual = std.testing.expectEqual;4const expectEqual = std.testing.expectEqual;
55
6test "if statements" {6test "if statements" {
7 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
8 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
9
7 shouldBeEqual(1, 1);10 shouldBeEqual(1, 1);
8 firstEqlThird(2, 1, 2);11 firstEqlThird(2, 1, 2);
9}12}
...@@ -27,6 +30,9 @@ fn firstEqlThird(a: i32, b: i32, c: i32) void {...@@ -27,6 +30,9 @@ fn firstEqlThird(a: i32, b: i32, c: i32) void {
27}30}
2831
29test "else if expression" {32test "else if expression" {
33 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
34 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
35
30 try expect(elseIfExpressionF(1) == 1);36 try expect(elseIfExpressionF(1) == 1);
31}37}
32fn elseIfExpressionF(c: u8) u8 {38fn elseIfExpressionF(c: u8) u8 {
...@@ -44,6 +50,10 @@ var global_with_val: anyerror!u32 = 0;...@@ -44,6 +50,10 @@ var global_with_val: anyerror!u32 = 0;
44var global_with_err: anyerror!u32 = error.SomeError;50var global_with_err: anyerror!u32 = error.SomeError;
4551
46test "unwrap mutable global var" {52test "unwrap mutable global var" {
53 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
54 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
55 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
56
47 if (global_with_val) |v| {57 if (global_with_val) |v| {
48 try expect(v == 0);58 try expect(v == 0);
49 } else |_| {59 } else |_| {
...@@ -57,6 +67,9 @@ test "unwrap mutable global var" {...@@ -57,6 +67,9 @@ test "unwrap mutable global var" {
57}67}
5868
59test "labeled break inside comptime if inside runtime if" {69test "labeled break inside comptime if inside runtime if" {
70 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
71 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
72
60 var answer: i32 = 0;73 var answer: i32 = 0;
61 var c = true;74 var c = true;
62 if (c) {75 if (c) {
...@@ -68,6 +81,9 @@ test "labeled break inside comptime if inside runtime if" {...@@ -68,6 +81,9 @@ test "labeled break inside comptime if inside runtime if" {
68}81}
6982
70test "const result loc, runtime if cond, else unreachable" {83test "const result loc, runtime if cond, else unreachable" {
84 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
85 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
86
71 const Num = enum { One, Two };87 const Num = enum { One, Two };
7288
73 var t = true;89 var t = true;
...@@ -76,6 +92,10 @@ test "const result loc, runtime if cond, else unreachable" {...@@ -76,6 +92,10 @@ test "const result loc, runtime if cond, else unreachable" {
76}92}
7793
78test "if copies its payload" {94test "if copies its payload" {
95 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
96 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
97 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
98
79 const S = struct {99 const S = struct {
80 fn doTheTest() !void {100 fn doTheTest() !void {
81 var tmp: ?i32 = 10;101 var tmp: ?i32 = 10;
test/behavior/incomplete_struct_param_tld.zig+3
...@@ -1,3 +1,4 @@...@@ -1,3 +1,4 @@
1const builtin = @import("builtin");
1const expect = @import("std").testing.expect;2const expect = @import("std").testing.expect;
23
3const A = struct {4const A = struct {
...@@ -21,6 +22,8 @@ fn foo(a: A) i32 {...@@ -21,6 +22,8 @@ fn foo(a: A) i32 {
21}22}
2223
23test "incomplete struct param top level declaration" {24test "incomplete struct param top level declaration" {
25 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
26 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
24 const a = A{27 const a = A{
25 .b = B{28 .b = B{
26 .c = C{ .x = 13 },29 .c = C{ .x = 13 },
test/behavior/inttoptr.zig+6
...@@ -3,6 +3,8 @@ const builtin = @import("builtin");...@@ -3,6 +3,8 @@ const builtin = @import("builtin");
3test "casting integer address to function pointer" {3test "casting integer address to function pointer" {
4 if (builtin.zig_backend == .stage1) return error.SkipZigTest;4 if (builtin.zig_backend == .stage1) return error.SkipZigTest;
5 if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch == .aarch64) return error.SkipZigTest; // TODO5 if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch == .aarch64) return error.SkipZigTest; // TODO
6 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
7 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
68
7 addressToFunction();9 addressToFunction();
8 comptime addressToFunction();10 comptime addressToFunction();
...@@ -14,6 +16,10 @@ fn addressToFunction() void {...@@ -14,6 +16,10 @@ fn addressToFunction() void {
14}16}
1517
16test "mutate through ptr initialized with constant intToPtr value" {18test "mutate through ptr initialized with constant intToPtr value" {
19 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
20 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
21 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
22
17 forceCompilerAnalyzeBranchHardCodedPtrDereference(false);23 forceCompilerAnalyzeBranchHardCodedPtrDereference(false);
18}24}
1925
test/behavior/member_func.zig+6
...@@ -28,6 +28,9 @@ const HasFuncs = struct {...@@ -28,6 +28,9 @@ const HasFuncs = struct {
2828
29test "standard field calls" {29test "standard field calls" {
30 if (builtin.zig_backend == .stage1) return error.SkipZigTest;30 if (builtin.zig_backend == .stage1) return error.SkipZigTest;
31 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
32 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
33 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
3134
32 try expect(HasFuncs.one(0) == 1);35 try expect(HasFuncs.one(0) == 1);
33 try expect(HasFuncs.two(0) == 2);36 try expect(HasFuncs.two(0) == 2);
...@@ -69,6 +72,9 @@ test "standard field calls" {...@@ -69,6 +72,9 @@ test "standard field calls" {
6972
70test "@field field calls" {73test "@field field calls" {
71 if (builtin.zig_backend == .stage1) return error.SkipZigTest;74 if (builtin.zig_backend == .stage1) return error.SkipZigTest;
75 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
76 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
77 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
7278
73 try expect(@field(HasFuncs, "one")(0) == 1);79 try expect(@field(HasFuncs, "one")(0) == 1);
74 try expect(@field(HasFuncs, "two")(0) == 2);80 try expect(@field(HasFuncs, "two")(0) == 2);
test/behavior/null.zig+29
...@@ -29,6 +29,10 @@ test "optional type" {...@@ -29,6 +29,10 @@ test "optional type" {
29}29}
3030
31test "test maybe object and get a pointer to the inner value" {31test "test maybe object and get a pointer to the inner value" {
32 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
33 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
34 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
35
32 var maybe_bool: ?bool = true;36 var maybe_bool: ?bool = true;
3337
34 if (maybe_bool) |*b| {38 if (maybe_bool) |*b| {
...@@ -45,6 +49,10 @@ test "rhs maybe unwrap return" {...@@ -45,6 +49,10 @@ test "rhs maybe unwrap return" {
45}49}
4650
47test "maybe return" {51test "maybe return" {
52 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
53 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
54 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
55
48 try maybeReturnImpl();56 try maybeReturnImpl();
49 comptime try maybeReturnImpl();57 comptime try maybeReturnImpl();
50}58}
...@@ -61,6 +69,10 @@ fn foo(x: ?i32) ?bool {...@@ -61,6 +69,10 @@ fn foo(x: ?i32) ?bool {
61}69}
6270
63test "test null runtime" {71test "test null runtime" {
72 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
73 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
74 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
75
64 try testTestNullRuntime(null);76 try testTestNullRuntime(null);
65}77}
66fn testTestNullRuntime(x: ?i32) !void {78fn testTestNullRuntime(x: ?i32) !void {
...@@ -69,6 +81,9 @@ fn testTestNullRuntime(x: ?i32) !void {...@@ -69,6 +81,9 @@ fn testTestNullRuntime(x: ?i32) !void {
69}81}
7082
71test "optional void" {83test "optional void" {
84 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
85 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
86
72 try optionalVoidImpl();87 try optionalVoidImpl();
73 comptime try optionalVoidImpl();88 comptime try optionalVoidImpl();
74}89}
...@@ -89,6 +104,9 @@ fn bar(x: ?void) ?void {...@@ -89,6 +104,9 @@ fn bar(x: ?void) ?void {
89const Empty = struct {};104const Empty = struct {};
90105
91test "optional struct{}" {106test "optional struct{}" {
107 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
108 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
109
92 _ = try optionalEmptyStructImpl();110 _ = try optionalEmptyStructImpl();
93 _ = comptime try optionalEmptyStructImpl();111 _ = comptime try optionalEmptyStructImpl();
94}112}
...@@ -107,17 +125,25 @@ fn baz(x: ?Empty) ?Empty {...@@ -107,17 +125,25 @@ fn baz(x: ?Empty) ?Empty {
107}125}
108126
109test "null with default unwrap" {127test "null with default unwrap" {
128 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
129
110 const x: i32 = null orelse 1;130 const x: i32 = null orelse 1;
111 try expect(x == 1);131 try expect(x == 1);
112}132}
113133
114test "optional pointer to 0 bit type null value at runtime" {134test "optional pointer to 0 bit type null value at runtime" {
135 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
136
115 const EmptyStruct = struct {};137 const EmptyStruct = struct {};
116 var x: ?*EmptyStruct = null;138 var x: ?*EmptyStruct = null;
117 try expect(x == null);139 try expect(x == null);
118}140}
119141
120test "if var maybe pointer" {142test "if var maybe pointer" {
143 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
144 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
145 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
146
121 try expect(shouldBeAPlus1(Particle{147 try expect(shouldBeAPlus1(Particle{
122 .a = 14,148 .a = 14,
123 .b = 1,149 .b = 1,
...@@ -159,6 +185,9 @@ const here_is_a_null_literal = SillyStruct{ .context = null };...@@ -159,6 +185,9 @@ const here_is_a_null_literal = SillyStruct{ .context = null };
159test "unwrap optional which is field of global var" {185test "unwrap optional which is field of global var" {
160 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO186 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
161 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO187 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
188 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
189 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
190 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
162191
163 struct_with_optional.field = null;192 struct_with_optional.field = null;
164 if (struct_with_optional.field) |payload| {193 if (struct_with_optional.field) |payload| {
test/behavior/pointers.zig+19
...@@ -17,6 +17,10 @@ fn testDerefPtr() !void {...@@ -17,6 +17,10 @@ fn testDerefPtr() !void {
17}17}
1818
19test "pointer arithmetic" {19test "pointer arithmetic" {
20 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
21 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
22 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
23
20 var ptr: [*]const u8 = "abcd";24 var ptr: [*]const u8 = "abcd";
2125
22 try expect(ptr[0] == 'a');26 try expect(ptr[0] == 'a');
...@@ -61,6 +65,10 @@ test "initialize const optional C pointer to null" {...@@ -61,6 +65,10 @@ test "initialize const optional C pointer to null" {
61}65}
6266
63test "assigning integer to C pointer" {67test "assigning integer to C pointer" {
68 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
69 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
70 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
71
64 var x: i32 = 0;72 var x: i32 = 0;
65 var y: i32 = 1;73 var y: i32 = 1;
66 var ptr: [*c]u8 = 0;74 var ptr: [*c]u8 = 0;
...@@ -75,6 +83,10 @@ test "assigning integer to C pointer" {...@@ -75,6 +83,10 @@ test "assigning integer to C pointer" {
75}83}
7684
77test "C pointer comparison and arithmetic" {85test "C pointer comparison and arithmetic" {
86 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
87 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
88 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
89
78 const S = struct {90 const S = struct {
79 fn doTheTest() !void {91 fn doTheTest() !void {
80 var ptr1: [*c]u32 = 0;92 var ptr1: [*c]u32 = 0;
...@@ -133,6 +145,10 @@ test "peer type resolution with C pointers" {...@@ -133,6 +145,10 @@ test "peer type resolution with C pointers" {
133}145}
134146
135test "implicit casting between C pointer and optional non-C pointer" {147test "implicit casting between C pointer and optional non-C pointer" {
148 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
149 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
150 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
151
136 var slice: []const u8 = "aoeu";152 var slice: []const u8 = "aoeu";
137 const opt_many_ptr: ?[*]const u8 = slice.ptr;153 const opt_many_ptr: ?[*]const u8 = slice.ptr;
138 var ptr_opt_many_ptr = &opt_many_ptr;154 var ptr_opt_many_ptr = &opt_many_ptr;
...@@ -172,6 +188,9 @@ test "compare equality of optional and non-optional pointer" {...@@ -172,6 +188,9 @@ test "compare equality of optional and non-optional pointer" {
172test "allowzero pointer and slice" {188test "allowzero pointer and slice" {
173 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO189 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
174 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO190 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
191 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
192 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
193 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
175194
176 var ptr = @intToPtr([*]allowzero i32, 0);195 var ptr = @intToPtr([*]allowzero i32, 0);
177 var opt_ptr: ?[*]allowzero i32 = ptr;196 var opt_ptr: ?[*]allowzero i32 = ptr;
test/behavior/ref_var_in_if_after_if_2nd_switch_prong.zig+5
...@@ -1,9 +1,14 @@...@@ -1,9 +1,14 @@
1const std = @import("std");1const std = @import("std");
2const builtin = @import("builtin");
2const expect = std.testing.expect;3const expect = std.testing.expect;
3const mem = std.mem;4const mem = std.mem;
45
5var ok: bool = false;6var ok: bool = false;
6test "reference a variable in an if after an if in the 2nd switch prong" {7test "reference a variable in an if after an if in the 2nd switch prong" {
8 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
9 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
10 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
11
7 try foo(true, Num.Two, false, "aoeu");12 try foo(true, Num.Two, false, "aoeu");
8 try expect(!ok);13 try expect(!ok);
9 try foo(false, Num.One, false, "aoeu");14 try foo(false, Num.One, false, "aoeu");
test/behavior/slice.zig-1
...@@ -248,7 +248,6 @@ test "result location zero sized array inside struct field implicit cast to slic...@@ -248,7 +248,6 @@ test "result location zero sized array inside struct field implicit cast to slic
248test "runtime safety lets us slice from len..len" {248test "runtime safety lets us slice from len..len" {
249 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;249 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
250 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;250 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
251 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
252251
253 var an_array = [_]u8{ 1, 2, 3 };252 var an_array = [_]u8{ 1, 2, 3 };
254 try expect(mem.eql(u8, sliceFromLenToLen(an_array[0..], 3, 3), ""));253 try expect(mem.eql(u8, sliceFromLenToLen(an_array[0..], 3, 3), ""));
test/behavior/src.zig+3
...@@ -1,7 +1,10 @@...@@ -1,7 +1,10 @@
1const std = @import("std");1const std = @import("std");
2const builtin = @import("builtin");
2const expect = std.testing.expect;3const expect = std.testing.expect;
34
4test "@src" {5test "@src" {
6 if (builtin.zig_backend != .stage1) return error.SkipZigTest;
7
5 try doTheTest();8 try doTheTest();
6}9}
710
test/behavior/struct.zig+4-8
...@@ -86,7 +86,8 @@ const StructFoo = struct {...@@ -86,7 +86,8 @@ const StructFoo = struct {
8686
87test "structs" {87test "structs" {
88 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;88 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
89 if (builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_arm) return error.SkipZigTest;89 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
90 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
9091
91 var foo: StructFoo = undefined;92 var foo: StructFoo = undefined;
92 @memset(@ptrCast([*]u8, &foo), 0, @sizeOf(StructFoo));93 @memset(@ptrCast([*]u8, &foo), 0, @sizeOf(StructFoo));
...@@ -248,7 +249,8 @@ test "usingnamespace within struct scope" {...@@ -248,7 +249,8 @@ test "usingnamespace within struct scope" {
248249
249test "struct field init with catch" {250test "struct field init with catch" {
250 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;251 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
251 if (builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_arm) return error.SkipZigTest;252 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
253 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
252254
253 const S = struct {255 const S = struct {
254 fn doTheTest() !void {256 fn doTheTest() !void {
...@@ -310,7 +312,6 @@ test "struct point to self" {...@@ -310,7 +312,6 @@ test "struct point to self" {
310 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO312 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
311 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO313 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
312 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO314 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
313 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
314315
315 var root: Node = undefined;316 var root: Node = undefined;
316 root.val.x = 1;317 root.val.x = 1;
...@@ -350,7 +351,6 @@ test "return empty struct from fn" {...@@ -350,7 +351,6 @@ test "return empty struct from fn" {
350 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO351 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
351 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO352 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
352 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO353 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
353 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
354354
355 _ = testReturnEmptyStructFromFn();355 _ = testReturnEmptyStructFromFn();
356}356}
...@@ -364,7 +364,6 @@ test "pass slice of empty struct to fn" {...@@ -364,7 +364,6 @@ test "pass slice of empty struct to fn" {
364 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO364 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
365 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO365 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
366 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO366 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
367 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
368367
369 try expect(testPassSliceOfEmptyStructToFn(&[_]EmptyStruct2{EmptyStruct2{}}) == 1);368 try expect(testPassSliceOfEmptyStructToFn(&[_]EmptyStruct2{EmptyStruct2{}}) == 1);
370}369}
...@@ -409,7 +408,6 @@ test "align 1 field before self referential align 8 field as slice return type"...@@ -409,7 +408,6 @@ test "align 1 field before self referential align 8 field as slice return type"
409 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO408 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
410 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO409 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
411 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO410 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
412 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
413411
414 const result = alloc(Expr);412 const result = alloc(Expr);
415 try expect(result.len == 0);413 try expect(result.len == 0);
...@@ -670,7 +668,6 @@ test "default struct initialization fields" {...@@ -670,7 +668,6 @@ test "default struct initialization fields" {
670 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO668 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
671 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO669 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
672 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO670 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
673 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
674671
675 const S = struct {672 const S = struct {
676 a: i32 = 1234,673 a: i32 = 1234,
...@@ -936,7 +933,6 @@ test "anonymous struct literal syntax" {...@@ -936,7 +933,6 @@ test "anonymous struct literal syntax" {
936 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO933 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
937 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO934 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
938 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO935 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
939 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
940936
941 const S = struct {937 const S = struct {
942 const Point = struct {938 const Point = struct {
test/behavior/this.zig+7
...@@ -1,4 +1,5 @@...@@ -1,4 +1,5 @@
1const expect = @import("std").testing.expect;1const expect = @import("std").testing.expect;
2const builtin = @import("builtin");
23
3const module = @This();4const module = @This();
45
...@@ -20,10 +21,16 @@ fn add(x: i32, y: i32) i32 {...@@ -20,10 +21,16 @@ fn add(x: i32, y: i32) i32 {
20}21}
2122
22test "this refer to module call private fn" {23test "this refer to module call private fn" {
24 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
25 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
26
23 try expect(module.add(1, 2) == 3);27 try expect(module.add(1, 2) == 3);
24}28}
2529
26test "this refer to container" {30test "this refer to container" {
31 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
32 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
33
27 var pt: Point(i32) = undefined;34 var pt: Point(i32) = undefined;
28 pt.x = 12;35 pt.x = 12;
29 pt.y = 34;36 pt.y = 34;
test/behavior/try.zig+13-1
...@@ -1,6 +1,12 @@...@@ -1,6 +1,12 @@
1const expect = @import("std").testing.expect;1const std = @import("std");
2const builtin = @import("builtin");
3const expect = std.testing.expect;
24
3test "try on error union" {5test "try on error union" {
6 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
7 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
8 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
9
4 try tryOnErrorUnionImpl();10 try tryOnErrorUnionImpl();
5 comptime try tryOnErrorUnionImpl();11 comptime try tryOnErrorUnionImpl();
6}12}
...@@ -19,6 +25,9 @@ fn returnsTen() anyerror!i32 {...@@ -19,6 +25,9 @@ fn returnsTen() anyerror!i32 {
19}25}
2026
21test "try without vars" {27test "try without vars" {
28 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
29 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
30
22 const result1 = if (failIfTrue(true)) 1 else |_| @as(i32, 2);31 const result1 = if (failIfTrue(true)) 1 else |_| @as(i32, 2);
23 try expect(result1 == 2);32 try expect(result1 == 2);
2433
...@@ -35,6 +44,9 @@ fn failIfTrue(ok: bool) anyerror!void {...@@ -35,6 +44,9 @@ fn failIfTrue(ok: bool) anyerror!void {
35}44}
3645
37test "try then not executed with assignment" {46test "try then not executed with assignment" {
47 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
48 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
49
38 if (failIfTrue(true)) {50 if (failIfTrue(true)) {
39 unreachable;51 unreachable;
40 } else |err| {52 } else |err| {
test/behavior/type_info.zig+11
...@@ -186,6 +186,10 @@ fn testErrorSet() !void {...@@ -186,6 +186,10 @@ fn testErrorSet() !void {
186}186}
187187
188test "type info: enum info" {188test "type info: enum info" {
189 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
190 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
191 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
192
189 try testEnum();193 try testEnum();
190 comptime try testEnum();194 comptime try testEnum();
191}195}
...@@ -249,6 +253,9 @@ fn testUnion() !void {...@@ -249,6 +253,9 @@ fn testUnion() !void {
249}253}
250254
251test "type info: struct info" {255test "type info: struct info" {
256 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
257 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
258
252 try testStruct();259 try testStruct();
253 comptime try testStruct();260 comptime try testStruct();
254}261}
...@@ -439,6 +446,10 @@ test "type info for async frames" {...@@ -439,6 +446,10 @@ test "type info for async frames" {
439}446}
440447
441test "Declarations are returned in declaration order" {448test "Declarations are returned in declaration order" {
449 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
450 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
451 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
452
442 const S = struct {453 const S = struct {
443 const a = 1;454 const a = 1;
444 const b = 2;455 const b = 2;
test/behavior/undefined.zig+11
...@@ -16,6 +16,8 @@ test "init static array to undefined" {...@@ -16,6 +16,8 @@ test "init static array to undefined" {
16 // This test causes `initStaticArray()` to be codegen'd, and the16 // This test causes `initStaticArray()` to be codegen'd, and the
17 // C backend does not yet support returning arrays, so it fails17 // C backend does not yet support returning arrays, so it fails
18 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;18 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
19 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
20 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
1921
20 try expect(static_array[0] == 1);22 try expect(static_array[0] == 1);
21 try expect(static_array[4] == 2);23 try expect(static_array[4] == 2);
...@@ -43,6 +45,9 @@ fn setFooX(foo: *Foo) void {...@@ -43,6 +45,9 @@ fn setFooX(foo: *Foo) void {
43}45}
4446
45test "assign undefined to struct" {47test "assign undefined to struct" {
48 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
49 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
50
46 comptime {51 comptime {
47 var foo: Foo = undefined;52 var foo: Foo = undefined;
48 setFooX(&foo);53 setFooX(&foo);
...@@ -56,6 +61,9 @@ test "assign undefined to struct" {...@@ -56,6 +61,9 @@ test "assign undefined to struct" {
56}61}
5762
58test "assign undefined to struct with method" {63test "assign undefined to struct with method" {
64 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
65 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
66
59 comptime {67 comptime {
60 var foo: Foo = undefined;68 var foo: Foo = undefined;
61 foo.setFooXMethod();69 foo.setFooXMethod();
...@@ -69,6 +77,9 @@ test "assign undefined to struct with method" {...@@ -69,6 +77,9 @@ test "assign undefined to struct with method" {
69}77}
7078
71test "type name of undefined" {79test "type name of undefined" {
80 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
81 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
82
72 const x = undefined;83 const x = undefined;
73 try expect(mem.eql(u8, @typeName(@TypeOf(x)), "@Type(.Undefined)"));84 try expect(mem.eql(u8, @typeName(@TypeOf(x)), "@Type(.Undefined)"));
74}85}
test/behavior/underscore.zig+5
...@@ -1,4 +1,5 @@...@@ -1,4 +1,5 @@
1const std = @import("std");1const std = @import("std");
2const builtin = @import("builtin");
2const expect = std.testing.expect;3const expect = std.testing.expect;
34
4test "ignore lval with underscore" {5test "ignore lval with underscore" {
...@@ -6,6 +7,10 @@ test "ignore lval with underscore" {...@@ -6,6 +7,10 @@ test "ignore lval with underscore" {
6}7}
78
8test "ignore lval with underscore (while loop)" {9test "ignore lval with underscore (while loop)" {
10 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
11 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
12 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
13
9 while (optionalReturnError()) |_| {14 while (optionalReturnError()) |_| {
10 while (optionalReturnError()) |_| {15 while (optionalReturnError()) |_| {
11 break;16 break;
test/behavior/union.zig+139
...@@ -10,6 +10,10 @@ const Foo = union {...@@ -10,6 +10,10 @@ const Foo = union {
10};10};
1111
12test "basic unions" {12test "basic unions" {
13 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
14 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
15 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
16
13 var foo = Foo{ .int = 1 };17 var foo = Foo{ .int = 1 };
14 try expect(foo.int == 1);18 try expect(foo.int == 1);
15 foo = Foo{ .float = 12.34 };19 foo = Foo{ .float = 12.34 };
...@@ -17,6 +21,10 @@ test "basic unions" {...@@ -17,6 +21,10 @@ test "basic unions" {
17}21}
1822
19test "init union with runtime value" {23test "init union with runtime value" {
24 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
25 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
26 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
27
20 var foo: Foo = undefined;28 var foo: Foo = undefined;
2129
22 setFloat(&foo, 12.34);30 setFloat(&foo, 12.34);
...@@ -35,6 +43,9 @@ fn setInt(foo: *Foo, x: i32) void {...@@ -35,6 +43,9 @@ fn setInt(foo: *Foo, x: i32) void {
35}43}
3644
37test "comptime union field access" {45test "comptime union field access" {
46 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
47 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
48
38 comptime {49 comptime {
39 var foo = Foo{ .int = 0 };50 var foo = Foo{ .int = 0 };
40 try expect(foo.int == 0);51 try expect(foo.int == 0);
...@@ -50,6 +61,10 @@ const FooExtern = extern union {...@@ -50,6 +61,10 @@ const FooExtern = extern union {
50};61};
5162
52test "basic extern unions" {63test "basic extern unions" {
64 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
65 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
66 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
67
53 var foo = FooExtern{ .int = 1 };68 var foo = FooExtern{ .int = 1 };
54 try expect(foo.int == 1);69 try expect(foo.int == 1);
55 foo.float = 12.34;70 foo.float = 12.34;
...@@ -61,10 +76,16 @@ const ExternPtrOrInt = extern union {...@@ -61,10 +76,16 @@ const ExternPtrOrInt = extern union {
61 int: u64,76 int: u64,
62};77};
63test "extern union size" {78test "extern union size" {
79 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
80 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
81
64 comptime try expect(@sizeOf(ExternPtrOrInt) == 8);82 comptime try expect(@sizeOf(ExternPtrOrInt) == 8);
65}83}
6684
67test "0-sized extern union definition" {85test "0-sized extern union definition" {
86 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
87 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
88
68 const U = extern union {89 const U = extern union {
69 a: void,90 a: void,
70 const f = 1;91 const f = 1;
...@@ -94,6 +115,9 @@ const err = @as(anyerror!Agg, Agg{...@@ -94,6 +115,9 @@ const err = @as(anyerror!Agg, Agg{
94const array = [_]Value{ v1, v2, v1, v2 };115const array = [_]Value{ v1, v2, v1, v2 };
95116
96test "unions embedded in aggregate types" {117test "unions embedded in aggregate types" {
118 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
119 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
120
97 switch (array[1]) {121 switch (array[1]) {
98 Value.Array => |arr| try expect(arr[4] == 3),122 Value.Array => |arr| try expect(arr[4] == 3),
99 else => unreachable,123 else => unreachable,
...@@ -105,6 +129,9 @@ test "unions embedded in aggregate types" {...@@ -105,6 +129,9 @@ test "unions embedded in aggregate types" {
105}129}
106130
107test "access a member of tagged union with conflicting enum tag name" {131test "access a member of tagged union with conflicting enum tag name" {
132 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
133 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
134
108 const Bar = union(enum) {135 const Bar = union(enum) {
109 A: A,136 A: A,
110 B: B,137 B: B,
...@@ -117,6 +144,10 @@ test "access a member of tagged union with conflicting enum tag name" {...@@ -117,6 +144,10 @@ test "access a member of tagged union with conflicting enum tag name" {
117}144}
118145
119test "constant tagged union with payload" {146test "constant tagged union with payload" {
147 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
148 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
149 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
150
120 var empty = TaggedUnionWithPayload{ .Empty = {} };151 var empty = TaggedUnionWithPayload{ .Empty = {} };
121 var full = TaggedUnionWithPayload{ .Full = 13 };152 var full = TaggedUnionWithPayload{ .Full = 13 };
122 shouldBeEmpty(empty);153 shouldBeEmpty(empty);
...@@ -143,6 +174,9 @@ const TaggedUnionWithPayload = union(enum) {...@@ -143,6 +174,9 @@ const TaggedUnionWithPayload = union(enum) {
143};174};
144175
145test "union alignment" {176test "union alignment" {
177 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
178 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
179
146 comptime {180 comptime {
147 try expect(@alignOf(AlignTestTaggedUnion) >= @alignOf([9]u8));181 try expect(@alignOf(AlignTestTaggedUnion) >= @alignOf([9]u8));
148 try expect(@alignOf(AlignTestTaggedUnion) >= @alignOf(u64));182 try expect(@alignOf(AlignTestTaggedUnion) >= @alignOf(u64));
...@@ -162,11 +196,18 @@ const Payload = union(Letter) {...@@ -162,11 +196,18 @@ const Payload = union(Letter) {
162};196};
163197
164test "union with specified enum tag" {198test "union with specified enum tag" {
199 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
200 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
201 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
202
165 try doTest();203 try doTest();
166 comptime try doTest();204 comptime try doTest();
167}205}
168206
169test "packed union generates correctly aligned LLVM type" {207test "packed union generates correctly aligned LLVM type" {
208 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
209 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
210 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
170 if (builtin.zig_backend == .stage1) return error.SkipZigTest;211 if (builtin.zig_backend == .stage1) return error.SkipZigTest;
171212
172 const U = packed union {213 const U = packed union {
...@@ -204,6 +245,10 @@ fn testComparison() !void {...@@ -204,6 +245,10 @@ fn testComparison() !void {
204}245}
205246
206test "comparison between union and enum literal" {247test "comparison between union and enum literal" {
248 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
249 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
250 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
251
207 try testComparison();252 try testComparison();
208 comptime try testComparison();253 comptime try testComparison();
209}254}
...@@ -215,6 +260,10 @@ const TheUnion = union(TheTag) {...@@ -215,6 +260,10 @@ const TheUnion = union(TheTag) {
215 C: i32,260 C: i32,
216};261};
217test "cast union to tag type of union" {262test "cast union to tag type of union" {
263 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
264 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
265 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
266
218 try testCastUnionToTag();267 try testCastUnionToTag();
219 comptime try testCastUnionToTag();268 comptime try testCastUnionToTag();
220}269}
...@@ -225,12 +274,19 @@ fn testCastUnionToTag() !void {...@@ -225,12 +274,19 @@ fn testCastUnionToTag() !void {
225}274}
226275
227test "union field access gives the enum values" {276test "union field access gives the enum values" {
277 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
278 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
279
228 try expect(TheUnion.A == TheTag.A);280 try expect(TheUnion.A == TheTag.A);
229 try expect(TheUnion.B == TheTag.B);281 try expect(TheUnion.B == TheTag.B);
230 try expect(TheUnion.C == TheTag.C);282 try expect(TheUnion.C == TheTag.C);
231}283}
232284
233test "cast tag type of union to union" {285test "cast tag type of union to union" {
286 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
287 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
288 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
289
234 var x: Value2 = Letter2.B;290 var x: Value2 = Letter2.B;
235 try expect(@as(Letter2, x) == Letter2.B);291 try expect(@as(Letter2, x) == Letter2.B);
236}292}
...@@ -242,6 +298,10 @@ const Value2 = union(Letter2) {...@@ -242,6 +298,10 @@ const Value2 = union(Letter2) {
242};298};
243299
244test "implicit cast union to its tag type" {300test "implicit cast union to its tag type" {
301 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
302 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
303 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
304
245 var x: Value2 = Letter2.B;305 var x: Value2 = Letter2.B;
246 try expect(x == Letter2.B);306 try expect(x == Letter2.B);
247 try giveMeLetterB(x);307 try giveMeLetterB(x);
...@@ -258,6 +318,10 @@ pub const PackThis = union(enum) {...@@ -258,6 +318,10 @@ pub const PackThis = union(enum) {
258};318};
259319
260test "constant packed union" {320test "constant packed union" {
321 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
322 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
323 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
324
261 try testConstPackedUnion(&[_]PackThis{PackThis{ .StringLiteral = 1 }});325 try testConstPackedUnion(&[_]PackThis{PackThis{ .StringLiteral = 1 }});
262}326}
263327
...@@ -272,6 +336,10 @@ const MultipleChoice = union(enum(u32)) {...@@ -272,6 +336,10 @@ const MultipleChoice = union(enum(u32)) {
272 D = 1000,336 D = 1000,
273};337};
274test "simple union(enum(u32))" {338test "simple union(enum(u32))" {
339 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
340 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
341 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
342
275 var x = MultipleChoice.C;343 var x = MultipleChoice.C;
276 try expect(x == MultipleChoice.C);344 try expect(x == MultipleChoice.C);
277 try expect(@enumToInt(@as(Tag(MultipleChoice), x)) == 60);345 try expect(@enumToInt(@as(Tag(MultipleChoice), x)) == 60);
...@@ -282,6 +350,9 @@ const PackedPtrOrInt = packed union {...@@ -282,6 +350,9 @@ const PackedPtrOrInt = packed union {
282 int: u64,350 int: u64,
283};351};
284test "packed union size" {352test "packed union size" {
353 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
354 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
355
285 comptime try expect(@sizeOf(PackedPtrOrInt) == 8);356 comptime try expect(@sizeOf(PackedPtrOrInt) == 8);
286}357}
287358
...@@ -289,10 +360,17 @@ const ZeroBits = union {...@@ -289,10 +360,17 @@ const ZeroBits = union {
289 OnlyField: void,360 OnlyField: void,
290};361};
291test "union with only 1 field which is void should be zero bits" {362test "union with only 1 field which is void should be zero bits" {
363 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
364 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
365
292 comptime try expect(@sizeOf(ZeroBits) == 0);366 comptime try expect(@sizeOf(ZeroBits) == 0);
293}367}
294368
295test "tagged union initialization with runtime void" {369test "tagged union initialization with runtime void" {
370 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
371 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
372 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
373
296 try expect(testTaggedUnionInit({}));374 try expect(testTaggedUnionInit({}));
297}375}
298376
...@@ -309,6 +387,10 @@ fn testTaggedUnionInit(x: anytype) bool {...@@ -309,6 +387,10 @@ fn testTaggedUnionInit(x: anytype) bool {
309pub const UnionEnumNoPayloads = union(enum) { A, B };387pub const UnionEnumNoPayloads = union(enum) { A, B };
310388
311test "tagged union with no payloads" {389test "tagged union with no payloads" {
390 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
391 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
392 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
393
312 const a = UnionEnumNoPayloads{ .B = {} };394 const a = UnionEnumNoPayloads{ .B = {} };
313 switch (a) {395 switch (a) {
314 Tag(UnionEnumNoPayloads).A => @panic("wrong"),396 Tag(UnionEnumNoPayloads).A => @panic("wrong"),
...@@ -317,6 +399,10 @@ test "tagged union with no payloads" {...@@ -317,6 +399,10 @@ test "tagged union with no payloads" {
317}399}
318400
319test "union with only 1 field casted to its enum type" {401test "union with only 1 field casted to its enum type" {
402 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
403 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
404 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
405
320 const Literal = union(enum) {406 const Literal = union(enum) {
321 Number: f64,407 Number: f64,
322 Bool: bool,408 Bool: bool,
...@@ -334,6 +420,9 @@ test "union with only 1 field casted to its enum type" {...@@ -334,6 +420,9 @@ test "union with only 1 field casted to its enum type" {
334}420}
335421
336test "union with one member defaults to u0 tag type" {422test "union with one member defaults to u0 tag type" {
423 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
424 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
425
337 const U0 = union(enum) {426 const U0 = union(enum) {
338 X: u32,427 X: u32,
339 };428 };
...@@ -348,6 +437,10 @@ const Foo1 = union(enum) {...@@ -348,6 +437,10 @@ const Foo1 = union(enum) {
348var glbl: Foo1 = undefined;437var glbl: Foo1 = undefined;
349438
350test "global union with single field is correctly initialized" {439test "global union with single field is correctly initialized" {
440 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
441 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
442 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
443
351 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO444 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
352 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO445 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
353446
...@@ -365,6 +458,10 @@ pub const FooUnion = union(enum) {...@@ -365,6 +458,10 @@ pub const FooUnion = union(enum) {
365var glbl_array: [2]FooUnion = undefined;458var glbl_array: [2]FooUnion = undefined;
366459
367test "initialize global array of union" {460test "initialize global array of union" {
461 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
462 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
463 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
464
368 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;465 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
369 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;466 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
370467
...@@ -375,6 +472,10 @@ test "initialize global array of union" {...@@ -375,6 +472,10 @@ test "initialize global array of union" {
375}472}
376473
377test "update the tag value for zero-sized unions" {474test "update the tag value for zero-sized unions" {
475 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
476 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
477 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
478
378 const S = union(enum) {479 const S = union(enum) {
379 U0: void,480 U0: void,
380 U1: void,481 U1: void,
...@@ -386,6 +487,10 @@ test "update the tag value for zero-sized unions" {...@@ -386,6 +487,10 @@ test "update the tag value for zero-sized unions" {
386}487}
387488
388test "union initializer generates padding only if needed" {489test "union initializer generates padding only if needed" {
490 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
491 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
492 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
493
389 const U = union(enum) {494 const U = union(enum) {
390 A: u24,495 A: u24,
391 };496 };
...@@ -395,6 +500,10 @@ test "union initializer generates padding only if needed" {...@@ -395,6 +500,10 @@ test "union initializer generates padding only if needed" {
395}500}
396501
397test "runtime tag name with single field" {502test "runtime tag name with single field" {
503 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
504 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
505 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
506
398 const U = union(enum) {507 const U = union(enum) {
399 A: i32,508 A: i32,
400 };509 };
...@@ -404,6 +513,10 @@ test "runtime tag name with single field" {...@@ -404,6 +513,10 @@ test "runtime tag name with single field" {
404}513}
405514
406test "method call on an empty union" {515test "method call on an empty union" {
516 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
517 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
518 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
519
407 const S = struct {520 const S = struct {
408 const MyUnion = union(MyUnionTag) {521 const MyUnion = union(MyUnionTag) {
409 pub const MyUnionTag = enum { X1, X2 };522 pub const MyUnionTag = enum { X1, X2 };
...@@ -441,6 +554,10 @@ const FooNoVoid = union(enum) {...@@ -441,6 +554,10 @@ const FooNoVoid = union(enum) {
441const Baz = enum { A, B, C, D };554const Baz = enum { A, B, C, D };
442555
443test "tagged union type" {556test "tagged union type" {
557 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
558 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
559 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
560
444 const foo1 = TaggedFoo{ .One = 13 };561 const foo1 = TaggedFoo{ .One = 13 };
445 const foo2 = TaggedFoo{562 const foo2 = TaggedFoo{
446 .Two = Point{563 .Two = Point{
...@@ -460,6 +577,10 @@ test "tagged union type" {...@@ -460,6 +577,10 @@ test "tagged union type" {
460}577}
461578
462test "tagged union as return value" {579test "tagged union as return value" {
580 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
581 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
582 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
583
463 switch (returnAnInt(13)) {584 switch (returnAnInt(13)) {
464 TaggedFoo.One => |value| try expect(value == 13),585 TaggedFoo.One => |value| try expect(value == 13),
465 else => unreachable,586 else => unreachable,
...@@ -471,6 +592,10 @@ fn returnAnInt(x: i32) TaggedFoo {...@@ -471,6 +592,10 @@ fn returnAnInt(x: i32) TaggedFoo {
471}592}
472593
473test "tagged union with all void fields but a meaningful tag" {594test "tagged union with all void fields but a meaningful tag" {
595 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
596 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
597 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
598
474 const S = struct {599 const S = struct {
475 const B = union(enum) {600 const B = union(enum) {
476 c: C,601 c: C,
...@@ -496,6 +621,9 @@ test "tagged union with all void fields but a meaningful tag" {...@@ -496,6 +621,9 @@ test "tagged union with all void fields but a meaningful tag" {
496621
497test "union(enum(u32)) with specified and unspecified tag values" {622test "union(enum(u32)) with specified and unspecified tag values" {
498 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO623 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
624 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
625 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
626 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
499627
500 comptime try expect(Tag(Tag(MultipleChoice2)) == u32);628 comptime try expect(Tag(Tag(MultipleChoice2)) == u32);
501 try testEnumWithSpecifiedAndUnspecifiedTagValues(MultipleChoice2{ .C = 123 });629 try testEnumWithSpecifiedAndUnspecifiedTagValues(MultipleChoice2{ .C = 123 });
...@@ -558,6 +686,10 @@ const PartialInstWithPayload = union(enum) {...@@ -558,6 +686,10 @@ const PartialInstWithPayload = union(enum) {
558};686};
559687
560test "union with only 1 field casted to its enum type which has enum value specified" {688test "union with only 1 field casted to its enum type which has enum value specified" {
689 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
690 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
691 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
692
561 const Literal = union(enum) {693 const Literal = union(enum) {
562 Number: f64,694 Number: f64,
563 Bool: bool,695 Bool: bool,
...@@ -638,6 +770,10 @@ fn Setter(attr: Attribute) type {...@@ -638,6 +770,10 @@ fn Setter(attr: Attribute) type {
638}770}
639771
640test "return union init with void payload" {772test "return union init with void payload" {
773 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
774 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
775 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
776
641 const S = struct {777 const S = struct {
642 fn entry() !void {778 fn entry() !void {
643 try expect(func().state == State.one);779 try expect(func().state == State.one);
...@@ -948,6 +1084,9 @@ test "union enum type gets a separate scope" {...@@ -948,6 +1084,9 @@ test "union enum type gets a separate scope" {
948test "global variable struct contains union initialized to non-most-aligned field" {1084test "global variable struct contains union initialized to non-most-aligned field" {
949 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO1085 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
950 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO1086 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
1087 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1088 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
1089 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
9511090
952 const T = struct {1091 const T = struct {
953 const U = union(enum) {1092 const U = union(enum) {
test/behavior/usingnamespace.zig+19
...@@ -1,4 +1,5 @@...@@ -1,4 +1,5 @@
1const std = @import("std");1const std = @import("std");
2const builtin = @import("builtin");
2const expect = std.testing.expect;3const expect = std.testing.expect;
34
4const A = struct {5const A = struct {
...@@ -10,6 +11,9 @@ const C = struct {...@@ -10,6 +11,9 @@ const C = struct {
10};11};
1112
12test "basic usingnamespace" {13test "basic usingnamespace" {
14 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
15 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
16
13 try std.testing.expect(C.B == bool);17 try std.testing.expect(C.B == bool);
14}18}
1519
...@@ -20,6 +24,9 @@ fn Foo(comptime T: type) type {...@@ -20,6 +24,9 @@ fn Foo(comptime T: type) type {
20}24}
2125
22test "usingnamespace inside a generic struct" {26test "usingnamespace inside a generic struct" {
27 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
28 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
29
23 const std2 = Foo(std);30 const std2 = Foo(std);
24 const testing2 = Foo(std.testing);31 const testing2 = Foo(std.testing);
25 try std2.testing.expect(true);32 try std2.testing.expect(true);
...@@ -31,11 +38,17 @@ usingnamespace struct {...@@ -31,11 +38,17 @@ usingnamespace struct {
31};38};
3239
33test "usingnamespace does not redeclare an imported variable" {40test "usingnamespace does not redeclare an imported variable" {
41 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
42 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
43
34 comptime try std.testing.expect(@This().foo == 42);44 comptime try std.testing.expect(@This().foo == 42);
35}45}
3646
37usingnamespace @import("usingnamespace/foo.zig");47usingnamespace @import("usingnamespace/foo.zig");
38test "usingnamespace omits mixing in private functions" {48test "usingnamespace omits mixing in private functions" {
49 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
50 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
51
39 try expect(@This().privateFunction());52 try expect(@This().privateFunction());
40 try expect(!@This().printText());53 try expect(!@This().printText());
41}54}
...@@ -44,10 +57,16 @@ fn privateFunction() bool {...@@ -44,10 +57,16 @@ fn privateFunction() bool {
44}57}
4558
46test {59test {
60 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
61 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
62
47 _ = @import("usingnamespace/import_segregation.zig");63 _ = @import("usingnamespace/import_segregation.zig");
48}64}
4965
50usingnamespace @import("usingnamespace/a.zig");66usingnamespace @import("usingnamespace/a.zig");
51test "two files usingnamespace import each other" {67test "two files usingnamespace import each other" {
68 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
69 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
70
52 try expect(@This().ok());71 try expect(@This().ok());
53}72}
test/behavior/void.zig+11
...@@ -1,4 +1,5 @@...@@ -1,4 +1,5 @@
1const expect = @import("std").testing.expect;1const expect = @import("std").testing.expect;
2const builtin = @import("builtin");
23
3const Foo = struct {4const Foo = struct {
4 a: void,5 a: void,
...@@ -18,6 +19,9 @@ test "compare void with void compile time known" {...@@ -18,6 +19,9 @@ test "compare void with void compile time known" {
18}19}
1920
20test "iterate over a void slice" {21test "iterate over a void slice" {
22 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
23 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
24
21 var j: usize = 0;25 var j: usize = 0;
22 for (times(10)) |_, i| {26 for (times(10)) |_, i| {
23 try expect(i == j);27 try expect(i == j);
...@@ -30,11 +34,18 @@ fn times(n: usize) []const void {...@@ -30,11 +34,18 @@ fn times(n: usize) []const void {
30}34}
3135
32test "void optional" {36test "void optional" {
37 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
38 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
39 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
40
33 var x: ?void = {};41 var x: ?void = {};
34 try expect(x != null);42 try expect(x != null);
35}43}
3644
37test "void array as a local variable initializer" {45test "void array as a local variable initializer" {
46 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
47 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
48
38 var x = [_]void{{}} ** 1004;49 var x = [_]void{{}} ** 1004;
39 _ = x[0];50 _ = x[0];
40}51}
test/behavior/while.zig+47
...@@ -1,7 +1,11 @@...@@ -1,7 +1,11 @@
1const std = @import("std");1const std = @import("std");
2const builtin = @import("builtin");
2const expect = std.testing.expect;3const expect = std.testing.expect;
34
4test "while loop" {5test "while loop" {
6 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
7 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
8
5 var i: i32 = 0;9 var i: i32 = 0;
6 while (i < 4) {10 while (i < 4) {
7 i += 1;11 i += 1;
...@@ -19,6 +23,9 @@ fn whileLoop2() i32 {...@@ -19,6 +23,9 @@ fn whileLoop2() i32 {
19}23}
2024
21test "static eval while" {25test "static eval while" {
26 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
27 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
28
22 try expect(static_eval_while_number == 1);29 try expect(static_eval_while_number == 1);
23}30}
24const static_eval_while_number = staticWhileLoop1();31const static_eval_while_number = staticWhileLoop1();
...@@ -98,6 +105,10 @@ fn testBreakOuter() void {...@@ -98,6 +105,10 @@ fn testBreakOuter() void {
98}105}
99106
100test "while copies its payload" {107test "while copies its payload" {
108 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
109 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
110 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
111
101 const S = struct {112 const S = struct {
102 fn doTheTest() !void {113 fn doTheTest() !void {
103 var tmp: ?i32 = 10;114 var tmp: ?i32 = 10;
...@@ -131,6 +142,10 @@ fn runContinueAndBreakTest() !void {...@@ -131,6 +142,10 @@ fn runContinueAndBreakTest() !void {
131}142}
132143
133test "while with optional as condition" {144test "while with optional as condition" {
145 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
146 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
147 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
148
134 numbers_left = 10;149 numbers_left = 10;
135 var sum: i32 = 0;150 var sum: i32 = 0;
136 while (getNumberOrNull()) |value| {151 while (getNumberOrNull()) |value| {
...@@ -140,6 +155,10 @@ test "while with optional as condition" {...@@ -140,6 +155,10 @@ test "while with optional as condition" {
140}155}
141156
142test "while with optional as condition with else" {157test "while with optional as condition with else" {
158 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
159 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
160 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
161
143 numbers_left = 10;162 numbers_left = 10;
144 var sum: i32 = 0;163 var sum: i32 = 0;
145 var got_else: i32 = 0;164 var got_else: i32 = 0;
...@@ -154,6 +173,10 @@ test "while with optional as condition with else" {...@@ -154,6 +173,10 @@ test "while with optional as condition with else" {
154}173}
155174
156test "while with error union condition" {175test "while with error union condition" {
176 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
177 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
178 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
179
157 numbers_left = 10;180 numbers_left = 10;
158 var sum: i32 = 0;181 var sum: i32 = 0;
159 var got_else: i32 = 0;182 var got_else: i32 = 0;
...@@ -182,6 +205,10 @@ test "while on bool with else result follow break prong" {...@@ -182,6 +205,10 @@ test "while on bool with else result follow break prong" {
182}205}
183206
184test "while on optional with else result follow else prong" {207test "while on optional with else result follow else prong" {
208 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
209 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
210 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
211
185 const result = while (returnNull()) |value| {212 const result = while (returnNull()) |value| {
186 break value;213 break value;
187 } else @as(i32, 2);214 } else @as(i32, 2);
...@@ -189,6 +216,10 @@ test "while on optional with else result follow else prong" {...@@ -189,6 +216,10 @@ test "while on optional with else result follow else prong" {
189}216}
190217
191test "while on optional with else result follow break prong" {218test "while on optional with else result follow break prong" {
219 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
220 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
221 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
222
192 const result = while (returnOptional(10)) |value| {223 const result = while (returnOptional(10)) |value| {
193 break value;224 break value;
194 } else @as(i32, 2);225 } else @as(i32, 2);
...@@ -215,6 +246,10 @@ fn returnTrue() bool {...@@ -215,6 +246,10 @@ fn returnTrue() bool {
215}246}
216247
217test "return with implicit cast from while loop" {248test "return with implicit cast from while loop" {
249 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
250 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
251 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
252
218 returnWithImplicitCastFromWhileLoopTest() catch unreachable;253 returnWithImplicitCastFromWhileLoopTest() catch unreachable;
219}254}
220fn returnWithImplicitCastFromWhileLoopTest() anyerror!void {255fn returnWithImplicitCastFromWhileLoopTest() anyerror!void {
...@@ -224,6 +259,10 @@ fn returnWithImplicitCastFromWhileLoopTest() anyerror!void {...@@ -224,6 +259,10 @@ fn returnWithImplicitCastFromWhileLoopTest() anyerror!void {
224}259}
225260
226test "while on error union with else result follow else prong" {261test "while on error union with else result follow else prong" {
262 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
263 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
264 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
265
227 const result = while (returnError()) |value| {266 const result = while (returnError()) |value| {
228 break value;267 break value;
229 } else |_| @as(i32, 2);268 } else |_| @as(i32, 2);
...@@ -231,6 +270,10 @@ test "while on error union with else result follow else prong" {...@@ -231,6 +270,10 @@ test "while on error union with else result follow else prong" {
231}270}
232271
233test "while on error union with else result follow break prong" {272test "while on error union with else result follow break prong" {
273 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
274 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
275 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
276
234 const result = while (returnSuccess(10)) |value| {277 const result = while (returnSuccess(10)) |value| {
235 break value;278 break value;
236 } else |_| @as(i32, 2);279 } else |_| @as(i32, 2);
...@@ -253,6 +296,10 @@ test "while bool 2 break statements and an else" {...@@ -253,6 +296,10 @@ test "while bool 2 break statements and an else" {
253}296}
254297
255test "while optional 2 break statements and an else" {298test "while optional 2 break statements and an else" {
299 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
300 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
301 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
302
256 const S = struct {303 const S = struct {
257 fn entry(opt_t: ?bool, f: bool) !void {304 fn entry(opt_t: ?bool, f: bool) !void {
258 var ok = false;305 var ok = false;