Skip to content

Commit

Permalink
Use StableRNG in tests (#278)
Browse files Browse the repository at this point in the history
  • Loading branch information
kimikage authored Apr 13, 2024
1 parent ca600b0 commit af56dd1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
FixedPointNumbersStatisticsExt = "Statistics"

[compat]
StableRNGs = "1"
# Update this version specifier when Statistics.jl v1.11.2 is released.
# https://github.com/JuliaStats/Statistics.jl/issues/165
Statistics = "< 1.11.2"
julia = "1"

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

[targets]
test = ["Documenter", "Statistics", "Test"]
test = ["Documenter", "StableRNGs", "Statistics", "Test"]
2 changes: 1 addition & 1 deletion test/common.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using FixedPointNumbers, Statistics, Random, Test
using FixedPointNumbers, Statistics, Random, StableRNGs, Test
using FixedPointNumbers: bitwidth, rawtype, nbitsfrac
using Base.Checked

Expand Down
3 changes: 2 additions & 1 deletion test/fixed.jl
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,8 @@ end

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

@testset "Promotion within Fixed" begin
Expand Down
3 changes: 2 additions & 1 deletion test/normed.jl
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,8 @@ end

@testset "rand" begin
test_rand(Normed)
@test rand(MersenneTwister(1234), N0f8) === 0.925N0f8
@test !(rand(N0f16) == rand(N0f16) == rand(N0f16)) # If this fails, we should suspect a bug.
@test rand(StableRNG(1234), N0f8) === 0.267N0f8
end

@testset "Promotion within Normed" begin
Expand Down

0 comments on commit af56dd1

Please sign in to comment.