| author | |
| committer | |
| log | 25e4b16e25502ca5e76e4049ed9f727168782dde |
| tree | 947799ee1d22e621937c95842370cc7aee679412 |
| parent | a94267b2906e90aadf397b3f524e1069721fb496 |
40 files changed, 832 insertions(+), 140 deletions(-)
test/behavior.zig+110-110| ... | ... | @@ -9,12 +9,16 @@ test { |
| 9 | 9 | _ = @import("behavior/bitcast.zig"); |
| 10 | 10 | _ = @import("behavior/bitreverse.zig"); |
| 11 | 11 | _ = @import("behavior/byteswap.zig"); |
| 12 | _ = @import("behavior/byval_arg_var.zig"); | |
| 12 | 13 | _ = @import("behavior/bool.zig"); |
| 13 | 14 | _ = @import("behavior/bugs/394.zig"); |
| 15 | _ = @import("behavior/bugs/624.zig"); | |
| 14 | 16 | _ = @import("behavior/bugs/655.zig"); |
| 15 | 17 | _ = @import("behavior/bugs/656.zig"); |
| 16 | 18 | _ = @import("behavior/bugs/679.zig"); |
| 19 | _ = @import("behavior/bugs/704.zig"); | |
| 17 | 20 | _ = @import("behavior/bugs/1025.zig"); |
| 21 | _ = @import("behavior/bugs/1076.zig"); | |
| 18 | 22 | _ = @import("behavior/bugs/1111.zig"); |
| 19 | 23 | _ = @import("behavior/bugs/1277.zig"); |
| 20 | 24 | _ = @import("behavior/bugs/1310.zig"); |
| ... | ... | @@ -27,149 +31,145 @@ test { |
| 27 | 31 | _ = @import("behavior/bugs/2006.zig"); |
| 28 | 32 | _ = @import("behavior/bugs/2346.zig"); |
| 29 | 33 | _ = @import("behavior/bugs/2578.zig"); |
| 34 | _ = @import("behavior/bugs/2692.zig"); | |
| 35 | _ = @import("behavior/bugs/2889.zig"); | |
| 30 | 36 | _ = @import("behavior/bugs/3007.zig"); |
| 37 | _ = @import("behavior/bugs/3046.zig"); | |
| 31 | 38 | _ = @import("behavior/bugs/3112.zig"); |
| 32 | 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 | 45 | _ = @import("behavior/bugs/6850.zig"); |
| 34 | 46 | _ = @import("behavior/bugs/7250.zig"); |
| 47 | _ = @import("behavior/call.zig"); | |
| 35 | 48 | _ = @import("behavior/cast.zig"); |
| 36 | 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 | 54 | _ = @import("behavior/fn_delegation.zig"); |
| 38 | 55 | _ = @import("behavior/fn_in_struct_in_comptime.zig"); |
| 56 | _ = @import("behavior/for.zig"); | |
| 57 | _ = @import("behavior/generics.zig"); | |
| 39 | 58 | _ = @import("behavior/hasdecl.zig"); |
| 40 | 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 | 65 | _ = @import("behavior/ir_block_deps.zig"); |
| 66 | _ = @import("behavior/member_func.zig"); | |
| 42 | 67 | _ = @import("behavior/namespace_depends_on_compile_var.zig"); |
| 68 | _ = @import("behavior/null.zig"); | |
| 43 | 69 | _ = @import("behavior/optional.zig"); |
| 44 | 70 | _ = @import("behavior/prefetch.zig"); |
| 71 | _ = @import("behavior/pointers.zig"); | |
| 45 | 72 | _ = @import("behavior/pub_enum.zig"); |
| 73 | _ = @import("behavior/ptrcast.zig"); | |
| 46 | 74 | _ = @import("behavior/reflection.zig"); |
| 75 | _ = @import("behavior/ref_var_in_if_after_if_2nd_switch_prong.zig"); | |
| 47 | 76 | _ = @import("behavior/slice.zig"); |
| 48 | 77 | _ = @import("behavior/slice_sentinel_comptime.zig"); |
| 49 | 78 | _ = @import("behavior/struct.zig"); |
| 79 | _ = @import("behavior/src.zig"); | |
| 80 | _ = @import("behavior/this.zig"); | |
| 50 | 81 | _ = @import("behavior/truncate.zig"); |
| 82 | _ = @import("behavior/try.zig"); | |
| 51 | 83 | _ = @import("behavior/tuple.zig"); |
| 52 | 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 | 90 | _ = @import("behavior/var_args.zig"); |
| 54 | _ = @import("behavior/int_div.zig"); | |
| 91 | _ = @import("behavior/void.zig"); | |
| 92 | _ = @import("behavior/while.zig"); | |
| 55 | 93 | |
| 56 | 94 | // tests that don't pass for stage1 |
| 57 | 95 | if (builtin.zig_backend != .stage1) { |
| 58 | 96 | _ = @import("behavior/decltest.zig"); |
| 59 | 97 | } |
| 60 | 98 | |
| 61 | if (builtin.zig_backend != .stage2_arm and builtin.zig_backend != .stage2_x86_64 and builtin.zig_backend != .stage2_aarch64) { | |
| 62 | // Tests that pass (partly) for stage1, llvm backend, C backend, wasm backend. | |
| 63 | _ = @import("behavior/bugs/624.zig"); | |
| 64 | _ = @import("behavior/bugs/704.zig"); | |
| 65 | _ = @import("behavior/bugs/1076.zig"); | |
| 66 | _ = @import("behavior/bugs/2692.zig"); | |
| 67 | _ = @import("behavior/bugs/2889.zig"); | |
| 68 | _ = @import("behavior/bugs/3046.zig"); | |
| 69 | _ = @import("behavior/bugs/3586.zig"); | |
| 70 | _ = @import("behavior/bugs/4560.zig"); | |
| 71 | _ = @import("behavior/bugs/4769_a.zig"); | |
| 72 | _ = @import("behavior/bugs/4769_b.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"); | |
| 99 | if (builtin.zig_backend != .stage2_arm and | |
| 100 | builtin.zig_backend != .stage2_x86_64 and | |
| 101 | builtin.zig_backend != .stage2_aarch64 and | |
| 102 | builtin.zig_backend != .stage2_wasm) | |
| 103 | { | |
| 104 | // Tests that pass for stage1, llvm backend, C backend | |
| 105 | _ = @import("behavior/bugs/9584.zig"); | |
| 106 | _ = @import("behavior/cast_int.zig"); | |
| 107 | _ = @import("behavior/eval.zig"); | |
| 108 | _ = @import("behavior/int128.zig"); | |
| 109 | _ = @import("behavior/merge_error_sets.zig"); | |
| 110 | _ = @import("behavior/translate_c_macros.zig"); | |
| 101 | 111 | |
| 102 | if (builtin.zig_backend != .stage2_wasm) { | |
| 103 | // Tests that pass for stage1, llvm backend, C backend | |
| 104 | _ = @import("behavior/bugs/9584.zig"); | |
| 105 | _ = @import("behavior/cast_int.zig"); | |
| 106 | _ = @import("behavior/eval.zig"); | |
| 107 | _ = @import("behavior/int128.zig"); | |
| 108 | _ = @import("behavior/merge_error_sets.zig"); | |
| 109 | _ = @import("behavior/translate_c_macros.zig"); | |
| 112 | if (builtin.zig_backend != .stage2_c) { | |
| 113 | // Tests that pass for stage1 and the llvm backend. | |
| 114 | _ = @import("behavior/atomics.zig"); | |
| 115 | _ = @import("behavior/floatop.zig"); | |
| 116 | _ = @import("behavior/math.zig"); | |
| 117 | _ = @import("behavior/maximum_minimum.zig"); | |
| 118 | _ = @import("behavior/popcount.zig"); | |
| 119 | _ = @import("behavior/saturating_arithmetic.zig"); | |
| 120 | _ = @import("behavior/sizeof_and_typeof.zig"); | |
| 121 | _ = @import("behavior/switch.zig"); | |
| 122 | _ = @import("behavior/widening.zig"); | |
| 110 | 123 | |
| 111 | if (builtin.zig_backend != .stage2_c) { | |
| 112 | // Tests that pass for stage1 and the llvm backend. | |
| 113 | _ = @import("behavior/atomics.zig"); | |
| 114 | _ = @import("behavior/floatop.zig"); | |
| 115 | _ = @import("behavior/math.zig"); | |
| 116 | _ = @import("behavior/maximum_minimum.zig"); | |
| 117 | _ = @import("behavior/popcount.zig"); | |
| 118 | _ = @import("behavior/saturating_arithmetic.zig"); | |
| 119 | _ = @import("behavior/sizeof_and_typeof.zig"); | |
| 120 | _ = @import("behavior/switch.zig"); | |
| 121 | _ = @import("behavior/widening.zig"); | |
| 124 | if (builtin.zig_backend == .stage1) { | |
| 125 | // Tests that only pass for the stage1 backend. | |
| 126 | if (builtin.os.tag != .wasi) { | |
| 127 | _ = @import("behavior/asm.zig"); | |
| 128 | _ = @import("behavior/async_fn.zig"); | |
| 129 | } | |
| 130 | _ = @import("behavior/await_struct.zig"); | |
| 131 | _ = @import("behavior/bugs/421.zig"); | |
| 132 | _ = @import("behavior/bugs/529.zig"); | |
| 133 | _ = @import("behavior/bugs/718.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 | 139 | _ = @import("behavior/bugs/1442.zig"); |
| 123 | ||
| 124 | if (builtin.zig_backend == .stage1) { | |
| 125 | // Tests that only pass for the stage1 backend. | |
| 126 | if (builtin.os.tag != .wasi) { | |
| 127 | _ = @import("behavior/asm.zig"); | |
| 128 | _ = @import("behavior/async_fn.zig"); | |
| 129 | } | |
| 130 | _ = @import("behavior/await_struct.zig"); | |
| 131 | _ = @import("behavior/bugs/421.zig"); | |
| 132 | _ = @import("behavior/bugs/529.zig"); | |
| 133 | _ = @import("behavior/bugs/718.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"); | |
| 139 | _ = @import("behavior/bugs/1607.zig"); | |
| 140 | _ = @import("behavior/bugs/1851.zig"); | |
| 141 | _ = @import("behavior/bugs/2114.zig"); | |
| 142 | _ = @import("behavior/bugs/3384.zig"); | |
| 143 | _ = @import("behavior/bugs/3742.zig"); | |
| 144 | _ = @import("behavior/bugs/3779.zig"); | |
| 145 | _ = @import("behavior/bugs/4328.zig"); | |
| 146 | _ = @import("behavior/bugs/5398.zig"); | |
| 147 | _ = @import("behavior/bugs/5413.zig"); | |
| 148 | _ = @import("behavior/bugs/5474.zig"); | |
| 149 | _ = @import("behavior/bugs/5487.zig"); | |
| 150 | _ = @import("behavior/bugs/6456.zig"); | |
| 151 | _ = @import("behavior/bugs/6781.zig"); | |
| 152 | _ = @import("behavior/bugs/7003.zig"); | |
| 153 | _ = @import("behavior/bugs/7027.zig"); | |
| 154 | _ = @import("behavior/bugs/7047.zig"); | |
| 155 | _ = @import("behavior/bugs/10147.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 | } | |
| 140 | _ = @import("behavior/bugs/1607.zig"); | |
| 141 | _ = @import("behavior/bugs/1851.zig"); | |
| 142 | _ = @import("behavior/bugs/2114.zig"); | |
| 143 | _ = @import("behavior/bugs/3384.zig"); | |
| 144 | _ = @import("behavior/bugs/3742.zig"); | |
| 145 | _ = @import("behavior/bugs/3779.zig"); | |
| 146 | _ = @import("behavior/bugs/4328.zig"); | |
| 147 | _ = @import("behavior/bugs/5398.zig"); | |
| 148 | _ = @import("behavior/bugs/5413.zig"); | |
| 149 | _ = @import("behavior/bugs/5474.zig"); | |
| 150 | _ = @import("behavior/bugs/5487.zig"); | |
| 151 | _ = @import("behavior/bugs/6456.zig"); | |
| 152 | _ = @import("behavior/bugs/6781.zig"); | |
| 153 | _ = @import("behavior/bugs/7003.zig"); | |
| 154 | _ = @import("behavior/bugs/7027.zig"); | |
| 155 | _ = @import("behavior/bugs/7047.zig"); | |
| 156 | _ = @import("behavior/bugs/10147.zig"); | |
| 157 | _ = @import("behavior/const_slice_child.zig"); | |
| 158 | _ = @import("behavior/export_self_referential_type_info.zig"); | |
| 159 | _ = @import("behavior/field_parent_ptr.zig"); | |
| 160 | _ = @import("behavior/misc.zig"); | |
| 161 | _ = @import("behavior/muladd.zig"); | |
| 162 | _ = @import("behavior/select.zig"); | |
| 163 | _ = @import("behavior/shuffle.zig"); | |
| 164 | _ = @import("behavior/struct_contains_null_ptr_itself.zig"); | |
| 165 | _ = @import("behavior/struct_contains_slice_of_itself.zig"); | |
| 166 | _ = @import("behavior/switch_prong_err_enum.zig"); | |
| 167 | _ = @import("behavior/switch_prong_implicit_cast.zig"); | |
| 168 | _ = @import("behavior/typename.zig"); | |
| 169 | _ = @import("behavior/union_with_members.zig"); | |
| 170 | _ = @import("behavior/vector.zig"); | |
| 171 | if (builtin.target.cpu.arch == .wasm32) { | |
| 172 | _ = @import("behavior/wasm.zig"); | |
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | } |
test/behavior/align.zig-6| ... | ... | @@ -180,8 +180,6 @@ fn noop4() align(4) void {} |
| 180 | 180 | test "function alignment" { |
| 181 | 181 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 182 | 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 | 183 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 186 | 184 | |
| 187 | 185 | // function alignment is a compile error on wasm32/wasm64 |
| ... | ... | @@ -199,7 +197,6 @@ test "implicitly decreasing fn alignment" { |
| 199 | 197 | if (builtin.zig_backend == .stage1) return error.SkipZigTest; |
| 200 | 198 | if (builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; |
| 201 | 199 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 202 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; | |
| 203 | 200 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 204 | 201 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 205 | 202 | |
| ... | ... | @@ -226,8 +223,6 @@ test "@alignCast functions" { |
| 226 | 223 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 227 | 224 | if (builtin.zig_backend == .stage1) return error.SkipZigTest; |
| 228 | 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 | 226 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 232 | 227 | |
| 233 | 228 | // function alignment is a compile error on wasm32/wasm64 |
| ... | ... | @@ -250,7 +245,6 @@ test "generic function with align param" { |
| 250 | 245 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 251 | 246 | if (builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; |
| 252 | 247 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 253 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; | |
| 254 | 248 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 255 | 249 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 256 | 250 |
test/behavior/array.zig+6-4| ... | ... | @@ -49,7 +49,7 @@ fn getArrayLen(a: []const u32) usize { |
| 49 | 49 | |
| 50 | 50 | test "array init with mult" { |
| 51 | 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; | |
| 53 | 53 | |
| 54 | 54 | const a = 'a'; |
| 55 | 55 | var i: [8]u8 = [2]u8{ a, 'b' } ** 4; |
| ... | ... | @@ -112,7 +112,7 @@ test "array len field" { |
| 112 | 112 | |
| 113 | 113 | test "array with sentinels" { |
| 114 | 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; | |
| 116 | 116 | |
| 117 | 117 | const S = struct { |
| 118 | 118 | fn doTheTest(is_ct: bool) !void { |
| ... | ... | @@ -179,7 +179,8 @@ fn plusOne(x: u32) u32 { |
| 179 | 179 | |
| 180 | 180 | test "single-item pointer to array indexing and slicing" { |
| 181 | 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; | |
| 183 | 184 | |
| 184 | 185 | try testSingleItemPtrArrayIndexSlice(); |
| 185 | 186 | comptime try testSingleItemPtrArrayIndexSlice(); |
| ... | ... | @@ -205,7 +206,8 @@ fn doSomeMangling(array: *[4]u8) void { |
| 205 | 206 | |
| 206 | 207 | test "implicit cast zero sized array ptr to slice" { |
| 207 | 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; | |
| 209 | 211 | |
| 210 | 212 | { |
| 211 | 213 | var b = "".*; |
test/behavior/basic.zig-6| ... | ... | @@ -117,7 +117,6 @@ fn first4KeysOfHomeRow() []const u8 { |
| 117 | 117 | test "return string from function" { |
| 118 | 118 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 119 | 119 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 120 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | |
| 121 | 120 | |
| 122 | 121 | try expect(mem.eql(u8, first4KeysOfHomeRow(), "aoeu")); |
| 123 | 122 | } |
| ... | ... | @@ -231,7 +230,6 @@ test "compile time global reinterpret" { |
| 231 | 230 | |
| 232 | 231 | test "cast undefined" { |
| 233 | 232 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 234 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | |
| 235 | 233 | |
| 236 | 234 | const array: [100]u8 = undefined; |
| 237 | 235 | const slice = @as([]const u8, &array); |
| ... | ... | @@ -303,7 +301,6 @@ test "call function pointer in struct" { |
| 303 | 301 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 304 | 302 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 305 | 303 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 306 | ||
| 307 | 304 | if (builtin.zig_backend == .stage1) return error.SkipZigTest; |
| 308 | 305 | |
| 309 | 306 | try expect(mem.eql(u8, f3(true), "a")); |
| ... | ... | @@ -382,7 +379,6 @@ fn testMemcpyMemset() !void { |
| 382 | 379 | test "variable is allowed to be a pointer to an opaque type" { |
| 383 | 380 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 384 | 381 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 385 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | |
| 386 | 382 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 387 | 383 | |
| 388 | 384 | var x: i32 = 1234; |
| ... | ... | @@ -425,7 +421,6 @@ test "array 2D const double ptr" { |
| 425 | 421 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 426 | 422 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 427 | 423 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 428 | ||
| 429 | 424 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO |
| 430 | 425 | |
| 431 | 426 | const rect_2d_vertexes = [_][1]f32{ |
| ... | ... | @@ -476,7 +471,6 @@ fn testArray2DConstDoublePtr(ptr: *const f32) !void { |
| 476 | 471 | test "double implicit cast in same expression" { |
| 477 | 472 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 478 | 473 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 479 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | |
| 480 | 474 | |
| 481 | 475 | var x = @as(i32, @as(u16, nine())); |
| 482 | 476 | try expect(x == 9); |
test/behavior/bugs/1076.zig+5| ... | ... | @@ -1,8 +1,13 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const mem = std.mem; |
| 3 | 4 | const expect = std.testing.expect; |
| 4 | 5 | |
| 5 | 6 | test "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 | 11 | try testCastPtrOfArrayToSliceAndPtr(); |
| 7 | 12 | comptime try testCastPtrOfArrayToSliceAndPtr(); |
| 8 | 13 | } |
test/behavior/bugs/1442.zig+3| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | |
| 3 | 4 | const Union = union(enum) { |
| 4 | 5 | Text: []const u8, |
| ... | ... | @@ -6,6 +7,8 @@ const Union = union(enum) { |
| 6 | 7 | }; |
| 7 | 8 | |
| 8 | 9 | test "const error union field alignment" { |
| 10 | if (builtin.zig_backend != .stage1) return error.SkipZigTest; | |
| 11 | ||
| 9 | 12 | var union_or_err: anyerror!Union = Union{ .Color = 1234 }; |
| 10 | 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 | const builtin = @import("builtin"); | |
| 2 | ||
| 1 | 3 | fn foo(a: []u8) void { |
| 2 | 4 | _ = a; |
| 3 | 5 | } |
| 4 | 6 | |
| 5 | 7 | test "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 | 11 | var pt: [0]u8 = undefined; |
| 7 | 12 | foo(&pt); |
| 8 | 13 | } |
test/behavior/bugs/2889.zig+5| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | |
| 3 | 4 | const source = "A-"; |
| 4 | 5 | |
| ... | ... | @@ -26,6 +27,10 @@ fn parseNote() ?i32 { |
| 26 | 27 | } |
| 27 | 28 | |
| 28 | 29 | test "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 | 34 | const result = parseNote(); |
| 30 | 35 | try std.testing.expect(result.? == 9); |
| 31 | 36 | } |
test/behavior/bugs/3046.zig+5-1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const expect = std.testing.expect; |
| 3 | 4 | |
| 4 | 5 | const SomeStruct = struct { |
| ... | ... | @@ -12,7 +13,10 @@ fn couldFail() anyerror!i32 { |
| 12 | 13 | var some_struct: SomeStruct = undefined; |
| 13 | 14 | |
| 14 | 15 | test "fixed" { |
| 15 | if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest; // TODO | |
| 16 | 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; | |
| 16 | 20 | |
| 17 | 21 | some_struct = SomeStruct{ |
| 18 | 22 | .field = couldFail() catch @as(i32, 0), |
test/behavior/bugs/3586.zig+5| ... | ... | @@ -1,3 +1,5 @@ |
| 1 | const builtin = @import("builtin"); | |
| 2 | ||
| 1 | 3 | const NoteParams = struct {}; |
| 2 | 4 | |
| 3 | 5 | const Container = struct { |
| ... | ... | @@ -5,6 +7,9 @@ const Container = struct { |
| 5 | 7 | }; |
| 6 | 8 | |
| 7 | 9 | test "fixed" { |
| 10 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 11 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 12 | ||
| 8 | 13 | var ctr = Container{ |
| 9 | 14 | .params = NoteParams{}, |
| 10 | 15 | }; |
test/behavior/bugs/4560.zig+4| ... | ... | @@ -1,6 +1,10 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | |
| 3 | 4 | test "fixed" { |
| 5 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 6 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 7 | ||
| 4 | 8 | var s: S = .{ |
| 5 | 9 | .a = 1, |
| 6 | 10 | .b = .{ |
test/behavior/bugs/4954.zig+6| ... | ... | @@ -1,8 +1,14 @@ |
| 1 | const builtin = @import("builtin"); | |
| 2 | ||
| 1 | 3 | fn f(buf: []u8) void { |
| 2 | 4 | _ = &buf[@sizeOf(u32)]; |
| 3 | 5 | } |
| 4 | 6 | |
| 5 | 7 | test "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 | 12 | var buf: [4096]u8 = undefined; |
| 7 | 13 | f(&buf); |
| 8 | 14 | } |
test/behavior/bugs/624.zig+4| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const expect = std.testing.expect; |
| 3 | 4 | |
| 4 | 5 | const TestContext = struct { |
| ... | ... | @@ -19,6 +20,9 @@ fn MemoryPool(comptime T: type) type { |
| 19 | 20 | } |
| 20 | 21 | |
| 21 | 22 | test "foo" { |
| 23 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 24 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 25 | ||
| 22 | 26 | var allocator = ContextAllocator{ .n = 10 }; |
| 23 | 27 | try expect(allocator.n == 10); |
| 24 | 28 | } |
test/behavior/bugs/704.zig+5| ... | ... | @@ -1,9 +1,14 @@ |
| 1 | const builtin = @import("builtin"); | |
| 2 | ||
| 1 | 3 | const xxx = struct { |
| 2 | 4 | pub fn bar(self: *xxx) void { |
| 3 | 5 | _ = self; |
| 4 | 6 | } |
| 5 | 7 | }; |
| 6 | 8 | test "bug 704" { |
| 9 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 10 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 11 | ||
| 7 | 12 | var x: xxx = undefined; |
| 8 | 13 | x.bar(); |
| 9 | 14 | } |
test/behavior/byval_arg_var.zig+5| ... | ... | @@ -1,8 +1,13 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | |
| 3 | 4 | var result: []const u8 = "wrong"; |
| 4 | 5 | |
| 5 | 6 | test "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 | 11 | start(); |
| 7 | 12 | blowUpStack(10); |
| 8 | 13 |
test/behavior/defer.zig+13| ... | ... | @@ -5,6 +5,9 @@ const expectEqual = std.testing.expectEqual; |
| 5 | 5 | const expectError = std.testing.expectError; |
| 6 | 6 | |
| 7 | 7 | test "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 | 11 | testBreakContInDefer(10); |
| 9 | 12 | comptime testBreakContInDefer(10); |
| 10 | 13 | } |
| ... | ... | @@ -21,6 +24,9 @@ fn testBreakContInDefer(x: usize) void { |
| 21 | 24 | } |
| 22 | 25 | |
| 23 | 26 | test "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 | 30 | var i = @as(usize, 0); |
| 25 | 31 | |
| 26 | 32 | blk: { |
| ... | ... | @@ -32,6 +38,9 @@ test "defer and labeled break" { |
| 32 | 38 | } |
| 33 | 39 | |
| 34 | 40 | test "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 | 44 | if (testNestedFnErrDefer()) |_| @panic("expected error") else |e| try expect(e == error.Bad); |
| 36 | 45 | } |
| 37 | 46 | |
| ... | ... | @@ -47,6 +56,10 @@ fn testNestedFnErrDefer() anyerror!void { |
| 47 | 56 | } |
| 48 | 57 | |
| 49 | 58 | test "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 | 63 | const S = struct { |
| 51 | 64 | fn doTheTest() !void { |
| 52 | 65 | try expect(notNull().? == 1); |
test/behavior/enum.zig+110| ... | ... | @@ -11,6 +11,9 @@ fn shouldEqual(n: Number, expected: u3) !void { |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | test "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 | 17 | try shouldEqual(Number.Zero, 0); |
| 15 | 18 | try shouldEqual(Number.One, 1); |
| 16 | 19 | try shouldEqual(Number.Two, 2); |
| ... | ... | @@ -24,6 +27,9 @@ fn testIntToEnumEval(x: i32) !void { |
| 24 | 27 | const IntToEnumNumber = enum { Zero, One, Two, Three, Four }; |
| 25 | 28 | |
| 26 | 29 | test "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 | 33 | try testIntToEnumEval(3); |
| 28 | 34 | } |
| 29 | 35 | |
| ... | ... | @@ -553,6 +559,9 @@ const ValueCount257 = enum { |
| 553 | 559 | }; |
| 554 | 560 | |
| 555 | 561 | test "enum sizes" { |
| 562 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 563 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 564 | ||
| 556 | 565 | comptime { |
| 557 | 566 | try expect(@sizeOf(ValueCount1) == 0); |
| 558 | 567 | try expect(@sizeOf(ValueCount2) == 1); |
| ... | ... | @@ -562,6 +571,9 @@ test "enum sizes" { |
| 562 | 571 | } |
| 563 | 572 | |
| 564 | 573 | test "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 | 577 | const x = .hi; |
| 566 | 578 | const y = .ok; |
| 567 | 579 | const z = .hi; |
| ... | ... | @@ -571,6 +583,9 @@ test "enum literal equality" { |
| 571 | 583 | } |
| 572 | 584 | |
| 573 | 585 | test "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 | 589 | const Color = enum { Auto, Off, On }; |
| 575 | 590 | |
| 576 | 591 | var color1: Color = .Auto; |
| ... | ... | @@ -579,6 +594,9 @@ test "enum literal cast to enum" { |
| 579 | 594 | } |
| 580 | 595 | |
| 581 | 596 | test "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 | 600 | const Items = enum { one, two }; |
| 583 | 601 | |
| 584 | 602 | try expect(Items.two == .two); |
| ... | ... | @@ -603,11 +621,19 @@ fn testEnumWithSpecifiedTagValues(x: MultipleChoice) !void { |
| 603 | 621 | } |
| 604 | 622 | |
| 605 | 623 | test "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 | 628 | try testEnumWithSpecifiedTagValues(MultipleChoice.C); |
| 607 | 629 | comptime try testEnumWithSpecifiedTagValues(MultipleChoice.C); |
| 608 | 630 | } |
| 609 | 631 | |
| 610 | 632 | test "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 | 637 | const S = struct { |
| 612 | 638 | const E = enum(u8) { a, b, _ }; |
| 613 | 639 | |
| ... | ... | @@ -649,6 +675,9 @@ test "non-exhaustive enum" { |
| 649 | 675 | } |
| 650 | 676 | |
| 651 | 677 | test "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 | 681 | const S = struct { |
| 653 | 682 | const E = enum(u8) { _ }; |
| 654 | 683 | |
| ... | ... | @@ -668,6 +697,10 @@ test "empty non-exhaustive enum" { |
| 668 | 697 | } |
| 669 | 698 | |
| 670 | 699 | test "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 | 704 | const S = struct { |
| 672 | 705 | const E = enum(u8) { a, _ }; |
| 673 | 706 | fn doTheTest(y: u8) !void { |
| ... | ... | @@ -708,6 +741,9 @@ const EnumWithTagValues = enum(u4) { |
| 708 | 741 | D = 1 << 3, |
| 709 | 742 | }; |
| 710 | 743 | test "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 | 747 | try expect(@enumToInt(EnumWithTagValues.C) == 0b0100); |
| 712 | 748 | } |
| 713 | 749 | |
| ... | ... | @@ -724,11 +760,18 @@ const MultipleChoice2 = enum(u32) { |
| 724 | 760 | }; |
| 725 | 761 | |
| 726 | 762 | test "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 | 766 | try expect(@intToEnum(MultipleChoice2, 0) == MultipleChoice2.Unspecified1); |
| 728 | 767 | try expect(@intToEnum(MultipleChoice2, 40) == MultipleChoice2.B); |
| 729 | 768 | } |
| 730 | 769 | |
| 731 | 770 | test "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 | 775 | try testEnumWithSpecifiedAndUnspecifiedTagValues(MultipleChoice2.D); |
| 733 | 776 | comptime try testEnumWithSpecifiedAndUnspecifiedTagValues(MultipleChoice2.D); |
| 734 | 777 | } |
| ... | ... | @@ -752,6 +795,9 @@ const Small2 = enum(u2) { One, Two }; |
| 752 | 795 | const Small = enum(u2) { One, Two, Three, Four }; |
| 753 | 796 | |
| 754 | 797 | test "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 | 802 | var x = Small.One; |
| 757 | 803 | x = Small.Two; |
| ... | ... | @@ -765,6 +811,9 @@ test "set enum tag type" { |
| 765 | 811 | } |
| 766 | 812 | |
| 767 | 813 | test "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 | 817 | try testCastEnumTag(Small2.Two); |
| 769 | 818 | comptime try testCastEnumTag(Small2.Two); |
| 770 | 819 | } |
| ... | ... | @@ -774,6 +823,9 @@ fn testCastEnumTag(value: Small2) !void { |
| 774 | 823 | } |
| 775 | 824 | |
| 776 | 825 | test "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 | 829 | const Enum = enum(u8) { |
| 778 | 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 | 833 | } |
| 782 | 834 | |
| 783 | 835 | test "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 | 839 | const SignedEnum = enum(i2) { |
| 785 | 840 | A0 = -1, |
| 786 | 841 | A1 = 0, |
| ... | ... | @@ -793,6 +848,9 @@ test "signed integer as enum tag" { |
| 793 | 848 | } |
| 794 | 849 | |
| 795 | 850 | test "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 | 854 | const E = enum(u2) { |
| 797 | 855 | One, |
| 798 | 856 | }; |
| ... | ... | @@ -804,6 +862,9 @@ test "enum with one member and custom tag type" { |
| 804 | 862 | } |
| 805 | 863 | |
| 806 | 864 | test "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 | 868 | const Enum = enum(u1) { |
| 808 | 869 | Test, |
| 809 | 870 | }; |
| ... | ... | @@ -811,6 +872,9 @@ test "enum with one member and u1 tag type @enumToInt" { |
| 811 | 872 | } |
| 812 | 873 | |
| 813 | 874 | test "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 | 878 | const Enum = enum(comptime_int) { |
| 815 | 879 | One = 3, |
| 816 | 880 | Two = 2, |
| ... | ... | @@ -820,6 +884,9 @@ test "enum with comptime_int tag type" { |
| 820 | 884 | } |
| 821 | 885 | |
| 822 | 886 | test "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 | 890 | const E0 = enum { X }; |
| 824 | 891 | comptime try expect(Tag(E0) == u0); |
| 825 | 892 | } |
| ... | ... | @@ -836,11 +903,17 @@ fn doALoopThing(id: EnumWithOneMember) void { |
| 836 | 903 | } |
| 837 | 904 | |
| 838 | 905 | test "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 | 909 | doALoopThing(EnumWithOneMember.Eof); |
| 840 | 910 | } |
| 841 | 911 | |
| 842 | 912 | const State = enum { Start }; |
| 843 | 913 | test "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 | 917 | var state = State.Start; |
| 845 | 918 | switch (state) { |
| 846 | 919 | State.Start => return, |
| ... | ... | @@ -849,6 +922,9 @@ test "switch on enum with one member is comptime known" { |
| 849 | 922 | } |
| 850 | 923 | |
| 851 | 924 | test "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 | 928 | const S = struct { |
| 853 | 929 | const E = enum { |
| 854 | 930 | one, |
| ... | ... | @@ -885,6 +961,10 @@ test "enum value allocation" { |
| 885 | 961 | } |
| 886 | 962 | |
| 887 | 963 | test "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 | 968 | const Arch = union(enum) { |
| 889 | 969 | x86_64, |
| 890 | 970 | arm: Arm32, |
| ... | ... | @@ -930,6 +1010,11 @@ test "exporting enum type and value" { |
| 930 | 1010 | } |
| 931 | 1011 | |
| 932 | 1012 | test "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 | 1018 | try test3_1(test3_foo); |
| 934 | 1019 | try test3_2(test3_bar); |
| 935 | 1020 | } |
| ... | ... | @@ -970,6 +1055,9 @@ fn test3_2(f: Test3Foo) !void { |
| 970 | 1055 | test "@tagName" { |
| 971 | 1056 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 972 | 1057 | 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; | |
| 973 | 1061 | |
| 974 | 1062 | try expect(mem.eql(u8, testEnumTagNameBare(BareNumber.Three), "Three")); |
| 975 | 1063 | comptime try expect(mem.eql(u8, testEnumTagNameBare(BareNumber.Three), "Three")); |
| ... | ... | @@ -984,6 +1072,9 @@ const BareNumber = enum { One, Two, Three }; |
| 984 | 1072 | test "@tagName non-exhaustive enum" { |
| 985 | 1073 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 986 | 1074 | 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; | |
| 987 | 1078 | |
| 988 | 1079 | try expect(mem.eql(u8, testEnumTagNameBare(NonExhaustive.B), "B")); |
| 989 | 1080 | comptime try expect(mem.eql(u8, testEnumTagNameBare(NonExhaustive.B), "B")); |
| ... | ... | @@ -993,6 +1084,9 @@ const NonExhaustive = enum(u8) { A, B, _ }; |
| 993 | 1084 | test "@tagName is null-terminated" { |
| 994 | 1085 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 995 | 1086 | 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; | |
| 996 | 1090 | |
| 997 | 1091 | const S = struct { |
| 998 | 1092 | fn doTheTest(n: BareNumber) !void { |
| ... | ... | @@ -1006,6 +1100,9 @@ test "@tagName is null-terminated" { |
| 1006 | 1100 | test "tag name with assigned enum values" { |
| 1007 | 1101 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 1008 | 1102 | 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; | |
| 1009 | 1106 | |
| 1010 | 1107 | const LocalFoo = enum(u8) { |
| 1011 | 1108 | A = 1, |
| ... | ... | @@ -1016,11 +1113,18 @@ test "tag name with assigned enum values" { |
| 1016 | 1113 | } |
| 1017 | 1114 | |
| 1018 | 1115 | test "@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 | 1119 | try expect(mem.eql(u8, @tagName(.FooBar), "FooBar")); |
| 1020 | 1120 | comptime try expect(mem.eql(u8, @tagName(.FooBar), "FooBar")); |
| 1021 | 1121 | } |
| 1022 | 1122 | |
| 1023 | 1123 | test "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 | 1128 | var bar: ?Bar = undefined; |
| 1025 | 1129 | bar = .B; |
| 1026 | 1130 | |
| ... | ... | @@ -1045,6 +1149,9 @@ const bit_field_1 = BitFieldOfEnums{ |
| 1045 | 1149 | |
| 1046 | 1150 | test "bit field access with enum fields" { |
| 1047 | 1151 | 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; | |
| 1048 | 1155 | |
| 1049 | 1156 | var data = bit_field_1; |
| 1050 | 1157 | try expect(getA(&data) == A.Two); |
| ... | ... | @@ -1073,6 +1180,9 @@ fn getC(data: *const BitFieldOfEnums) C { |
| 1073 | 1180 | } |
| 1074 | 1181 | |
| 1075 | 1182 | test "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 | 1186 | const Items = enum { one, two }; |
| 1077 | 1187 | const array = [_]Items{ .one, .two }; |
| 1078 | 1188 |
test/behavior/error.zig+48| ... | ... | @@ -6,12 +6,18 @@ const expectEqual = std.testing.expectEqual; |
| 6 | 6 | const mem = std.mem; |
| 7 | 7 | |
| 8 | 8 | test "error values" { |
| 9 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 10 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 11 | ||
| 9 | 12 | const a = @errorToInt(error.err1); |
| 10 | 13 | const b = @errorToInt(error.err2); |
| 11 | 14 | try expect(a != b); |
| 12 | 15 | } |
| 13 | 16 | |
| 14 | 17 | test "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 | 21 | shouldBeNotEqual(error.AnError, error.SecondError); |
| 16 | 22 | } |
| 17 | 23 | fn shouldBeNotEqual(a: anyerror, b: anyerror) void { |
| ... | ... | @@ -19,6 +25,10 @@ fn shouldBeNotEqual(a: anyerror, b: anyerror) void { |
| 19 | 25 | } |
| 20 | 26 | |
| 21 | 27 | test "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 | 32 | const a = errBinaryOperatorG(true) catch 3; |
| 23 | 33 | const b = errBinaryOperatorG(false) catch 3; |
| 24 | 34 | try expect(a == 3); |
| ... | ... | @@ -29,6 +39,9 @@ fn errBinaryOperatorG(x: bool) anyerror!isize { |
| 29 | 39 | } |
| 30 | 40 | |
| 31 | 41 | test "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 | 45 | const x = error{} || error{}; |
| 33 | 46 | _ = x; |
| 34 | 47 | } |
| ... | ... | @@ -48,10 +61,18 @@ pub fn baz() anyerror!i32 { |
| 48 | 61 | } |
| 49 | 62 | |
| 50 | 63 | test "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 | 68 | try expect((baz() catch unreachable) == 15); |
| 52 | 69 | } |
| 53 | 70 | |
| 54 | 71 | test "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 | 76 | const i = unwrapSimpleValueFromErrorDo() catch unreachable; |
| 56 | 77 | try expect(i == 13); |
| 57 | 78 | } |
| ... | ... | @@ -60,6 +81,10 @@ fn unwrapSimpleValueFromErrorDo() anyerror!isize { |
| 60 | 81 | } |
| 61 | 82 | |
| 62 | 83 | test "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 | 88 | doErrReturnInAssignment() catch unreachable; |
| 64 | 89 | } |
| 65 | 90 | |
| ... | ... | @@ -73,12 +98,19 @@ fn makeANonErr() anyerror!i32 { |
| 73 | 98 | } |
| 74 | 99 | |
| 75 | 100 | test "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 | 104 | comptime { |
| 77 | 105 | try expect(?(anyerror!i32) == ?(anyerror!i32)); |
| 78 | 106 | } |
| 79 | 107 | } |
| 80 | 108 | |
| 81 | 109 | test "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 | 114 | const S = struct { |
| 83 | 115 | fn errorable() !u64 { |
| 84 | 116 | var x = @as(u64, try number()); |
| ... | ... | @@ -93,12 +125,19 @@ test "widen cast integer payload of error union function call" { |
| 93 | 125 | } |
| 94 | 126 | |
| 95 | 127 | test "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 | 132 | const SomeError = error{Hello}; |
| 97 | 133 | var a_local_variable: ?SomeError = null; |
| 98 | 134 | _ = a_local_variable; |
| 99 | 135 | } |
| 100 | 136 | |
| 101 | 137 | test "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 | 141 | const S = struct { |
| 103 | 142 | fn entry() !void { |
| 104 | 143 | var x: Foo = undefined; |
| ... | ... | @@ -118,6 +157,9 @@ test "implicit cast to optional to error union to return result loc" { |
| 118 | 157 | } |
| 119 | 158 | |
| 120 | 159 | test "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 | 163 | entry(); |
| 122 | 164 | comptime entry(); |
| 123 | 165 | } |
| ... | ... | @@ -482,6 +524,9 @@ test "error union comptime caching" { |
| 482 | 524 | test "@errorName" { |
| 483 | 525 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 484 | 526 | 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; | |
| 485 | 530 | |
| 486 | 531 | try expect(mem.eql(u8, @errorName(error.AnError), "AnError")); |
| 487 | 532 | try expect(mem.eql(u8, @errorName(error.ALongerErrorName), "ALongerErrorName")); |
| ... | ... | @@ -494,6 +539,9 @@ fn gimmeItBroke() anyerror { |
| 494 | 539 | test "@errorName sentinel length matches slice length" { |
| 495 | 540 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 496 | 541 | 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; | |
| 497 | 545 | |
| 498 | 546 | const name = testBuiltinErrorName(error.FooBar); |
| 499 | 547 | const length: usize = 6; |
test/behavior/fn.zig+71| ... | ... | @@ -5,6 +5,9 @@ const expect = testing.expect; |
| 5 | 5 | const expectEqual = testing.expectEqual; |
| 6 | 6 | |
| 7 | 7 | test "params" { |
| 8 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 9 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 10 | ||
| 8 | 11 | try expect(testParamsAdd(22, 11) == 33); |
| 9 | 12 | } |
| 10 | 13 | fn testParamsAdd(a: i32, b: i32) i32 { |
| ... | ... | @@ -12,6 +15,9 @@ fn testParamsAdd(a: i32, b: i32) i32 { |
| 12 | 15 | } |
| 13 | 16 | |
| 14 | 17 | test "local variables" { |
| 18 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 19 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 20 | ||
| 15 | 21 | testLocVars(2); |
| 16 | 22 | } |
| 17 | 23 | fn testLocVars(b: i32) void { |
| ... | ... | @@ -20,6 +26,9 @@ fn testLocVars(b: i32) void { |
| 20 | 26 | } |
| 21 | 27 | |
| 22 | 28 | test "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 | 32 | var zero: i32 = 0; |
| 24 | 33 | try expect(zero == 0); |
| 25 | 34 | |
| ... | ... | @@ -31,6 +40,9 @@ test "mutable local variables" { |
| 31 | 40 | } |
| 32 | 41 | |
| 33 | 42 | test "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 | 47 | const no_conflict: i32 = 5; |
| 36 | 48 | try expect(no_conflict == 5); |
| ... | ... | @@ -47,10 +59,16 @@ fn @"weird function name"() i32 { |
| 47 | 59 | return 1234; |
| 48 | 60 | } |
| 49 | 61 | test "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 | 65 | try expect(@"weird function name"() == 1234); |
| 51 | 66 | } |
| 52 | 67 | |
| 53 | 68 | test "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 | 72 | const a = inlineFn; |
| 55 | 73 | a(); |
| 56 | 74 | } |
| ... | ... | @@ -68,6 +86,9 @@ fn outer(y: u32) *const fn (u32) u32 { |
| 68 | 86 | } |
| 69 | 87 | |
| 70 | 88 | test "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 | 92 | if (builtin.zig_backend == .stage1) return error.SkipZigTest; |
| 72 | 93 | |
| 73 | 94 | var func = outer(10); |
| ... | ... | @@ -76,6 +97,9 @@ test "return inner function which references comptime variable of outer function |
| 76 | 97 | |
| 77 | 98 | test "discard the result of a function that returns a struct" { |
| 78 | 99 | 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 | 103 | const S = struct { |
| 80 | 104 | fn entry() void { |
| 81 | 105 | _ = func(); |
| ... | ... | @@ -97,6 +121,9 @@ test "discard the result of a function that returns a struct" { |
| 97 | 121 | test "inline function call that calls optional function pointer, return pointer at callsite interacts correctly with callsite return type" { |
| 98 | 122 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 99 | 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; | |
| 100 | 127 | |
| 101 | 128 | const S = struct { |
| 102 | 129 | field: u32, |
| ... | ... | @@ -129,6 +156,9 @@ test "inline function call that calls optional function pointer, return pointer |
| 129 | 156 | } |
| 130 | 157 | |
| 131 | 158 | test "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 | 162 | wantsFnWithVoid(fnWithUnreachable); |
| 133 | 163 | } |
| 134 | 164 | |
| ... | ... | @@ -143,6 +173,8 @@ fn fnWithUnreachable() noreturn { |
| 143 | 173 | test "extern struct with stdcallcc fn pointer" { |
| 144 | 174 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 145 | 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; | |
| 146 | 178 | |
| 147 | 179 | const S = extern struct { |
| 148 | 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 | 202 | } |
| 171 | 203 | |
| 172 | 204 | test "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 | 208 | try expect(fComplexCallconvRet(3).x == 9); |
| 174 | 209 | } |
| 175 | 210 | |
| 176 | 211 | test "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 | 215 | try expect(addPointCoords(Point{ .x = 1, .y = 2 }) == 3); |
| 178 | 216 | } |
| 179 | 217 | |
| ... | ... | @@ -187,6 +225,10 @@ fn addPointCoords(pt: Point) i32 { |
| 187 | 225 | } |
| 188 | 226 | |
| 189 | 227 | test "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 | 232 | try expect((try addPointCoordsVar(Point{ .x = 1, .y = 2 })) == 3); |
| 191 | 233 | } |
| 192 | 234 | |
| ... | ... | @@ -196,6 +238,9 @@ fn addPointCoordsVar(pt: anytype) !i32 { |
| 196 | 238 | } |
| 197 | 239 | |
| 198 | 240 | test "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 | 244 | var pt = Point2{ .x = 1, .y = 2 }; |
| 200 | 245 | try expect(pt.addPointCoords() == 3); |
| 201 | 246 | } |
| ... | ... | @@ -210,6 +255,9 @@ const Point2 = struct { |
| 210 | 255 | }; |
| 211 | 256 | |
| 212 | 257 | test "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 | 261 | var pt = Point3{ .x = 1, .y = 2 }; |
| 214 | 262 | try expect(pt.addPointCoords(i32) == 3); |
| 215 | 263 | } |
| ... | ... | @@ -225,6 +273,9 @@ const Point3 = struct { |
| 225 | 273 | }; |
| 226 | 274 | |
| 227 | 275 | test "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 | 279 | comptime { |
| 229 | 280 | var pt = Point2{ .x = 1, .y = 2 }; |
| 230 | 281 | try expect(pt.addPointCoords() == 3); |
| ... | ... | @@ -232,6 +283,9 @@ test "pass by non-copying value as method, at comptime" { |
| 232 | 283 | } |
| 233 | 284 | |
| 234 | 285 | test "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 | 289 | const S = struct { |
| 236 | 290 | fn entry() !void { |
| 237 | 291 | var x = Foo{ |
| ... | ... | @@ -255,6 +309,10 @@ test "implicit cast fn call result to optional in field result" { |
| 255 | 309 | } |
| 256 | 310 | |
| 257 | 311 | test "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 | 316 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 259 | 317 | try voidFun(1, void{}, 2, {}); |
| 260 | 318 | } |
| ... | ... | @@ -267,6 +325,9 @@ fn voidFun(a: i32, b: void, c: i32, d: void) !void { |
| 267 | 325 | } |
| 268 | 326 | |
| 269 | 327 | test "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 | 331 | acceptsString(""); |
| 271 | 332 | } |
| 272 | 333 | |
| ... | ... | @@ -301,6 +362,9 @@ fn fn4() u32 { |
| 301 | 362 | } |
| 302 | 363 | |
| 303 | 364 | test "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 | 368 | try numberLiteralArg(3); |
| 305 | 369 | comptime try numberLiteralArg(3); |
| 306 | 370 | } |
| ... | ... | @@ -311,6 +375,10 @@ fn numberLiteralArg(a: anytype) !void { |
| 311 | 375 | |
| 312 | 376 | test "function call with anon list literal" { |
| 313 | 377 | 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 | 382 | const S = struct { |
| 315 | 383 | fn doTheTest() !void { |
| 316 | 384 | try consumeVec(.{ 9, 8, 7 }); |
| ... | ... | @@ -327,6 +395,9 @@ test "function call with anon list literal" { |
| 327 | 395 | } |
| 328 | 396 | |
| 329 | 397 | test "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 | 401 | const S = struct { |
| 331 | 402 | fn doTheTest() !void { |
| 332 | 403 | var x: i32 = 1; |
test/behavior/for.zig+23-1| ... | ... | @@ -5,6 +5,9 @@ const expectEqual = std.testing.expectEqual; |
| 5 | 5 | const mem = std.mem; |
| 6 | 6 | |
| 7 | 7 | test "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 | 11 | const array = [_]i32{ 1, 2, 3, 4, 5 }; |
| 9 | 12 | var sum: i32 = 0; |
| 10 | 13 | for (array) |x| { |
| ... | ... | @@ -18,6 +21,9 @@ test "continue in for loop" { |
| 18 | 21 | } |
| 19 | 22 | |
| 20 | 23 | test "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 | 27 | try testBreakOuter(); |
| 22 | 28 | comptime try testBreakOuter(); |
| 23 | 29 | } |
| ... | ... | @@ -35,6 +41,9 @@ fn testBreakOuter() !void { |
| 35 | 41 | } |
| 36 | 42 | |
| 37 | 43 | test "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 | 47 | try testContinueOuter(); |
| 39 | 48 | comptime try testContinueOuter(); |
| 40 | 49 | } |
| ... | ... | @@ -52,6 +61,9 @@ fn testContinueOuter() !void { |
| 52 | 61 | } |
| 53 | 62 | |
| 54 | 63 | test "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 | 67 | for ([_]void{}) |_, i| { |
| 56 | 68 | _ = i; |
| 57 | 69 | for ([_]void{}) |_, j| { |
| ... | ... | @@ -63,7 +75,10 @@ test "ignore lval with underscore (for loop)" { |
| 63 | 75 | } |
| 64 | 76 | |
| 65 | 77 | test "basic for loop" { |
| 66 | if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest; // TODO | |
| 78 | 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; | |
| 67 | 82 | |
| 68 | 83 | const expected_result = [_]u8{ 9, 8, 7, 6, 0, 1, 2, 3 } ** 3; |
| 69 | 84 | |
| ... | ... | @@ -104,6 +119,10 @@ test "basic for loop" { |
| 104 | 119 | } |
| 105 | 120 | |
| 106 | 121 | test "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 | 126 | const S = struct { |
| 108 | 127 | fn doTheTest(slice: []const u8) !void { |
| 109 | 128 | if (for (slice) |item| { |
| ... | ... | @@ -121,6 +140,9 @@ test "for with null and T peer types and inferred result location type" { |
| 121 | 140 | } |
| 122 | 141 | |
| 123 | 142 | test "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 | 146 | const S = struct { |
| 125 | 147 | fn entry(t: bool, f: bool) !void { |
| 126 | 148 | var buf: [10]u8 = undefined; |
test/behavior/generics.zig+41-2| ... | ... | @@ -5,6 +5,9 @@ const expect = testing.expect; |
| 5 | 5 | const expectEqual = testing.expectEqual; |
| 6 | 6 | |
| 7 | 7 | test "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 | 11 | var x: usize = 0; |
| 9 | 12 | x += checkSize(i32); |
| 10 | 13 | x += checkSize(bool); |
| ... | ... | @@ -17,6 +20,9 @@ fn checkSize(comptime T: type) usize { |
| 17 | 20 | } |
| 18 | 21 | |
| 19 | 22 | test "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 | 26 | try expect(max(i32, 3, -1) == 3); |
| 21 | 27 | try expect(max(u8, 1, 100) == 100); |
| 22 | 28 | if (builtin.zig_backend == .stage1) { |
| ... | ... | @@ -37,6 +43,9 @@ fn add(comptime a: i32, b: i32) i32 { |
| 37 | 43 | |
| 38 | 44 | const the_max = max(u32, 1234, 5678); |
| 39 | 45 | test "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 | 49 | try expect(the_max == 5678); |
| 41 | 50 | } |
| 42 | 51 | |
| ... | ... | @@ -53,12 +62,20 @@ fn sameButWithFloats(a: f64, b: f64) f64 { |
| 53 | 62 | } |
| 54 | 63 | |
| 55 | 64 | test "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 | 69 | try expect(gimmeTheBigOne(1234, 5678) == 5678); |
| 57 | 70 | try expect(shouldCallSameInstance(34, 12) == 34); |
| 58 | 71 | try expect(sameButWithFloats(0.43, 0.49) == 0.49); |
| 59 | 72 | } |
| 60 | 73 | |
| 61 | 74 | test "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 | 79 | try expect(max_i32(12, 34) == 34); |
| 63 | 80 | try expect(max_f64(1.2, 3.4) == 3.4); |
| 64 | 81 | comptime { |
| ... | ... | @@ -80,6 +97,10 @@ fn max_f64(a: f64, b: f64) f64 { |
| 80 | 97 | } |
| 81 | 98 | |
| 82 | 99 | test "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 | 104 | var l: SimpleList(10) = undefined; |
| 84 | 105 | l.array[0] = 10; |
| 85 | 106 | l.array[1] = 11; |
| ... | ... | @@ -99,6 +120,9 @@ fn SimpleList(comptime L: usize) type { |
| 99 | 120 | } |
| 100 | 121 | |
| 101 | 122 | test "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 | 126 | var list: List(i32) = undefined; |
| 103 | 127 | var list2: List(i32) = undefined; |
| 104 | 128 | list.length = 10; |
| ... | ... | @@ -120,6 +144,9 @@ pub fn SmallList(comptime T: type, comptime STATIC_SIZE: usize) type { |
| 120 | 144 | } |
| 121 | 145 | |
| 122 | 146 | test "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 | 150 | try expect(GenericDataThing(3).count_plus_one == 4); |
| 124 | 151 | } |
| 125 | 152 | fn GenericDataThing(comptime count: isize) type { |
| ... | ... | @@ -129,6 +156,9 @@ fn GenericDataThing(comptime count: isize) type { |
| 129 | 156 | } |
| 130 | 157 | |
| 131 | 158 | test "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 | 162 | try expect(aGenericFn(i32, 3, 4) == 7); |
| 133 | 163 | } |
| 134 | 164 | 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 | } |
| 137 | 167 | |
| 138 | 168 | test "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 | 172 | try expect(getFirstByte(u8, &[_]u8{13}) == 13); |
| 140 | 173 | try expect(getFirstByte(u16, &[_]u16{ |
| 141 | 174 | 0, |
| ... | ... | @@ -150,6 +183,9 @@ fn getFirstByte(comptime T: type, mem: []const T) u8 { |
| 150 | 183 | } |
| 151 | 184 | |
| 152 | 185 | test "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 | 189 | const A = 128; |
| 154 | 190 | |
| 155 | 191 | const S = struct { |
| ... | ... | @@ -165,8 +201,10 @@ test "generic fn keeps non-generic parameter types" { |
| 165 | 201 | } |
| 166 | 202 | |
| 167 | 203 | test "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 | 206 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 169 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | |
| 207 | ||
| 170 | 208 | try expect(foos[0](true)); |
| 171 | 209 | try expect(!foos[1](true)); |
| 172 | 210 | } |
| ... | ... | @@ -185,7 +223,8 @@ fn foo2(arg: anytype) bool { |
| 185 | 223 | |
| 186 | 224 | test "generic struct" { |
| 187 | 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 | 228 | var a1 = GenNode(i32){ |
| 190 | 229 | .value = 13, |
| 191 | 230 | .next = null, |
test/behavior/if.zig+20| ... | ... | @@ -4,6 +4,9 @@ const expect = std.testing.expect; |
| 4 | 4 | const expectEqual = std.testing.expectEqual; |
| 5 | 5 | |
| 6 | 6 | test "if statements" { |
| 7 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 8 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 9 | ||
| 7 | 10 | shouldBeEqual(1, 1); |
| 8 | 11 | firstEqlThird(2, 1, 2); |
| 9 | 12 | } |
| ... | ... | @@ -27,6 +30,9 @@ fn firstEqlThird(a: i32, b: i32, c: i32) void { |
| 27 | 30 | } |
| 28 | 31 | |
| 29 | 32 | test "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 | 36 | try expect(elseIfExpressionF(1) == 1); |
| 31 | 37 | } |
| 32 | 38 | fn elseIfExpressionF(c: u8) u8 { |
| ... | ... | @@ -44,6 +50,10 @@ var global_with_val: anyerror!u32 = 0; |
| 44 | 50 | var global_with_err: anyerror!u32 = error.SomeError; |
| 45 | 51 | |
| 46 | 52 | test "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 | 57 | if (global_with_val) |v| { |
| 48 | 58 | try expect(v == 0); |
| 49 | 59 | } else |_| { |
| ... | ... | @@ -57,6 +67,9 @@ test "unwrap mutable global var" { |
| 57 | 67 | } |
| 58 | 68 | |
| 59 | 69 | test "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 | 73 | var answer: i32 = 0; |
| 61 | 74 | var c = true; |
| 62 | 75 | if (c) { |
| ... | ... | @@ -68,6 +81,9 @@ test "labeled break inside comptime if inside runtime if" { |
| 68 | 81 | } |
| 69 | 82 | |
| 70 | 83 | test "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 | 87 | const Num = enum { One, Two }; |
| 72 | 88 | |
| 73 | 89 | var t = true; |
| ... | ... | @@ -76,6 +92,10 @@ test "const result loc, runtime if cond, else unreachable" { |
| 76 | 92 | } |
| 77 | 93 | |
| 78 | 94 | test "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 | 99 | const S = struct { |
| 80 | 100 | fn doTheTest() !void { |
| 81 | 101 | var tmp: ?i32 = 10; |
test/behavior/incomplete_struct_param_tld.zig+3| ... | ... | @@ -1,3 +1,4 @@ |
| 1 | const builtin = @import("builtin"); | |
| 1 | 2 | const expect = @import("std").testing.expect; |
| 2 | 3 | |
| 3 | 4 | const A = struct { |
| ... | ... | @@ -21,6 +22,8 @@ fn foo(a: A) i32 { |
| 21 | 22 | } |
| 22 | 23 | |
| 23 | 24 | test "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 | 27 | const a = A{ |
| 25 | 28 | .b = B{ |
| 26 | 29 | .c = C{ .x = 13 }, |
test/behavior/inttoptr.zig+6| ... | ... | @@ -3,6 +3,8 @@ const builtin = @import("builtin"); |
| 3 | 3 | test "casting integer address to function pointer" { |
| 4 | 4 | if (builtin.zig_backend == .stage1) return error.SkipZigTest; |
| 5 | 5 | 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; | |
| 6 | 8 | |
| 7 | 9 | addressToFunction(); |
| 8 | 10 | comptime addressToFunction(); |
| ... | ... | @@ -14,6 +16,10 @@ fn addressToFunction() void { |
| 14 | 16 | } |
| 15 | 17 | |
| 16 | 18 | test "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 | 23 | forceCompilerAnalyzeBranchHardCodedPtrDereference(false); |
| 18 | 24 | } |
| 19 | 25 |
test/behavior/member_func.zig+6| ... | ... | @@ -28,6 +28,9 @@ const HasFuncs = struct { |
| 28 | 28 | |
| 29 | 29 | test "standard field calls" { |
| 30 | 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; | |
| 31 | 34 | |
| 32 | 35 | try expect(HasFuncs.one(0) == 1); |
| 33 | 36 | try expect(HasFuncs.two(0) == 2); |
| ... | ... | @@ -69,6 +72,9 @@ test "standard field calls" { |
| 69 | 72 | |
| 70 | 73 | test "@field field calls" { |
| 71 | 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; | |
| 72 | 78 | |
| 73 | 79 | try expect(@field(HasFuncs, "one")(0) == 1); |
| 74 | 80 | try expect(@field(HasFuncs, "two")(0) == 2); |
test/behavior/null.zig+29| ... | ... | @@ -29,6 +29,10 @@ test "optional type" { |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | test "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 | 36 | var maybe_bool: ?bool = true; |
| 33 | 37 | |
| 34 | 38 | if (maybe_bool) |*b| { |
| ... | ... | @@ -45,6 +49,10 @@ test "rhs maybe unwrap return" { |
| 45 | 49 | } |
| 46 | 50 | |
| 47 | 51 | test "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 | 56 | try maybeReturnImpl(); |
| 49 | 57 | comptime try maybeReturnImpl(); |
| 50 | 58 | } |
| ... | ... | @@ -61,6 +69,10 @@ fn foo(x: ?i32) ?bool { |
| 61 | 69 | } |
| 62 | 70 | |
| 63 | 71 | test "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 | 76 | try testTestNullRuntime(null); |
| 65 | 77 | } |
| 66 | 78 | fn testTestNullRuntime(x: ?i32) !void { |
| ... | ... | @@ -69,6 +81,9 @@ fn testTestNullRuntime(x: ?i32) !void { |
| 69 | 81 | } |
| 70 | 82 | |
| 71 | 83 | test "optional void" { |
| 84 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 85 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 86 | ||
| 72 | 87 | try optionalVoidImpl(); |
| 73 | 88 | comptime try optionalVoidImpl(); |
| 74 | 89 | } |
| ... | ... | @@ -89,6 +104,9 @@ fn bar(x: ?void) ?void { |
| 89 | 104 | const Empty = struct {}; |
| 90 | 105 | |
| 91 | 106 | test "optional struct{}" { |
| 107 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 108 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 109 | ||
| 92 | 110 | _ = try optionalEmptyStructImpl(); |
| 93 | 111 | _ = comptime try optionalEmptyStructImpl(); |
| 94 | 112 | } |
| ... | ... | @@ -107,17 +125,25 @@ fn baz(x: ?Empty) ?Empty { |
| 107 | 125 | } |
| 108 | 126 | |
| 109 | 127 | test "null with default unwrap" { |
| 128 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 129 | ||
| 110 | 130 | const x: i32 = null orelse 1; |
| 111 | 131 | try expect(x == 1); |
| 112 | 132 | } |
| 113 | 133 | |
| 114 | 134 | test "optional pointer to 0 bit type null value at runtime" { |
| 135 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 136 | ||
| 115 | 137 | const EmptyStruct = struct {}; |
| 116 | 138 | var x: ?*EmptyStruct = null; |
| 117 | 139 | try expect(x == null); |
| 118 | 140 | } |
| 119 | 141 | |
| 120 | 142 | test "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 | 147 | try expect(shouldBeAPlus1(Particle{ |
| 122 | 148 | .a = 14, |
| 123 | 149 | .b = 1, |
| ... | ... | @@ -159,6 +185,9 @@ const here_is_a_null_literal = SillyStruct{ .context = null }; |
| 159 | 185 | test "unwrap optional which is field of global var" { |
| 160 | 186 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 161 | 187 | 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; | |
| 162 | 191 | |
| 163 | 192 | struct_with_optional.field = null; |
| 164 | 193 | if (struct_with_optional.field) |payload| { |
test/behavior/pointers.zig+19| ... | ... | @@ -17,6 +17,10 @@ fn testDerefPtr() !void { |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | test "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 | 24 | var ptr: [*]const u8 = "abcd"; |
| 21 | 25 | |
| 22 | 26 | try expect(ptr[0] == 'a'); |
| ... | ... | @@ -61,6 +65,10 @@ test "initialize const optional C pointer to null" { |
| 61 | 65 | } |
| 62 | 66 | |
| 63 | 67 | test "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 | 72 | var x: i32 = 0; |
| 65 | 73 | var y: i32 = 1; |
| 66 | 74 | var ptr: [*c]u8 = 0; |
| ... | ... | @@ -75,6 +83,10 @@ test "assigning integer to C pointer" { |
| 75 | 83 | } |
| 76 | 84 | |
| 77 | 85 | test "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 | 90 | const S = struct { |
| 79 | 91 | fn doTheTest() !void { |
| 80 | 92 | var ptr1: [*c]u32 = 0; |
| ... | ... | @@ -133,6 +145,10 @@ test "peer type resolution with C pointers" { |
| 133 | 145 | } |
| 134 | 146 | |
| 135 | 147 | test "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 | 152 | var slice: []const u8 = "aoeu"; |
| 137 | 153 | const opt_many_ptr: ?[*]const u8 = slice.ptr; |
| 138 | 154 | var ptr_opt_many_ptr = &opt_many_ptr; |
| ... | ... | @@ -172,6 +188,9 @@ test "compare equality of optional and non-optional pointer" { |
| 172 | 188 | test "allowzero pointer and slice" { |
| 173 | 189 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 174 | 190 | 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; | |
| 175 | 194 | |
| 176 | 195 | var ptr = @intToPtr([*]allowzero i32, 0); |
| 177 | 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 | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const expect = std.testing.expect; |
| 3 | 4 | const mem = std.mem; |
| 4 | 5 | |
| 5 | 6 | var ok: bool = false; |
| 6 | 7 | test "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 | 12 | try foo(true, Num.Two, false, "aoeu"); |
| 8 | 13 | try expect(!ok); |
| 9 | 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 | 248 | test "runtime safety lets us slice from len..len" { |
| 249 | 249 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 250 | 250 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 251 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | |
| 252 | 251 | |
| 253 | 252 | var an_array = [_]u8{ 1, 2, 3 }; |
| 254 | 253 | try expect(mem.eql(u8, sliceFromLenToLen(an_array[0..], 3, 3), "")); |
test/behavior/src.zig+3| ... | ... | @@ -1,7 +1,10 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const expect = std.testing.expect; |
| 3 | 4 | |
| 4 | 5 | test "@src" { |
| 6 | if (builtin.zig_backend != .stage1) return error.SkipZigTest; | |
| 7 | ||
| 5 | 8 | try doTheTest(); |
| 6 | 9 | } |
| 7 | 10 |
test/behavior/struct.zig+4-8| ... | ... | @@ -86,7 +86,8 @@ const StructFoo = struct { |
| 86 | 86 | |
| 87 | 87 | test "structs" { |
| 88 | 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; | |
| 90 | 91 | |
| 91 | 92 | var foo: StructFoo = undefined; |
| 92 | 93 | @memset(@ptrCast([*]u8, &foo), 0, @sizeOf(StructFoo)); |
| ... | ... | @@ -248,7 +249,8 @@ test "usingnamespace within struct scope" { |
| 248 | 249 | |
| 249 | 250 | test "struct field init with catch" { |
| 250 | 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; | |
| 252 | 254 | |
| 253 | 255 | const S = struct { |
| 254 | 256 | fn doTheTest() !void { |
| ... | ... | @@ -310,7 +312,6 @@ test "struct point to self" { |
| 310 | 312 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO |
| 311 | 313 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 312 | 314 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 313 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO | |
| 314 | 315 | |
| 315 | 316 | var root: Node = undefined; |
| 316 | 317 | root.val.x = 1; |
| ... | ... | @@ -350,7 +351,6 @@ test "return empty struct from fn" { |
| 350 | 351 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO |
| 351 | 352 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 352 | 353 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 353 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO | |
| 354 | 354 | |
| 355 | 355 | _ = testReturnEmptyStructFromFn(); |
| 356 | 356 | } |
| ... | ... | @@ -364,7 +364,6 @@ test "pass slice of empty struct to fn" { |
| 364 | 364 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO |
| 365 | 365 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 366 | 366 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 367 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO | |
| 368 | 367 | |
| 369 | 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 | 408 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO |
| 410 | 409 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 411 | 410 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 412 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO | |
| 413 | 411 | |
| 414 | 412 | const result = alloc(Expr); |
| 415 | 413 | try expect(result.len == 0); |
| ... | ... | @@ -670,7 +668,6 @@ test "default struct initialization fields" { |
| 670 | 668 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO |
| 671 | 669 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 672 | 670 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 673 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO | |
| 674 | 671 | |
| 675 | 672 | const S = struct { |
| 676 | 673 | a: i32 = 1234, |
| ... | ... | @@ -936,7 +933,6 @@ test "anonymous struct literal syntax" { |
| 936 | 933 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO |
| 937 | 934 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 938 | 935 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 939 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO | |
| 940 | 936 | |
| 941 | 937 | const S = struct { |
| 942 | 938 | const Point = struct { |
test/behavior/this.zig+7| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const expect = @import("std").testing.expect; |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | |
| 3 | 4 | const module = @This(); |
| 4 | 5 | |
| ... | ... | @@ -20,10 +21,16 @@ fn add(x: i32, y: i32) i32 { |
| 20 | 21 | } |
| 21 | 22 | |
| 22 | 23 | test "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 | 27 | try expect(module.add(1, 2) == 3); |
| 24 | 28 | } |
| 25 | 29 | |
| 26 | 30 | test "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 | 34 | var pt: Point(i32) = undefined; |
| 28 | 35 | pt.x = 12; |
| 29 | 36 | pt.y = 34; |
test/behavior/try.zig+13-1| ... | ... | @@ -1,6 +1,12 @@ |
| 1 | const expect = @import("std").testing.expect; | |
| 1 | const std = @import("std"); | |
| 2 | const builtin = @import("builtin"); | |
| 3 | const expect = std.testing.expect; | |
| 2 | 4 | |
| 3 | 5 | test "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 | 10 | try tryOnErrorUnionImpl(); |
| 5 | 11 | comptime try tryOnErrorUnionImpl(); |
| 6 | 12 | } |
| ... | ... | @@ -19,6 +25,9 @@ fn returnsTen() anyerror!i32 { |
| 19 | 25 | } |
| 20 | 26 | |
| 21 | 27 | test "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 | 31 | const result1 = if (failIfTrue(true)) 1 else |_| @as(i32, 2); |
| 23 | 32 | try expect(result1 == 2); |
| 24 | 33 | |
| ... | ... | @@ -35,6 +44,9 @@ fn failIfTrue(ok: bool) anyerror!void { |
| 35 | 44 | } |
| 36 | 45 | |
| 37 | 46 | test "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 | 50 | if (failIfTrue(true)) { |
| 39 | 51 | unreachable; |
| 40 | 52 | } else |err| { |
test/behavior/type_info.zig+11| ... | ... | @@ -186,6 +186,10 @@ fn testErrorSet() !void { |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | test "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 | 193 | try testEnum(); |
| 190 | 194 | comptime try testEnum(); |
| 191 | 195 | } |
| ... | ... | @@ -249,6 +253,9 @@ fn testUnion() !void { |
| 249 | 253 | } |
| 250 | 254 | |
| 251 | 255 | test "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 | 259 | try testStruct(); |
| 253 | 260 | comptime try testStruct(); |
| 254 | 261 | } |
| ... | ... | @@ -439,6 +446,10 @@ test "type info for async frames" { |
| 439 | 446 | } |
| 440 | 447 | |
| 441 | 448 | test "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 | 453 | const S = struct { |
| 443 | 454 | const a = 1; |
| 444 | 455 | const b = 2; |
test/behavior/undefined.zig+11| ... | ... | @@ -16,6 +16,8 @@ test "init static array to undefined" { |
| 16 | 16 | // This test causes `initStaticArray()` to be codegen'd, and the |
| 17 | 17 | // C backend does not yet support returning arrays, so it fails |
| 18 | 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; | |
| 19 | 21 | |
| 20 | 22 | try expect(static_array[0] == 1); |
| 21 | 23 | try expect(static_array[4] == 2); |
| ... | ... | @@ -43,6 +45,9 @@ fn setFooX(foo: *Foo) void { |
| 43 | 45 | } |
| 44 | 46 | |
| 45 | 47 | test "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 | 51 | comptime { |
| 47 | 52 | var foo: Foo = undefined; |
| 48 | 53 | setFooX(&foo); |
| ... | ... | @@ -56,6 +61,9 @@ test "assign undefined to struct" { |
| 56 | 61 | } |
| 57 | 62 | |
| 58 | 63 | test "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 | 67 | comptime { |
| 60 | 68 | var foo: Foo = undefined; |
| 61 | 69 | foo.setFooXMethod(); |
| ... | ... | @@ -69,6 +77,9 @@ test "assign undefined to struct with method" { |
| 69 | 77 | } |
| 70 | 78 | |
| 71 | 79 | test "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 | 83 | const x = undefined; |
| 73 | 84 | try expect(mem.eql(u8, @typeName(@TypeOf(x)), "@Type(.Undefined)")); |
| 74 | 85 | } |
test/behavior/underscore.zig+5| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const expect = std.testing.expect; |
| 3 | 4 | |
| 4 | 5 | test "ignore lval with underscore" { |
| ... | ... | @@ -6,6 +7,10 @@ test "ignore lval with underscore" { |
| 6 | 7 | } |
| 7 | 8 | |
| 8 | 9 | test "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 | 14 | while (optionalReturnError()) |_| { |
| 10 | 15 | while (optionalReturnError()) |_| { |
| 11 | 16 | break; |
test/behavior/union.zig+139| ... | ... | @@ -10,6 +10,10 @@ const Foo = union { |
| 10 | 10 | }; |
| 11 | 11 | |
| 12 | 12 | test "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 | 17 | var foo = Foo{ .int = 1 }; |
| 14 | 18 | try expect(foo.int == 1); |
| 15 | 19 | foo = Foo{ .float = 12.34 }; |
| ... | ... | @@ -17,6 +21,10 @@ test "basic unions" { |
| 17 | 21 | } |
| 18 | 22 | |
| 19 | 23 | test "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 | 28 | var foo: Foo = undefined; |
| 21 | 29 | |
| 22 | 30 | setFloat(&foo, 12.34); |
| ... | ... | @@ -35,6 +43,9 @@ fn setInt(foo: *Foo, x: i32) void { |
| 35 | 43 | } |
| 36 | 44 | |
| 37 | 45 | test "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 | 49 | comptime { |
| 39 | 50 | var foo = Foo{ .int = 0 }; |
| 40 | 51 | try expect(foo.int == 0); |
| ... | ... | @@ -50,6 +61,10 @@ const FooExtern = extern union { |
| 50 | 61 | }; |
| 51 | 62 | |
| 52 | 63 | test "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 | 68 | var foo = FooExtern{ .int = 1 }; |
| 54 | 69 | try expect(foo.int == 1); |
| 55 | 70 | foo.float = 12.34; |
| ... | ... | @@ -61,10 +76,16 @@ const ExternPtrOrInt = extern union { |
| 61 | 76 | int: u64, |
| 62 | 77 | }; |
| 63 | 78 | test "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 | 82 | comptime try expect(@sizeOf(ExternPtrOrInt) == 8); |
| 65 | 83 | } |
| 66 | 84 | |
| 67 | 85 | test "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 | 89 | const U = extern union { |
| 69 | 90 | a: void, |
| 70 | 91 | const f = 1; |
| ... | ... | @@ -94,6 +115,9 @@ const err = @as(anyerror!Agg, Agg{ |
| 94 | 115 | const array = [_]Value{ v1, v2, v1, v2 }; |
| 95 | 116 | |
| 96 | 117 | test "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 | 121 | switch (array[1]) { |
| 98 | 122 | Value.Array => |arr| try expect(arr[4] == 3), |
| 99 | 123 | else => unreachable, |
| ... | ... | @@ -105,6 +129,9 @@ test "unions embedded in aggregate types" { |
| 105 | 129 | } |
| 106 | 130 | |
| 107 | 131 | test "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 | 135 | const Bar = union(enum) { |
| 109 | 136 | A: A, |
| 110 | 137 | B: B, |
| ... | ... | @@ -117,6 +144,10 @@ test "access a member of tagged union with conflicting enum tag name" { |
| 117 | 144 | } |
| 118 | 145 | |
| 119 | 146 | test "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 | 151 | var empty = TaggedUnionWithPayload{ .Empty = {} }; |
| 121 | 152 | var full = TaggedUnionWithPayload{ .Full = 13 }; |
| 122 | 153 | shouldBeEmpty(empty); |
| ... | ... | @@ -143,6 +174,9 @@ const TaggedUnionWithPayload = union(enum) { |
| 143 | 174 | }; |
| 144 | 175 | |
| 145 | 176 | test "union alignment" { |
| 177 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 178 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 179 | ||
| 146 | 180 | comptime { |
| 147 | 181 | try expect(@alignOf(AlignTestTaggedUnion) >= @alignOf([9]u8)); |
| 148 | 182 | try expect(@alignOf(AlignTestTaggedUnion) >= @alignOf(u64)); |
| ... | ... | @@ -162,11 +196,18 @@ const Payload = union(Letter) { |
| 162 | 196 | }; |
| 163 | 197 | |
| 164 | 198 | test "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 | 203 | try doTest(); |
| 166 | 204 | comptime try doTest(); |
| 167 | 205 | } |
| 168 | 206 | |
| 169 | 207 | test "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 | 211 | if (builtin.zig_backend == .stage1) return error.SkipZigTest; |
| 171 | 212 | |
| 172 | 213 | const U = packed union { |
| ... | ... | @@ -204,6 +245,10 @@ fn testComparison() !void { |
| 204 | 245 | } |
| 205 | 246 | |
| 206 | 247 | test "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 | 252 | try testComparison(); |
| 208 | 253 | comptime try testComparison(); |
| 209 | 254 | } |
| ... | ... | @@ -215,6 +260,10 @@ const TheUnion = union(TheTag) { |
| 215 | 260 | C: i32, |
| 216 | 261 | }; |
| 217 | 262 | test "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 | 267 | try testCastUnionToTag(); |
| 219 | 268 | comptime try testCastUnionToTag(); |
| 220 | 269 | } |
| ... | ... | @@ -225,12 +274,19 @@ fn testCastUnionToTag() !void { |
| 225 | 274 | } |
| 226 | 275 | |
| 227 | 276 | test "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 | 280 | try expect(TheUnion.A == TheTag.A); |
| 229 | 281 | try expect(TheUnion.B == TheTag.B); |
| 230 | 282 | try expect(TheUnion.C == TheTag.C); |
| 231 | 283 | } |
| 232 | 284 | |
| 233 | 285 | test "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 | 290 | var x: Value2 = Letter2.B; |
| 235 | 291 | try expect(@as(Letter2, x) == Letter2.B); |
| 236 | 292 | } |
| ... | ... | @@ -242,6 +298,10 @@ const Value2 = union(Letter2) { |
| 242 | 298 | }; |
| 243 | 299 | |
| 244 | 300 | test "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 | 305 | var x: Value2 = Letter2.B; |
| 246 | 306 | try expect(x == Letter2.B); |
| 247 | 307 | try giveMeLetterB(x); |
| ... | ... | @@ -258,6 +318,10 @@ pub const PackThis = union(enum) { |
| 258 | 318 | }; |
| 259 | 319 | |
| 260 | 320 | test "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 | 325 | try testConstPackedUnion(&[_]PackThis{PackThis{ .StringLiteral = 1 }}); |
| 262 | 326 | } |
| 263 | 327 | |
| ... | ... | @@ -272,6 +336,10 @@ const MultipleChoice = union(enum(u32)) { |
| 272 | 336 | D = 1000, |
| 273 | 337 | }; |
| 274 | 338 | test "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 | 343 | var x = MultipleChoice.C; |
| 276 | 344 | try expect(x == MultipleChoice.C); |
| 277 | 345 | try expect(@enumToInt(@as(Tag(MultipleChoice), x)) == 60); |
| ... | ... | @@ -282,6 +350,9 @@ const PackedPtrOrInt = packed union { |
| 282 | 350 | int: u64, |
| 283 | 351 | }; |
| 284 | 352 | test "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 | 356 | comptime try expect(@sizeOf(PackedPtrOrInt) == 8); |
| 286 | 357 | } |
| 287 | 358 | |
| ... | ... | @@ -289,10 +360,17 @@ const ZeroBits = union { |
| 289 | 360 | OnlyField: void, |
| 290 | 361 | }; |
| 291 | 362 | test "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 | 366 | comptime try expect(@sizeOf(ZeroBits) == 0); |
| 293 | 367 | } |
| 294 | 368 | |
| 295 | 369 | test "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 | 374 | try expect(testTaggedUnionInit({})); |
| 297 | 375 | } |
| 298 | 376 | |
| ... | ... | @@ -309,6 +387,10 @@ fn testTaggedUnionInit(x: anytype) bool { |
| 309 | 387 | pub const UnionEnumNoPayloads = union(enum) { A, B }; |
| 310 | 388 | |
| 311 | 389 | test "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 | 394 | const a = UnionEnumNoPayloads{ .B = {} }; |
| 313 | 395 | switch (a) { |
| 314 | 396 | Tag(UnionEnumNoPayloads).A => @panic("wrong"), |
| ... | ... | @@ -317,6 +399,10 @@ test "tagged union with no payloads" { |
| 317 | 399 | } |
| 318 | 400 | |
| 319 | 401 | test "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 | 406 | const Literal = union(enum) { |
| 321 | 407 | Number: f64, |
| 322 | 408 | Bool: bool, |
| ... | ... | @@ -334,6 +420,9 @@ test "union with only 1 field casted to its enum type" { |
| 334 | 420 | } |
| 335 | 421 | |
| 336 | 422 | test "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 | 426 | const U0 = union(enum) { |
| 338 | 427 | X: u32, |
| 339 | 428 | }; |
| ... | ... | @@ -348,6 +437,10 @@ const Foo1 = union(enum) { |
| 348 | 437 | var glbl: Foo1 = undefined; |
| 349 | 438 | |
| 350 | 439 | test "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 | 444 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO |
| 352 | 445 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 353 | 446 | |
| ... | ... | @@ -365,6 +458,10 @@ pub const FooUnion = union(enum) { |
| 365 | 458 | var glbl_array: [2]FooUnion = undefined; |
| 366 | 459 | |
| 367 | 460 | test "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 | 465 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; |
| 369 | 466 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 370 | 467 | |
| ... | ... | @@ -375,6 +472,10 @@ test "initialize global array of union" { |
| 375 | 472 | } |
| 376 | 473 | |
| 377 | 474 | test "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 | 479 | const S = union(enum) { |
| 379 | 480 | U0: void, |
| 380 | 481 | U1: void, |
| ... | ... | @@ -386,6 +487,10 @@ test "update the tag value for zero-sized unions" { |
| 386 | 487 | } |
| 387 | 488 | |
| 388 | 489 | test "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 | 494 | const U = union(enum) { |
| 390 | 495 | A: u24, |
| 391 | 496 | }; |
| ... | ... | @@ -395,6 +500,10 @@ test "union initializer generates padding only if needed" { |
| 395 | 500 | } |
| 396 | 501 | |
| 397 | 502 | test "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 | 507 | const U = union(enum) { |
| 399 | 508 | A: i32, |
| 400 | 509 | }; |
| ... | ... | @@ -404,6 +513,10 @@ test "runtime tag name with single field" { |
| 404 | 513 | } |
| 405 | 514 | |
| 406 | 515 | test "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 | 520 | const S = struct { |
| 408 | 521 | const MyUnion = union(MyUnionTag) { |
| 409 | 522 | pub const MyUnionTag = enum { X1, X2 }; |
| ... | ... | @@ -441,6 +554,10 @@ const FooNoVoid = union(enum) { |
| 441 | 554 | const Baz = enum { A, B, C, D }; |
| 442 | 555 | |
| 443 | 556 | test "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 | 561 | const foo1 = TaggedFoo{ .One = 13 }; |
| 445 | 562 | const foo2 = TaggedFoo{ |
| 446 | 563 | .Two = Point{ |
| ... | ... | @@ -460,6 +577,10 @@ test "tagged union type" { |
| 460 | 577 | } |
| 461 | 578 | |
| 462 | 579 | test "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 | 584 | switch (returnAnInt(13)) { |
| 464 | 585 | TaggedFoo.One => |value| try expect(value == 13), |
| 465 | 586 | else => unreachable, |
| ... | ... | @@ -471,6 +592,10 @@ fn returnAnInt(x: i32) TaggedFoo { |
| 471 | 592 | } |
| 472 | 593 | |
| 473 | 594 | test "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 | 599 | const S = struct { |
| 475 | 600 | const B = union(enum) { |
| 476 | 601 | c: C, |
| ... | ... | @@ -496,6 +621,9 @@ test "tagged union with all void fields but a meaningful tag" { |
| 496 | 621 | |
| 497 | 622 | test "union(enum(u32)) with specified and unspecified tag values" { |
| 498 | 623 | 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; | |
| 499 | 627 | |
| 500 | 628 | comptime try expect(Tag(Tag(MultipleChoice2)) == u32); |
| 501 | 629 | try testEnumWithSpecifiedAndUnspecifiedTagValues(MultipleChoice2{ .C = 123 }); |
| ... | ... | @@ -558,6 +686,10 @@ const PartialInstWithPayload = union(enum) { |
| 558 | 686 | }; |
| 559 | 687 | |
| 560 | 688 | test "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 | 693 | const Literal = union(enum) { |
| 562 | 694 | Number: f64, |
| 563 | 695 | Bool: bool, |
| ... | ... | @@ -638,6 +770,10 @@ fn Setter(attr: Attribute) type { |
| 638 | 770 | } |
| 639 | 771 | |
| 640 | 772 | test "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 | 777 | const S = struct { |
| 642 | 778 | fn entry() !void { |
| 643 | 779 | try expect(func().state == State.one); |
| ... | ... | @@ -948,6 +1084,9 @@ test "union enum type gets a separate scope" { |
| 948 | 1084 | test "global variable struct contains union initialized to non-most-aligned field" { |
| 949 | 1085 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 950 | 1086 | 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; | |
| 951 | 1090 | |
| 952 | 1091 | const T = struct { |
| 953 | 1092 | const U = union(enum) { |
test/behavior/usingnamespace.zig+19| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const expect = std.testing.expect; |
| 3 | 4 | |
| 4 | 5 | const A = struct { |
| ... | ... | @@ -10,6 +11,9 @@ const C = struct { |
| 10 | 11 | }; |
| 11 | 12 | |
| 12 | 13 | test "basic usingnamespace" { |
| 14 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 15 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 16 | ||
| 13 | 17 | try std.testing.expect(C.B == bool); |
| 14 | 18 | } |
| 15 | 19 | |
| ... | ... | @@ -20,6 +24,9 @@ fn Foo(comptime T: type) type { |
| 20 | 24 | } |
| 21 | 25 | |
| 22 | 26 | test "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 | 30 | const std2 = Foo(std); |
| 24 | 31 | const testing2 = Foo(std.testing); |
| 25 | 32 | try std2.testing.expect(true); |
| ... | ... | @@ -31,11 +38,17 @@ usingnamespace struct { |
| 31 | 38 | }; |
| 32 | 39 | |
| 33 | 40 | test "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 | 44 | comptime try std.testing.expect(@This().foo == 42); |
| 35 | 45 | } |
| 36 | 46 | |
| 37 | 47 | usingnamespace @import("usingnamespace/foo.zig"); |
| 38 | 48 | test "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 | 52 | try expect(@This().privateFunction()); |
| 40 | 53 | try expect(!@This().printText()); |
| 41 | 54 | } |
| ... | ... | @@ -44,10 +57,16 @@ fn privateFunction() bool { |
| 44 | 57 | } |
| 45 | 58 | |
| 46 | 59 | test { |
| 60 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 61 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 62 | ||
| 47 | 63 | _ = @import("usingnamespace/import_segregation.zig"); |
| 48 | 64 | } |
| 49 | 65 | |
| 50 | 66 | usingnamespace @import("usingnamespace/a.zig"); |
| 51 | 67 | test "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 | 71 | try expect(@This().ok()); |
| 53 | 72 | } |
test/behavior/void.zig+11| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const expect = @import("std").testing.expect; |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | |
| 3 | 4 | const Foo = struct { |
| 4 | 5 | a: void, |
| ... | ... | @@ -18,6 +19,9 @@ test "compare void with void compile time known" { |
| 18 | 19 | } |
| 19 | 20 | |
| 20 | 21 | test "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 | 25 | var j: usize = 0; |
| 22 | 26 | for (times(10)) |_, i| { |
| 23 | 27 | try expect(i == j); |
| ... | ... | @@ -30,11 +34,18 @@ fn times(n: usize) []const void { |
| 30 | 34 | } |
| 31 | 35 | |
| 32 | 36 | test "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 | 41 | var x: ?void = {}; |
| 34 | 42 | try expect(x != null); |
| 35 | 43 | } |
| 36 | 44 | |
| 37 | 45 | test "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 | 49 | var x = [_]void{{}} ** 1004; |
| 39 | 50 | _ = x[0]; |
| 40 | 51 | } |
test/behavior/while.zig+47| ... | ... | @@ -1,7 +1,11 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | |
| 2 | 3 | const expect = std.testing.expect; |
| 3 | 4 | |
| 4 | 5 | test "while loop" { |
| 6 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 7 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 8 | ||
| 5 | 9 | var i: i32 = 0; |
| 6 | 10 | while (i < 4) { |
| 7 | 11 | i += 1; |
| ... | ... | @@ -19,6 +23,9 @@ fn whileLoop2() i32 { |
| 19 | 23 | } |
| 20 | 24 | |
| 21 | 25 | test "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 | 29 | try expect(static_eval_while_number == 1); |
| 23 | 30 | } |
| 24 | 31 | const static_eval_while_number = staticWhileLoop1(); |
| ... | ... | @@ -98,6 +105,10 @@ fn testBreakOuter() void { |
| 98 | 105 | } |
| 99 | 106 | |
| 100 | 107 | test "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 | 112 | const S = struct { |
| 102 | 113 | fn doTheTest() !void { |
| 103 | 114 | var tmp: ?i32 = 10; |
| ... | ... | @@ -131,6 +142,10 @@ fn runContinueAndBreakTest() !void { |
| 131 | 142 | } |
| 132 | 143 | |
| 133 | 144 | test "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 | 149 | numbers_left = 10; |
| 135 | 150 | var sum: i32 = 0; |
| 136 | 151 | while (getNumberOrNull()) |value| { |
| ... | ... | @@ -140,6 +155,10 @@ test "while with optional as condition" { |
| 140 | 155 | } |
| 141 | 156 | |
| 142 | 157 | test "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 | 162 | numbers_left = 10; |
| 144 | 163 | var sum: i32 = 0; |
| 145 | 164 | var got_else: i32 = 0; |
| ... | ... | @@ -154,6 +173,10 @@ test "while with optional as condition with else" { |
| 154 | 173 | } |
| 155 | 174 | |
| 156 | 175 | test "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 | 180 | numbers_left = 10; |
| 158 | 181 | var sum: i32 = 0; |
| 159 | 182 | var got_else: i32 = 0; |
| ... | ... | @@ -182,6 +205,10 @@ test "while on bool with else result follow break prong" { |
| 182 | 205 | } |
| 183 | 206 | |
| 184 | 207 | test "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 | 212 | const result = while (returnNull()) |value| { |
| 186 | 213 | break value; |
| 187 | 214 | } else @as(i32, 2); |
| ... | ... | @@ -189,6 +216,10 @@ test "while on optional with else result follow else prong" { |
| 189 | 216 | } |
| 190 | 217 | |
| 191 | 218 | test "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 | 223 | const result = while (returnOptional(10)) |value| { |
| 193 | 224 | break value; |
| 194 | 225 | } else @as(i32, 2); |
| ... | ... | @@ -215,6 +246,10 @@ fn returnTrue() bool { |
| 215 | 246 | } |
| 216 | 247 | |
| 217 | 248 | test "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 | 253 | returnWithImplicitCastFromWhileLoopTest() catch unreachable; |
| 219 | 254 | } |
| 220 | 255 | fn returnWithImplicitCastFromWhileLoopTest() anyerror!void { |
| ... | ... | @@ -224,6 +259,10 @@ fn returnWithImplicitCastFromWhileLoopTest() anyerror!void { |
| 224 | 259 | } |
| 225 | 260 | |
| 226 | 261 | test "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 | 266 | const result = while (returnError()) |value| { |
| 228 | 267 | break value; |
| 229 | 268 | } else |_| @as(i32, 2); |
| ... | ... | @@ -231,6 +270,10 @@ test "while on error union with else result follow else prong" { |
| 231 | 270 | } |
| 232 | 271 | |
| 233 | 272 | test "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 | 277 | const result = while (returnSuccess(10)) |value| { |
| 235 | 278 | break value; |
| 236 | 279 | } else |_| @as(i32, 2); |
| ... | ... | @@ -253,6 +296,10 @@ test "while bool 2 break statements and an else" { |
| 253 | 296 | } |
| 254 | 297 | |
| 255 | 298 | test "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 | 303 | const S = struct { |
| 257 | 304 | fn entry(opt_t: ?bool, f: bool) !void { |
| 258 | 305 | var ok = false; |