| ... | @@ -7,6 +7,9 @@ const minInt = std.math.minInt; | ... | @@ -7,6 +7,9 @@ const minInt = std.math.minInt; |
| 7 | const native_endian = builtin.target.cpu.arch.endian(); | 7 | const native_endian = builtin.target.cpu.arch.endian(); |
| 8 | | 8 | |
| 9 | test "@bitCast iX -> uX (32, 64)" { | 9 | test "@bitCast iX -> uX (32, 64)" { |
| | 10 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| | 11 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 12 | |
| 10 | const bit_values = [_]usize{ 32, 64 }; | 13 | const bit_values = [_]usize{ 32, 64 }; |
| 11 | | 14 | |
| 12 | inline for (bit_values) |bits| { | 15 | inline for (bit_values) |bits| { |
| ... | @@ -17,6 +20,10 @@ test "@bitCast iX -> uX (32, 64)" { | ... | @@ -17,6 +20,10 @@ test "@bitCast iX -> uX (32, 64)" { |
| 17 | | 20 | |
| 18 | test "@bitCast iX -> uX (8, 16, 128)" { | 21 | test "@bitCast iX -> uX (8, 16, 128)" { |
| 19 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; | 22 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; |
| | 23 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| | 24 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| | 25 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 26 | |
| 20 | const bit_values = [_]usize{ 8, 16, 128 }; | 27 | const bit_values = [_]usize{ 8, 16, 128 }; |
| 21 | | 28 | |
| 22 | inline for (bit_values) |bits| { | 29 | inline for (bit_values) |bits| { |
| ... | @@ -29,6 +36,8 @@ test "@bitCast iX -> uX exotic integers" { | ... | @@ -29,6 +36,8 @@ test "@bitCast iX -> uX exotic integers" { |
| 29 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; | 36 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; |
| 30 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | 37 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 31 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | 38 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| | 39 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| | 40 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 32 | | 41 | |
| 33 | const bit_values = [_]usize{ 1, 48, 27, 512, 493, 293, 125, 204, 112 }; | 42 | const bit_values = [_]usize{ 1, 48, 27, 512, 493, 293, 125, 204, 112 }; |
| 34 | | 43 | |
| ... | @@ -66,6 +75,9 @@ fn conv_uN(comptime N: usize, x: std.meta.Int(.unsigned, N)) std.meta.Int(.signe | ... | @@ -66,6 +75,9 @@ fn conv_uN(comptime N: usize, x: std.meta.Int(.unsigned, N)) std.meta.Int(.signe |
| 66 | } | 75 | } |
| 67 | | 76 | |
| 68 | test "nested bitcast" { | 77 | test "nested bitcast" { |
| | 78 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| | 79 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 80 | |
| 69 | const S = struct { | 81 | const S = struct { |
| 70 | fn moo(x: isize) !void { | 82 | fn moo(x: isize) !void { |
| 71 | try expect(@intCast(isize, 42) == x); | 83 | try expect(@intCast(isize, 42) == x); |
| ... | @@ -83,6 +95,9 @@ test "nested bitcast" { | ... | @@ -83,6 +95,9 @@ test "nested bitcast" { |
| 83 | } | 95 | } |
| 84 | | 96 | |
| 85 | test "@bitCast enum to its integer type" { | 97 | test "@bitCast enum to its integer type" { |
| | 98 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| | 99 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 100 | |
| 86 | const SOCK = enum(c_int) { | 101 | const SOCK = enum(c_int) { |
| 87 | A, | 102 | A, |
| 88 | B, | 103 | B, |
| ... | @@ -100,11 +115,17 @@ test "@bitCast enum to its integer type" { | ... | @@ -100,11 +115,17 @@ test "@bitCast enum to its integer type" { |
| 100 | | 115 | |
| 101 | // issue #3010: compiler segfault | 116 | // issue #3010: compiler segfault |
| 102 | test "bitcast literal [4]u8 param to u32" { | 117 | test "bitcast literal [4]u8 param to u32" { |
| | 118 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| | 119 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 120 | |
| 103 | const ip = @bitCast(u32, [_]u8{ 255, 255, 255, 255 }); | 121 | const ip = @bitCast(u32, [_]u8{ 255, 255, 255, 255 }); |
| 104 | try expect(ip == maxInt(u32)); | 122 | try expect(ip == maxInt(u32)); |
| 105 | } | 123 | } |
| 106 | | 124 | |
| 107 | test "bitcast generates a temporary value" { | 125 | test "bitcast generates a temporary value" { |
| | 126 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| | 127 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 128 | |
| 108 | var y = @as(u16, 0x55AA); | 129 | var y = @as(u16, 0x55AA); |
| 109 | const x = @bitCast(u16, @bitCast([2]u8, y)); | 130 | const x = @bitCast(u16, @bitCast([2]u8, y)); |
| 110 | try expect(y == x); | 131 | try expect(y == x); |
| ... | @@ -115,6 +136,8 @@ test "@bitCast packed structs at runtime and comptime" { | ... | @@ -115,6 +136,8 @@ test "@bitCast packed structs at runtime and comptime" { |
| 115 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; | 136 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; |
| 116 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | 137 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 117 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | 138 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| | 139 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| | 140 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 118 | | 141 | |
| 119 | const Full = packed struct { | 142 | const Full = packed struct { |
| 120 | number: u16, | 143 | number: u16, |
| ... | @@ -151,6 +174,8 @@ test "@bitCast extern structs at runtime and comptime" { | ... | @@ -151,6 +174,8 @@ test "@bitCast extern structs at runtime and comptime" { |
| 151 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; | 174 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; |
| 152 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | 175 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 153 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | 176 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| | 177 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| | 178 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 154 | | 179 | |
| 155 | const Full = extern struct { | 180 | const Full = extern struct { |
| 156 | number: u16, | 181 | number: u16, |
| ... | @@ -184,6 +209,8 @@ test "bitcast packed struct to integer and back" { | ... | @@ -184,6 +209,8 @@ test "bitcast packed struct to integer and back" { |
| 184 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; | 209 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; |
| 185 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | 210 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 186 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | 211 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| | 212 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| | 213 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 187 | | 214 | |
| 188 | const LevelUpMove = packed struct { | 215 | const LevelUpMove = packed struct { |
| 189 | move_id: u9, | 216 | move_id: u9, |
| ... | @@ -203,6 +230,9 @@ test "bitcast packed struct to integer and back" { | ... | @@ -203,6 +230,9 @@ test "bitcast packed struct to integer and back" { |
| 203 | } | 230 | } |
| 204 | | 231 | |
| 205 | test "implicit cast to error union by returning" { | 232 | test "implicit cast to error union by returning" { |
| | 233 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| | 234 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 235 | |
| 206 | const S = struct { | 236 | const S = struct { |
| 207 | fn entry() !void { | 237 | fn entry() !void { |
| 208 | try expect((func(-1) catch unreachable) == maxInt(u64)); | 238 | try expect((func(-1) catch unreachable) == maxInt(u64)); |
| ... | @@ -220,6 +250,8 @@ test "bitcast packed struct literal to byte" { | ... | @@ -220,6 +250,8 @@ test "bitcast packed struct literal to byte" { |
| 220 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; | 250 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; |
| 221 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | 251 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 222 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | 252 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| | 253 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| | 254 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 223 | | 255 | |
| 224 | const Foo = packed struct { | 256 | const Foo = packed struct { |
| 225 | value: u8, | 257 | value: u8, |
| ... | @@ -233,6 +265,8 @@ test "comptime bitcast used in expression has the correct type" { | ... | @@ -233,6 +265,8 @@ test "comptime bitcast used in expression has the correct type" { |
| 233 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; | 265 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; |
| 234 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | 266 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 235 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | 267 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| | 268 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| | 269 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 236 | | 270 | |
| 237 | const Foo = packed struct { | 271 | const Foo = packed struct { |
| 238 | value: u8, | 272 | value: u8, |
| ... | @@ -245,6 +279,8 @@ test "bitcast passed as tuple element" { | ... | @@ -245,6 +279,8 @@ test "bitcast passed as tuple element" { |
| 245 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; | 279 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; |
| 246 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | 280 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 247 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | 281 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| | 282 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| | 283 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 248 | | 284 | |
| 249 | const S = struct { | 285 | const S = struct { |
| 250 | fn foo(args: anytype) !void { | 286 | fn foo(args: anytype) !void { |
| ... | @@ -257,6 +293,8 @@ test "bitcast passed as tuple element" { | ... | @@ -257,6 +293,8 @@ test "bitcast passed as tuple element" { |
| 257 | | 293 | |
| 258 | test "triple level result location with bitcast sandwich passed as tuple element" { | 294 | test "triple level result location with bitcast sandwich passed as tuple element" { |
| 259 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | 295 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| | 296 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| | 297 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 260 | | 298 | |
| 261 | const S = struct { | 299 | const S = struct { |
| 262 | fn foo(args: anytype) !void { | 300 | fn foo(args: anytype) !void { |