| ... | ... | @@ -7,6 +7,9 @@ const minInt = std.math.minInt; |
| 7 | 7 | const native_endian = builtin.target.cpu.arch.endian(); |
| 8 | 8 | |
| 9 | 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 | 13 | const bit_values = [_]usize{ 32, 64 }; |
| 11 | 14 | |
| 12 | 15 | inline for (bit_values) |bits| { |
| ... | ... | @@ -17,6 +20,10 @@ test "@bitCast iX -> uX (32, 64)" { |
| 17 | 20 | |
| 18 | 21 | test "@bitCast iX -> uX (8, 16, 128)" { |
| 19 | 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 | 27 | const bit_values = [_]usize{ 8, 16, 128 }; |
| 21 | 28 | |
| 22 | 29 | inline for (bit_values) |bits| { |
| ... | ... | @@ -29,6 +36,8 @@ test "@bitCast iX -> uX exotic integers" { |
| 29 | 36 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; |
| 30 | 37 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 31 | 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 | 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 | 75 | } |
| 67 | 76 | |
| 68 | 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 | 81 | const S = struct { |
| 70 | 82 | fn moo(x: isize) !void { |
| 71 | 83 | try expect(@intCast(isize, 42) == x); |
| ... | ... | @@ -83,6 +95,9 @@ test "nested bitcast" { |
| 83 | 95 | } |
| 84 | 96 | |
| 85 | 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 | 101 | const SOCK = enum(c_int) { |
| 87 | 102 | A, |
| 88 | 103 | B, |
| ... | ... | @@ -100,11 +115,17 @@ test "@bitCast enum to its integer type" { |
| 100 | 115 | |
| 101 | 116 | // issue #3010: compiler segfault |
| 102 | 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 | 121 | const ip = @bitCast(u32, [_]u8{ 255, 255, 255, 255 }); |
| 104 | 122 | try expect(ip == maxInt(u32)); |
| 105 | 123 | } |
| 106 | 124 | |
| 107 | 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 | 129 | var y = @as(u16, 0x55AA); |
| 109 | 130 | const x = @bitCast(u16, @bitCast([2]u8, y)); |
| 110 | 131 | try expect(y == x); |
| ... | ... | @@ -115,6 +136,8 @@ test "@bitCast packed structs at runtime and comptime" { |
| 115 | 136 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; |
| 116 | 137 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 117 | 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 | 142 | const Full = packed struct { |
| 120 | 143 | number: u16, |
| ... | ... | @@ -151,6 +174,8 @@ test "@bitCast extern structs at runtime and comptime" { |
| 151 | 174 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; |
| 152 | 175 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 153 | 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 | 180 | const Full = extern struct { |
| 156 | 181 | number: u16, |
| ... | ... | @@ -184,6 +209,8 @@ test "bitcast packed struct to integer and back" { |
| 184 | 209 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; |
| 185 | 210 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 186 | 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 | 215 | const LevelUpMove = packed struct { |
| 189 | 216 | move_id: u9, |
| ... | ... | @@ -203,6 +230,9 @@ test "bitcast packed struct to integer and back" { |
| 203 | 230 | } |
| 204 | 231 | |
| 205 | 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 | 236 | const S = struct { |
| 207 | 237 | fn entry() !void { |
| 208 | 238 | try expect((func(-1) catch unreachable) == maxInt(u64)); |
| ... | ... | @@ -220,6 +250,8 @@ test "bitcast packed struct literal to byte" { |
| 220 | 250 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; |
| 221 | 251 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 222 | 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 | 256 | const Foo = packed struct { |
| 225 | 257 | value: u8, |
| ... | ... | @@ -233,6 +265,8 @@ test "comptime bitcast used in expression has the correct type" { |
| 233 | 265 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; |
| 234 | 266 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 235 | 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 | 271 | const Foo = packed struct { |
| 238 | 272 | value: u8, |
| ... | ... | @@ -245,6 +279,8 @@ test "bitcast passed as tuple element" { |
| 245 | 279 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; |
| 246 | 280 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; |
| 247 | 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 | 285 | const S = struct { |
| 250 | 286 | fn foo(args: anytype) !void { |
| ... | ... | @@ -257,6 +293,8 @@ test "bitcast passed as tuple element" { |
| 257 | 293 | |
| 258 | 294 | test "triple level result location with bitcast sandwich passed as tuple element" { |
| 259 | 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 | 299 | const S = struct { |
| 262 | 300 | fn foo(args: anytype) !void { |