Skip to content

Commit 6acfae0

Browse files
committed
limit the scope of srand in tests
1 parent f2fd1f8 commit 6acfae0

File tree

9 files changed

+215
-165
lines changed

9 files changed

+215
-165
lines changed

stdlib/Test/src/Test.jl

+19
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export @testset
2121
export @inferred
2222
export detect_ambiguities, detect_unbound_args
2323
export GenericString, GenericSet, GenericDict, GenericArray
24+
export guardsrand
2425

2526
#-----------------------------------------------------------------------
2627

@@ -1429,6 +1430,24 @@ Base.setindex!(a::GenericArray, x, i...) = a.a[i...] = x
14291430

14301431
Base.similar(A::GenericArray, s::Integer...) = GenericArray(similar(A.a, s...))
14311432

1433+
"guardsrand(f) runs the function `f()` and then restores the
1434+
state of the global RNG as it was before.!!!"
1435+
function guardsrand(f, r::AbstractRNG=Base.GLOBAL_RNG)
1436+
old = copy(r)
1437+
try
1438+
f()
1439+
finally
1440+
copy!(r, old)
1441+
end
1442+
end
1443+
1444+
"guardsrand(f, seed) is equivalent to `srand(seed); f()` and then restoring
1445+
the state of the global RNG as it was before."
1446+
guardsrand(f, seed::Integer) = guardsrand() do
1447+
srand(seed)
1448+
f()
1449+
end
1450+
14321451
# 0.7 deprecations
14331452

14341453
begin

stdlib/Test/test/runtests.jl

+25-3
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,11 @@ end
280280
@test S(1) == T(1)
281281
end
282282
end
283-
srand(123)
284283
@testset "some loops fail" begin
285-
@testset for i in 1:5
286-
@test i <= rand(1:10)
284+
guardsrand(123) do
285+
@testset for i in 1:5
286+
@test i <= rand(1:10)
287+
end
287288
end
288289
# should add 3 errors and 3 passing tests
289290
@testset for i in 1:6
@@ -599,3 +600,24 @@ msg = split(read(pipeline(ignorestatus(`$(Base.julia_cmd()) --startup-file=no --
599600
Test.print_test_results(Test.DefaultTestSet(""))'`), stderr=DevNull), String), "\n")[1]
600601

601602
@test msg == rstrip(msg)
603+
604+
# test guarded srand
605+
let seed = rand(UInt)
606+
orig = copy(Base.GLOBAL_RNG)
607+
@test srand(()->rand(), seed) == srand(()->rand(), seed)
608+
@test srand(()->rand(Int), seed) == srand(()->rand(Int), seed)
609+
r1, r2 = MersenneTwister(0), MersenneTwister(0)
610+
a, b = guardsrand(r1) do
611+
srand(r1, 0)
612+
rand(r1), rand(r1, Int)
613+
end::Tuple{Float64,Int}
614+
c, d = guardsrand(r2) do
615+
srand(r2, 0)
616+
rand(r2), rand(r2, Int)
617+
end::Tuple{Float64,Int}
618+
@test a == c == rand(r1) == rand(r2)
619+
@test b == d == rand(r1, Int) == rand(r2, Int)
620+
@test orig == Base.GLOBAL_RNG
621+
@test rand(orig) == rand()
622+
@test_throws MethodError srand(()->nothing)
623+
end

test/error.jl

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
@test maximum(ExponentialBackOff(n=10, max_delay=0.06)) == 0.06
77
ratio(x) = x[2:end]./x[1:end-1]
88
@test all(x->x 10.0, ratio(collect(ExponentialBackOff(n=10, max_delay=Inf, factor=10, jitter=0.0))))
9-
srand(12345)
10-
@test (mean(ratio(collect(ExponentialBackOff(n=100, max_delay=Inf, factor=1, jitter=0.1)))) - 1.0) < 1e-4
9+
guardsrand(12345) do
10+
@test (mean(ratio(collect(ExponentialBackOff(n=100, max_delay=Inf, factor=1, jitter=0.1)))) - 1.0) < 1e-4
11+
end
1112
end
1213
@testset "retrying after errors" begin
1314
function foo_error(c, n)

test/linalg/arnoldi.jl

+68-67
Original file line numberDiff line numberDiff line change
@@ -3,86 +3,87 @@
33
using Test
44

55
@testset "eigs" begin
6-
srand(1234)
7-
n = 10
8-
areal = sprandn(n,n,0.4)
9-
breal = sprandn(n,n,0.4)
10-
acmplx = complex.(sprandn(n,n,0.4), sprandn(n,n,0.4))
11-
bcmplx = complex.(sprandn(n,n,0.4), sprandn(n,n,0.4))
12-
13-
testtol = 1e-6
14-
15-
@testset for elty in (Float64, Complex128)
16-
if elty == Complex64 || elty == Complex128
17-
a = acmplx
18-
b = bcmplx
19-
else
20-
a = areal
21-
b = breal
22-
end
23-
a = convert(SparseMatrixCSC{elty}, a)
24-
asym = a' + a # symmetric indefinite
25-
apd = a'*a # symmetric positive-definite
6+
guardsrand(1234) do
7+
n = 10
8+
areal = sprandn(n,n,0.4)
9+
breal = sprandn(n,n,0.4)
10+
acmplx = complex.(sprandn(n,n,0.4), sprandn(n,n,0.4))
11+
bcmplx = complex.(sprandn(n,n,0.4), sprandn(n,n,0.4))
2612

27-
b = convert(SparseMatrixCSC{elty}, b)
28-
bsym = b' + b
29-
bpd = b'*b
13+
testtol = 1e-6
3014

31-
(d,v) = eigs(a, nev=3)
32-
@test a*v[:,2] d[2]*v[:,2]
33-
@test norm(v) > testtol # eigenvectors cannot be null vectors
34-
(d,v) = eigs(a, I, nev=3) # test eigs(A, B; kwargs...)
35-
@test a*v[:,2] d[2]*v[:,2]
36-
@test norm(v) > testtol # eigenvectors cannot be null vectors
37-
@test_warn "Use symbols instead of strings for specifying which eigenvalues to compute" eigs(a, which="LM")
38-
# (d,v) = eigs(a, b, nev=3, tol=1e-8) # not handled yet
39-
# @test a*v[:,2] ≈ d[2]*b*v[:,2] atol=testtol
40-
# @test norm(v) > testtol # eigenvectors cannot be null vectors
15+
@testset for elty in (Float64, Complex128)
16+
if elty == Complex64 || elty == Complex128
17+
a = acmplx
18+
b = bcmplx
19+
else
20+
a = areal
21+
b = breal
22+
end
23+
a = convert(SparseMatrixCSC{elty}, a)
24+
asym = a' + a # symmetric indefinite
25+
apd = a'*a # symmetric positive-definite
4126

42-
(d,v) = eigs(asym, nev=3)
43-
@test asym*v[:,1] d[1]*v[:,1]
44-
@test eigs(asym; nev=1, sigma=d[3])[1][1] d[3]
45-
@test norm(v) > testtol # eigenvectors cannot be null vectors
27+
b = convert(SparseMatrixCSC{elty}, b)
28+
bsym = b' + b
29+
bpd = b'*b
4630

47-
(d,v) = eigs(apd, nev=3)
48-
@test apd*v[:,3] d[3]*v[:,3]
49-
@test eigs(apd; nev=1, sigma=d[3])[1][1] d[3]
31+
(d,v) = eigs(a, nev=3)
32+
@test a*v[:,2] d[2]*v[:,2]
33+
@test norm(v) > testtol # eigenvectors cannot be null vectors
34+
(d,v) = eigs(a, I, nev=3) # test eigs(A, B; kwargs...)
35+
@test a*v[:,2] d[2]*v[:,2]
36+
@test norm(v) > testtol # eigenvectors cannot be null vectors
37+
@test_warn "Use symbols instead of strings for specifying which eigenvalues to compute" eigs(a, which="LM")
38+
# (d,v) = eigs(a, b, nev=3, tol=1e-8) # not handled yet
39+
# @test a*v[:,2] ≈ d[2]*b*v[:,2] atol=testtol
40+
# @test norm(v) > testtol # eigenvectors cannot be null vectors
5041

51-
(d,v) = eigs(apd, bpd, nev=3, tol=1e-8)
52-
@test apd*v[:,2] d[2]*bpd*v[:,2] atol=testtol
53-
@test norm(v) > testtol # eigenvectors cannot be null vectors
42+
(d,v) = eigs(asym, nev=3)
43+
@test asym*v[:,1] d[1]*v[:,1]
44+
@test eigs(asym; nev=1, sigma=d[3])[1][1] d[3]
45+
@test norm(v) > testtol # eigenvectors cannot be null vectors
5446

55-
@testset "(shift-and-)invert mode" begin
56-
(d,v) = eigs(apd, nev=3, sigma=0)
47+
(d,v) = eigs(apd, nev=3)
5748
@test apd*v[:,3] d[3]*v[:,3]
58-
@test norm(v) > testtol # eigenvectors cannot be null vectors
49+
@test eigs(apd; nev=1, sigma=d[3])[1][1] d[3]
5950

60-
(d,v) = eigs(apd, bpd, nev=3, sigma=0, tol=1e-8)
61-
@test apd*v[:,1] d[1]*bpd*v[:,1] atol=testtol
51+
(d,v) = eigs(apd, bpd, nev=3, tol=1e-8)
52+
@test apd*v[:,2] d[2]*bpd*v[:,2] atol=testtol
6253
@test norm(v) > testtol # eigenvectors cannot be null vectors
63-
end
6454

65-
@testset "ArgumentErrors" begin
66-
@test_throws ArgumentError eigs(rand(elty,2,2))
67-
@test_throws ArgumentError eigs(a, nev=-1)
68-
@test_throws ArgumentError eigs(a, which=:Z)
69-
@test_throws ArgumentError eigs(a, which=:BE)
70-
@test_throws DimensionMismatch eigs(a, v0=zeros(elty,n+2))
71-
@test_throws ArgumentError eigs(a, v0=zeros(Int,n))
72-
if elty == Float64
73-
@test_throws ArgumentError eigs(a+a.',which=:SI)
74-
@test_throws ArgumentError eigs(a+a.',which=:LI)
75-
@test_throws ArgumentError eigs(a,sigma=rand(Complex64))
55+
@testset "(shift-and-)invert mode" begin
56+
(d,v) = eigs(apd, nev=3, sigma=0)
57+
@test apd*v[:,3] d[3]*v[:,3]
58+
@test norm(v) > testtol # eigenvectors cannot be null vectors
59+
60+
(d,v) = eigs(apd, bpd, nev=3, sigma=0, tol=1e-8)
61+
@test apd*v[:,1] d[1]*bpd*v[:,1] atol=testtol
62+
@test norm(v) > testtol # eigenvectors cannot be null vectors
63+
end
64+
65+
@testset "ArgumentErrors" begin
66+
@test_throws ArgumentError eigs(rand(elty,2,2))
67+
@test_throws ArgumentError eigs(a, nev=-1)
68+
@test_throws ArgumentError eigs(a, which=:Z)
69+
@test_throws ArgumentError eigs(a, which=:BE)
70+
@test_throws DimensionMismatch eigs(a, v0=zeros(elty,n+2))
71+
@test_throws ArgumentError eigs(a, v0=zeros(Int,n))
72+
if elty == Float64
73+
@test_throws ArgumentError eigs(a+a.',which=:SI)
74+
@test_throws ArgumentError eigs(a+a.',which=:LI)
75+
@test_throws ArgumentError eigs(a,sigma=rand(Complex64))
76+
end
7677
end
7778
end
78-
end
7979

80-
@testset "Symmetric generalized with singular B" begin
81-
n = 10
82-
k = 3
83-
A = randn(n,n); A = A'A
84-
B = randn(n,k); B = B*B'
85-
@test sort(eigs(A, B, nev = k, sigma = 1.0)[1]) sort(eigvals(A, B)[1:k])
80+
@testset "Symmetric generalized with singular B" begin
81+
n = 10
82+
k = 3
83+
A = randn(n,n); A = A'A
84+
B = randn(n,k); B = B*B'
85+
@test sort(eigs(A, B, nev = k, sigma = 1.0)[1]) sort(eigvals(A, B)[1:k])
86+
end
8687
end
8788
end
8889

test/linalg/lapack.jl

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import Base.LinAlg.BlasInt
1010
@test_throws ArgumentError Base.LinAlg.LAPACK.chktrans('Z')
1111

1212
@testset "syevr" begin
13-
let
14-
srand(123)
13+
guardsrand(123) do
1514
Ainit = randn(5,5)
1615
@testset for elty in (Float32, Float64, Complex64, Complex128)
1716
if elty == Complex64 || elty == Complex128

test/linalg/tridiag.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ function test_approx_eq_vecs(a::StridedVecOrMat{S}, b::StridedVecOrMat{T}, error
1414
end
1515
end
1616

17-
let n = 12 #Size of matrix problem to test
18-
srand(123)
17+
guardsrand(123) do
18+
n = 12 #Size of matrix problem to test
1919
@testset for elty in (Float32, Float64, Complex64, Complex128, Int)
2020
if elty == Int
2121
srand(61516384)

test/random.jl

+25-20
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# This file is a part of Julia. License is MIT: https://julialang.org/license
22

3-
srand(0)
3+
44

55
# Issue #6573
6-
let
6+
guardsrand(0) do
77
rand()
88
x = rand(384)
99
@test find(x .== rand()) == []
@@ -119,11 +119,12 @@ for T in [UInt32, UInt64, UInt128, Int128]
119119
r = rand(s, 1, 2)
120120
@test size(r) == (1, 2)
121121
@test typeof(r) == Matrix{BigInt}
122-
123-
srand(0)
124-
r = rand(s)
125-
srand(0)
126-
@test rand(s) == r
122+
guardsrand() do
123+
srand(0)
124+
r = rand(s)
125+
srand(0)
126+
@test rand(s) == r
127+
end
127128
end
128129

129130
# Test ziggurat tables
@@ -211,16 +212,15 @@ randmtzig_fill_ziggurat_tables()
211212
@test all(fe == Base.Random.fe)
212213

213214
#same random numbers on for small ranges on all systems
214-
215-
let
216-
global global_seed = rand(UInt) #leave state nondeterministic as above
217-
srand(global_seed)
215+
guardsrand() do
216+
seed = rand(UInt)
217+
srand(seed)
218218
r = map(Int64, rand(map(Int32, 97:122)))
219-
srand(global_seed)
219+
srand(seed)
220220
@test r == rand(map(Int64, 97:122))
221-
srand(global_seed)
221+
srand(seed)
222222
r = map(UInt64, rand(map(UInt32, 97:122)))
223-
srand(global_seed)
223+
srand(seed)
224224
@test r == rand(map(UInt64, 97:122))
225225
end
226226

@@ -268,7 +268,7 @@ let mt = MersenneTwister(0)
268268
0x4b54632b4619f4eca22675166784d229][i]
269269
end
270270

271-
srand(mt,0)
271+
srand(mt, 0)
272272
for (i,T) in enumerate([Int8, UInt8, Int16, UInt16, Int32, UInt32, Int64, UInt64, Int128, Float16, Float32])
273273
A = Array{T}(16)
274274
B = Array{T}(31)
@@ -281,7 +281,7 @@ let mt = MersenneTwister(0)
281281
-33032345278809823492812856023466859769,Float16(0.95),0.51829386f0][i]
282282
end
283283

284-
srand(mt,0)
284+
srand(mt, 0)
285285
AF64 = Array{Float64}(Base.Random.dsfmt_get_min_array_size()-1)
286286
@test rand!(mt, AF64)[end] == 0.957735065345398
287287
@test rand!(mt, AF64)[end] == 0.6492481059865669
@@ -497,7 +497,9 @@ let mta = MersenneTwister(42), mtb = MersenneTwister(42)
497497
end
498498

499499
# test PRNG jump
500-
let mta = MersenneTwister(global_seed), mtb = MersenneTwister(global_seed)
500+
let seed = rand(UInt)
501+
mta = MersenneTwister(seed)
502+
mtb = MersenneTwister(seed)
501503
step = 25000*2
502504
size = 4
503505
jump25000 = "35931a4947eeab70a9abbfaca4a79cfcf2610a35a586c6f4e4bdfa826d538cbfb0432c37321fcec4f6c98de3df06685087032988b0ad9a2144562aa82e06f2f6f256b5b412c524e35383a894da7b04e142c4156290585186d8fc06d3141a778220c2519a851b5a9e5947a3f745b71804631988825e21dba40392ff4c036b30d2d013b45e2be94b5e130a9c6424d2e82f48c855c81bd10757fdb5a91e23e9e312e430514ea31631d8897b4cf26eb39b37be0c92706e5637d4b34c1e4046b741e455df195cb512e8e0f8d578175a3da5e00d7ce247d9b92042b1b515d01f7f89fe661ebccb06dfb77bc0fbb99806921b472ccce58f2166ac058d9cf427ad7d74986e60a56d2fee0a8b680e466a8ea4e508a76c058b6f97b99c9aa5b10297b1a1bd6a8e80f3a79e008fa55a4a8915fbdec78b6b117ad67e195311fe79fc084c33f6db546f5b7602d010fa8b830e3f1b00cef00ee16840178fc7e9aa5f1cee625d43de8488bf6c8bd379ea6f97c55c7a9ee091477a23533d5e52e194bd9d4e17b02a64a2736feb3779fabd5777e448ffee0f2d4b38a8e7441822b882fc6df0bde8541e85c0c78a05936cff0c88a50980b7a84971fba3650991fe2cba425ac4b4289e7b06ce2cfabfcc8a553201e8c74b45e4ae74b6d054e37af95e6fd55e029b7c526b85ecfb3be8db670218ee3dda7b2a54ab1ed26eefe4cd1d2a9c589a6e94d0aa3ebe29e40e616aa0b731061c3d6e247ec610024a1a97b7adb7919308b0fb5dd5d51a58aa2f55d77b88037de7c1a74823c96cb09d22dd7f90dba14eefdcffaab34d323c829f24742f6f6b32b0724a26ae4a81130a8a275d30c21e6245fa27cf26d606a49bccba2980697c32d9efe583c4ee2140569025c4f044d744bc40cec1660d9e4d2de3a4de83bae4f0a9fdb34ef4509b2b4e6c37967a485a52d69d1573bb826bc64c966de9c792b7c2f07b645c56a29381911a98928e48516f246a55bcaa78f3c7d1c30127df5f06ba0a2d6a5e54605a20e60fab30c01a9472cb610ca0ef2418a985af00c7e47539111bf539dd554297d0374a7ff627d879600595b442c8dcffcffa3bbb07e5c7882ff0858142be4deac448698f0917fe2b7a9b686a9df1fa929f06a51aff992a6ee0b0605f8b34b87600cfa0af2475333b78625ce1520c793dc5080218247b4e41bbd7d9dab163470fe17a3d2622cdce979cc5565b0bc04eabaf656f21fa072a18ab33c656b665248ef20321407fef263b1c67316f2c6f236951990099e42d4614d8e08b27aa89d9f4548fa321d4b381d2da04fd7f17d6b9a68adfd0e4427196d25dcad869f8a155c6242f7d072baa5e7405ceb65dfaa3eb864bfe679a17df34273fde5037befe9ed5391b932cee271f59128c61ab3f0fc3f7cf8ff051fbda8382c64579efddd494c79850c56bda73bcd39c20c2820d191995b3335253c3b0ac8f5e5373f40c228886e6c526c2c249a5304578ba2a80f591c34ca1eaa84d6cc9399cf3f1207e61c4acada647e4e87ad5fba84aeeff6b6881d35bda77c74384fc5e279a0f495d509bc882c2b8bc790651a6d7a4ecba23a3f05111e1d8be37c03439fbd484668ceab69a52b7d519b169cbbcf634ee5e3bf78a5f8771f95fea03f2cb889e116a9f5de3abeacb8e42475fb5d022484b02d11f1e406332e0a773098fc4f0baa57cda2863c554f291d4eb74e63e4b3d44b0ed156bff1820003d407a3aaa9e6dfaa226ba7ef2fd0eff90a5482926f47f24f67019edccb6fd329eef30b5fb2125276aa1fe75a702b32c907ab133c72a74e77e0a5eb48fc5176b9d65b75b0038e1a9ed74ec2a3dcd2348fa54256f082abc01a301bacef7380f20ee0411c08a35dafdaae9f9fc123448da28626ffcc654e9d522bc8b8776b13a3310f7eeb4d27290ef4cbc7492fbcb5409d455748a8a1f087430cf5e6f453e2caa0c5343fcf4374cc38bead49941d8ab59b4d5181716c238aa88dbf1c4a2da3a9a9b9435d5ee1d51d27b0655a4308c1252aaf633cd8f44a351ffc8cec65de0b7e4e2556100e2ae9bc511044351109a6254b2d387b1a72c768f43fa7be6b93806e323b55c3e7925ed627dc708fde0954b299b1ca33bb7fbe33e0f9e4ce5b4f26efaf8e5b9507ada4f8658998eb7167afbd4482ee47cc60f4039d6a77c1fb126033bfc2e7c6162ff7561f22e263325c53a014a4ac9390fe6fab5d433c1e9896fe561f22fc8290f3f4560b676f3dfbfd1fe605343a0685349241b83a28d61cc0292d1f638a36d3d87bfa9f72f9df1cfe90692dfda5bd5e698362f5316984cbe73a132a801acbca76b5f5c23d98a217f2159b6cbbcdf8f52d23ea24c9471a31562a651b20e05cd0300ee500a450cfdaa4d2d83f7e7e27f8b7c793cf80f8067dadef77e49a64c373b97bac4dd472e5145072c73d0fdd68d9646c8a8ed9aec6c40bc915ae44ae27391ca0f1a4d2cb1c3d097be614e6eba807f4549d769a5872f268ccf770f2682d844490348f0b6a0d2b51aadbb5523cf708b66f9928eed12b35a39cf42d283b29f5283e1c8ba1f73457af17b14cdfdf9a85b0589acf1f9504e46b0bab8be848dac5673587035b99f56c41d3195bbba1616b149a22193cfb760d6bf2d84861653cd21be9a2d33187cb25d47fbecdd4626d1d97202f460a39b7128cadb77ddf682feca61fb6de0290df598a565a6361a91d76c0c685046489ed4cb1dcc4f1cea849c12dc4a3d38d3010567f387590532b78927e92f0b718c84e882b3df071a78a011d0fd56d4101dcb009914a16a781b240a6fb2440c72b0ffb365be9d3459d114e665a0d35d7b8bd280101d85d1211d939ba0b15ab528c4f9dd2b001172561d211671b96873010ae3c2b8317f773d735698914228764b831423ae19dd4bbb008b9f1bd1e3ebdd626e629a46a9dd70bdd4bb30e2279e83c12bbbead6479b5f9980b1a9c785395520703a9367d931b45c1566c9d314b1745cafc6d0667cc9bc94d0c53a960c829eb09b768ab6bb2133e4fea1d939f3d3f8e1237210cf3577c830f0493073dc1d189abf27402b8b31b7c172c43dbf331a0828adfe737380e763d0ab0bfaaf94ec04830f94380a83718f340c4eeb20d7eb22b94613be84a9ed332ab364efff6cb37eec35d186185cca725e7a748f6bdb427604fb1628d49a7424a5a62a2e930fe142b035503af332fe748d5e63591b9ac54071ca843d5e474a48837de8b80387f3269ab50d2fd99c08c971e015d13fa02c7c315922ce58bdacbf8ee48827851a61fca59882d7eadcce3166dfe012aa9ec849e698e776a4d384f4755b506a222636942a81bbbffa1ff47e4d81fe68120aebcfd1a7e0000fd0cffdc44e1f0cd69ea2b4936564c78af51fed1cc8e34f0b46d6330b4b50ddee09335b7b0be0bc9f7f8e48415e15d08f811653d21bc6dd152742b086caadcc6dff5e27b40da42c2f1ebf3dd2bd51c418718e499859239317fcab10892eadf1c0ebf7a4246bce4cce3617193032f3e41b977dc8650298ac39631c527460364effea0f0bfd043df72ead0406aba1bcd636d65d7b89979eb8e1";
@@ -518,8 +520,10 @@ let mta = MersenneTwister(global_seed), mtb = MersenneTwister(global_seed)
518520
end
519521

520522
# test that the following is not an error (#16925)
521-
srand(typemax(UInt))
522-
srand(typemax(UInt128))
523+
guardsrand() do
524+
srand(typemax(UInt))
525+
srand(typemax(UInt128))
526+
end
523527

524528
# copy, == and hash
525529
let seed = rand(UInt32, 10)
@@ -563,7 +567,8 @@ let seed = rand(UInt32, 10)
563567
end
564568

565569
# srand(rng, ...) returns rng (#21248)
566-
let g = Base.Random.GLOBAL_RNG,
570+
guardsrand() do
571+
g = Base.Random.GLOBAL_RNG
567572
m = MersenneTwister(0)
568573
@test srand() === g
569574
@test srand(rand(UInt)) === g

0 commit comments

Comments
 (0)