Skip to content

Commit 202f908

Browse files
committed
Use StableRNG in tests (#278)
1 parent 1c9c75e commit 202f908

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1313
FixedPointNumbersStatisticsExt = "Statistics"
1414

1515
[compat]
16+
StableRNGs = "1"
1617
# Update this version specifier when Statistics.jl v1.11.2 is released.
1718
# https://github.com/JuliaStats/Statistics.jl/issues/165
1819
Statistics = "< 1.11.2"
1920
julia = "1"
2021

2122
[extras]
2223
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
24+
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
2325
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
2426
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2527

2628
[targets]
27-
test = ["Documenter", "Statistics", "Test"]
29+
test = ["Documenter", "StableRNGs", "Statistics", "Test"]

test/common.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using FixedPointNumbers, Statistics, Random, Test
1+
using FixedPointNumbers, Statistics, Random, StableRNGs, Test
22
using FixedPointNumbers: bitwidth, rawtype, nbitsfrac
33

44
# FIXME: Remove this comment (SP is borrowed from PR #224)

test/fixed.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,8 @@ end
487487
@test ndims(a) == 2 && eltype(a) === F
488488
@test size(a) == (3,5)
489489
end
490-
@test rand(MersenneTwister(1234), Q0f7) === -0.156Q0f7
490+
@test !(rand(Q0f15) == rand(Q0f15) == rand(Q0f15)) # If this fails, we should suspect a bug.
491+
@test rand(StableRNG(1234), Q0f7) === 0.531Q0f7
491492
end
492493

493494
@testset "Promotion within Fixed" begin

test/normed.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,8 @@ end
503503
@test ndims(a) == 2 && eltype(a) === N
504504
@test size(a) == (3,5)
505505
end
506-
@test rand(MersenneTwister(1234), N0f8) === 0.925N0f8
506+
@test !(rand(N0f16) == rand(N0f16) == rand(N0f16)) # If this fails, we should suspect a bug.
507+
@test rand(StableRNG(1234), N0f8) === 0.267N0f8
507508
end
508509

509510
@testset "Promotion within Normed" begin

0 commit comments

Comments
 (0)