Skip to content

Commit af56dd1

Browse files
authored
Use StableRNG in tests (#278)
1 parent ca600b0 commit af56dd1

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
using Base.Checked
44

test/fixed.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,8 @@ end
677677

678678
@testset "rand" begin
679679
test_rand(Fixed)
680-
@test rand(MersenneTwister(1234), Q0f7) === -0.156Q0f7
680+
@test !(rand(Q0f15) == rand(Q0f15) == rand(Q0f15)) # If this fails, we should suspect a bug.
681+
@test rand(StableRNG(1234), Q0f7) === 0.531Q0f7
681682
end
682683

683684
@testset "Promotion within Fixed" begin

test/normed.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,8 @@ end
650650

651651
@testset "rand" begin
652652
test_rand(Normed)
653-
@test rand(MersenneTwister(1234), N0f8) === 0.925N0f8
653+
@test !(rand(N0f16) == rand(N0f16) == rand(N0f16)) # If this fails, we should suspect a bug.
654+
@test rand(StableRNG(1234), N0f8) === 0.267N0f8
654655
end
655656

656657
@testset "Promotion within Normed" begin

0 commit comments

Comments
 (0)