Skip to content

Commit

Permalink
wrap for @atomic tests in @testset
Browse files Browse the repository at this point in the history
  • Loading branch information
kalmarek committed Jun 7, 2024
1 parent c7f721c commit 6980cd3
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions test/atomics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,8 @@ let a = ARefxy(1, -1)
end

let a = AtomicMemory{Float64}(undef, 2)
@testset "@atomic with AtomicMemory" begin
a = AtomicMemory{Float64}(undef, 2)
@test_throws CanonicalIndexError a[1] = 3

@test Base.setindex_atomic!(a, 1, 2) == 2.0
Expand All @@ -436,8 +438,8 @@ let a = AtomicMemory{Float64}(undef, 2)

@test (@atomic a[1]) == a[1]

# atomic set, swap and modify
let a = a, (old::Float64, new::Int) = (a[1], 10)
@testset "atomic set, swap and modify" begin
(old::Float64, new::Int) = (a[1], 10)
# old and new are intentionally of different types to test inner conversion
@test (@atomic a[1] = new) == new
@test a[1] == new
Expand All @@ -452,8 +454,8 @@ let a = AtomicMemory{Float64}(undef, 2)
@atomic a[1] = old
end

# atomicreplace
let a = a, (old::Float64, new::Int) = (a[1], 10)
@testset "@atomicreplace" begin
(old::Float64, new::Int) = (a[1], 10)
# old and new are intentionally of different types to test inner conversion
@test (@atomicreplace a[1] old => new) == (old=old, success=true)
@test a[1] == new
Expand All @@ -472,8 +474,8 @@ let a = AtomicMemory{Float64}(undef, 2)
@atomic a[1] = old
end

# @atomiconce
let a = a, b = AtomicMemory{Vector{Int}}(undef, 1)
@testset "@atomiconce" begin
b = AtomicMemory{Vector{Int}}(undef, 1)
@test (@atomiconce a[1] = 3) == false

@test !isassigned(b, 1)
Expand Down

0 comments on commit 6980cd3

Please sign in to comment.