| author | |
| committer | |
| log | 9c70315854735ab9ecd572e327f41ea547033f09 |
| tree | 758a4a381e90af513771cde4287d60d476c173d0 |
| parent | 0251ce1e1bdf47765fc7280aab1816b50084c0b8 |
- fixup 128-bit atomics test to only run on x86_64
- add truncation test for 128-bit types, including non power of two targets (there was a bug with broken non-power-of-two truncation in the cbe)
- add 128-bit binary not test (covers another bug fixed in the cbe)3 files changed, 34 insertions(+), 9 deletions(-)
test/behavior/atomics.zig+4-7| ... | ... | @@ -308,16 +308,13 @@ fn testAtomicRmwInt(comptime signedness: std.builtin.Signedness, comptime N: usi |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | test "atomicrmw with 128-bit ints" { |
| 311 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO | |
| 312 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO | |
| 313 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | |
| 314 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | |
| 315 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | |
| 316 | ||
| 317 | if (builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) { | |
| 311 | if (builtin.cpu.arch != .x86_64) { | |
| 312 | // TODO: Ideally this could use target.atomicPtrAlignment and check for IntTooBig | |
| 318 | 313 | return error.SkipZigTest; |
| 319 | 314 | } |
| 320 | 315 | |
| 316 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO | |
| 317 | ||
| 321 | 318 | try testAtomicRmwInt128(.unsigned); |
| 322 | 319 | comptime try testAtomicRmwInt128(.unsigned); |
| 323 | 320 | } |
test/behavior/int128.zig+13-2| ... | ... | @@ -69,6 +69,17 @@ test "truncate int128" { |
| 69 | 69 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 70 | 70 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 71 | 71 | |
| 72 | var buff: u128 = maxInt(u128); | |
| 73 | try expect(@truncate(u64, buff) == maxInt(u64)); | |
| 72 | { | |
| 73 | var buff: u128 = maxInt(u128); | |
| 74 | try expect(@truncate(u64, buff) == maxInt(u64)); | |
| 75 | try expect(@truncate(u90, buff) == maxInt(u90)); | |
| 76 | try expect(@truncate(u128, buff) == maxInt(u128)); | |
| 77 | } | |
| 78 | ||
| 79 | { | |
| 80 | var buff: i128 = maxInt(i128); | |
| 81 | try expect(@truncate(i64, buff) == -1); | |
| 82 | try expect(@truncate(i90, buff) == -1); | |
| 83 | try expect(@truncate(i128, buff) == maxInt(i128)); | |
| 84 | } | |
| 74 | 85 | } |
test/behavior/math.zig+17| ... | ... | @@ -377,6 +377,23 @@ fn testBinaryNot(x: u16) !void { |
| 377 | 377 | try expect(~x == 0b0101010101010101); |
| 378 | 378 | } |
| 379 | 379 | |
| 380 | ||
| 381 | test "binary not 128-bit" { | |
| 382 | try expect(comptime x: { | |
| 383 | break :x ~@as(u128, 0x55555555_55555555_55555555_55555555) == 0xaaaaaaaa_aaaaaaaa_aaaaaaaa_aaaaaaaa; | |
| 384 | }); | |
| 385 | try expect(comptime x: { | |
| 386 | break :x ~@as(i128, 0x55555555_55555555_55555555_55555555) == @bitCast(i128, @as(u128, 0xaaaaaaaa_aaaaaaaa_aaaaaaaa_aaaaaaaa)); | |
| 387 | }); | |
| 388 | ||
| 389 | try testBinaryNot128(u128, 0xaaaaaaaa_aaaaaaaa_aaaaaaaa_aaaaaaaa); | |
| 390 | try testBinaryNot128(i128, @bitCast(i128, @as(u128, 0xaaaaaaaa_aaaaaaaa_aaaaaaaa_aaaaaaaa))); | |
| 391 | } | |
| 392 | ||
| 393 | fn testBinaryNot128(comptime Type: type, x: Type) !void { | |
| 394 | try expect(~x == @as(Type, 0x55555555_55555555_55555555_55555555)); | |
| 395 | } | |
| 396 | ||
| 380 | 397 | test "division" { |
| 381 | 398 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO |
| 382 | 399 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO |