Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions stdlib/Random/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1065,3 +1065,26 @@ end
end
end
end

@testset "TaskLocalRNG: copy and copy! handle the splitmix state" begin
seeds = rand(RandomDevice(), UInt64, 5)
for seed in seeds
Random.seed!(seed)
rng1 = copy(TaskLocalRNG())
x = fetch(@async rand(UInt64))
rng2 = copy(TaskLocalRNG())
y = fetch(@async rand(UInt64))
rng3 = copy(TaskLocalRNG())
@test x != y
@test rng1 != rng2
Random.seed!(seed)
@test TaskLocalRNG() == rng1
@test x == fetch(@async rand(UInt64))
@test TaskLocalRNG() == rng2
# this should be a no-op:
copy!(TaskLocalRNG(), copy(TaskLocalRNG()))
@test TaskLocalRNG() == rng2
@test y == fetch(@async rand(UInt64))
@test TaskLocalRNG() == rng3
end
end