Skip to content

Commit

Permalink
TaskLocalRNG: test that copy handles the splitmix state (#51355)
Browse files Browse the repository at this point in the history
This adds a test for #51332.
  • Loading branch information
rfourquet authored Sep 17, 2023
1 parent ee371a1 commit 28d0e1e
Showing 1 changed file with 23 additions and 0 deletions.
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

2 comments on commit 28d0e1e

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily package evaluation, I will reply here when finished:

@nanosoldier runtests(isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The package evaluation job you requested has completed - possible new issues were detected.
The full report is available.

Please sign in to comment.