Skip to content

Commit 610b02c

Browse files
BratishkaErikandrewrk
authored andcommitted
std.atomic.Atomic: update tests to new for-loop syntax, re-enable test with isel
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
1 parent b975701 commit 610b02c

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

lib/std/atomic/Atomic.zig

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -374,10 +374,6 @@ const atomic_rmw_orderings = [_]Ordering{
374374
};
375375

376376
test "Atomic.swap" {
377-
// TODO: Re-enable when LLVM is released with a bugfix for isel of
378-
// atomic load (currently fixed on trunk, broken on 15.0.2)
379-
if (builtin.cpu.arch == .powerpc64le) return error.SkipZigTest;
380-
381377
inline for (atomic_rmw_orderings) |ordering| {
382378
var x = Atomic(usize).init(5);
383379
try testing.expectEqual(x.swap(10, ordering), 5);
@@ -546,9 +542,8 @@ test "Atomic.bitSet" {
546542
inline for (atomicIntTypes()) |Int| {
547543
inline for (atomic_rmw_orderings) |ordering| {
548544
var x = Atomic(Int).init(0);
549-
const bit_array = @as([@bitSizeOf(Int)]void, undefined);
550545

551-
for (bit_array, 0..) |_, bit_index| {
546+
for (0..@bitSizeOf(Int)) |bit_index| {
552547
const bit = @intCast(std.math.Log2Int(Int), bit_index);
553548
const mask = @as(Int, 1) << bit;
554549

@@ -562,7 +557,7 @@ test "Atomic.bitSet" {
562557
try testing.expect(x.load(.SeqCst) & mask != 0);
563558

564559
// all the previous bits should have not changed (still be set)
565-
for (bit_array[0..bit_index], 0..) |_, prev_bit_index| {
560+
for (0..bit_index) |prev_bit_index| {
566561
const prev_bit = @intCast(std.math.Log2Int(Int), prev_bit_index);
567562
const prev_mask = @as(Int, 1) << prev_bit;
568563
try testing.expect(x.load(.SeqCst) & prev_mask != 0);
@@ -576,9 +571,8 @@ test "Atomic.bitReset" {
576571
inline for (atomicIntTypes()) |Int| {
577572
inline for (atomic_rmw_orderings) |ordering| {
578573
var x = Atomic(Int).init(0);
579-
const bit_array = @as([@bitSizeOf(Int)]void, undefined);
580574

581-
for (bit_array, 0..) |_, bit_index| {
575+
for (0..@bitSizeOf(Int)) |bit_index| {
582576
const bit = @intCast(std.math.Log2Int(Int), bit_index);
583577
const mask = @as(Int, 1) << bit;
584578
x.storeUnchecked(x.loadUnchecked() | mask);
@@ -593,7 +587,7 @@ test "Atomic.bitReset" {
593587
try testing.expect(x.load(.SeqCst) & mask == 0);
594588

595589
// all the previous bits should have not changed (still be reset)
596-
for (bit_array[0..bit_index], 0..) |_, prev_bit_index| {
590+
for (0..bit_index) |prev_bit_index| {
597591
const prev_bit = @intCast(std.math.Log2Int(Int), prev_bit_index);
598592
const prev_mask = @as(Int, 1) << prev_bit;
599593
try testing.expect(x.load(.SeqCst) & prev_mask == 0);
@@ -607,9 +601,8 @@ test "Atomic.bitToggle" {
607601
inline for (atomicIntTypes()) |Int| {
608602
inline for (atomic_rmw_orderings) |ordering| {
609603
var x = Atomic(Int).init(0);
610-
const bit_array = @as([@bitSizeOf(Int)]void, undefined);
611604

612-
for (bit_array, 0..) |_, bit_index| {
605+
for (0..@bitSizeOf(Int)) |bit_index| {
613606
const bit = @intCast(std.math.Log2Int(Int), bit_index);
614607
const mask = @as(Int, 1) << bit;
615608

@@ -623,7 +616,7 @@ test "Atomic.bitToggle" {
623616
try testing.expect(x.load(.SeqCst) & mask == 0);
624617

625618
// all the previous bits should have not changed (still be toggled back)
626-
for (bit_array[0..bit_index], 0..) |_, prev_bit_index| {
619+
for (0..bit_index) |prev_bit_index| {
627620
const prev_bit = @intCast(std.math.Log2Int(Int), prev_bit_index);
628621
const prev_mask = @as(Int, 1) << prev_bit;
629622
try testing.expect(x.load(.SeqCst) & prev_mask == 0);

0 commit comments

Comments
 (0)