@@ -60,41 +60,42 @@ function test_rand(@nospecialize(test::Union{Nothing,Function}),
6060 @test size (mM) == (2 , 3 )
6161 foreach (_test, mM)
6262
63- Random . seed! (rng, rng . seed )
64- x = rand (rng , R, args... )
63+ rng1 = copy (rng)
64+ x = rand (rng1 , R, args... )
6565 @test x isa type
6666 _test (x)
67- y = rand (rng , M)
67+ y = rand (rng1 , M)
6868 @test y isa type
6969 _test (y)
7070
7171 if isempty (args)
72- v = rand (rng , R, 2 )
72+ v = rand (rng1 , R, 2 )
7373 @test v isa Vector{type}
7474 @test size (v) == (2 ,)
7575 foreach (_test, v)
76- m = rand (rng , R, 2 , 3 )
76+ m = rand (rng1 , R, 2 , 3 )
7777 @test m isa Matrix{type}
7878 @test size (m) == (2 , 3 )
7979 foreach (_test, m)
8080 end
81- vM = rand (rng , M, 2 )
81+ vM = rand (rng1 , M, 2 )
8282 @test vM isa Vector{type}
8383 @test size (vM) == (2 ,)
8484 foreach (_test, vM)
8585
86- mM = rand (rng , M, 2 , 3 )
86+ mM = rand (rng1 , M, 2 , 3 )
8787 @test mM isa Matrix{type}
8888 @test size (mM) == (2 , 3 )
8989 foreach (_test, mM)
9090
91- Random. seed! (rng, rng. seed)
92- @test x == rand (rng, R, args... )
93- @test y == rand (rng, M)
91+ # rng2 should reproduce the same random values as rng1
92+ rng2 = copy (rng)
93+ @test x == rand (rng2, R, args... )
94+ @test y == rand (rng2, M)
9495 if isempty (args)
95- @test v == rand (rng , R, 2 )
96- @test m == rand (rng , R, 2 , 3 )
96+ @test v == rand (rng2 , R, 2 )
97+ @test m == rand (rng2 , R, 2 , 3 )
9798 end
98- @test vM == rand (rng , M, 2 )
99- @test mM == rand (rng , M, 2 , 3 )
99+ @test vM == rand (rng2 , M, 2 )
100+ @test mM == rand (rng2 , M, 2 , 3 )
100101end
0 commit comments