File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -1065,3 +1065,26 @@ end
1065
1065
end
1066
1066
end
1067
1067
end
1068
+
1069
+ @testset " TaskLocalRNG: copy and copy! handle the splitmix state" begin
1070
+ seeds = rand (RandomDevice (), UInt64, 5 )
1071
+ for seed in seeds
1072
+ Random. seed! (seed)
1073
+ rng1 = copy (TaskLocalRNG ())
1074
+ x = fetch (@async rand (UInt64))
1075
+ rng2 = copy (TaskLocalRNG ())
1076
+ y = fetch (@async rand (UInt64))
1077
+ rng3 = copy (TaskLocalRNG ())
1078
+ @test x != y
1079
+ @test rng1 != rng2
1080
+ Random. seed! (seed)
1081
+ @test TaskLocalRNG () == rng1
1082
+ @test x == fetch (@async rand (UInt64))
1083
+ @test TaskLocalRNG () == rng2
1084
+ # this should be a no-op:
1085
+ copy! (TaskLocalRNG (), copy (TaskLocalRNG ()))
1086
+ @test TaskLocalRNG () == rng2
1087
+ @test y == fetch (@async rand (UInt64))
1088
+ @test TaskLocalRNG () == rng3
1089
+ end
1090
+ end
You can’t perform that action at this time.
0 commit comments