From 4aab0afe5c91e4ed038767c0a9fe607c58441cde Mon Sep 17 00:00:00 2001 From: kimikage Date: Fri, 5 Apr 2024 12:58:31 +0900 Subject: [PATCH] Use `StableRNG` in tests --- Project.toml | 4 +++- test/common.jl | 2 +- test/fixed.jl | 3 ++- test/normed.jl | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Project.toml b/Project.toml index 3e5a53bb..da614a0f 100644 --- a/Project.toml +++ b/Project.toml @@ -13,6 +13,7 @@ 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" @@ -20,8 +21,9 @@ 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"] diff --git a/test/common.jl b/test/common.jl index feb4cd20..fdd4cf7b 100644 --- a/test/common.jl +++ b/test/common.jl @@ -1,4 +1,4 @@ -using FixedPointNumbers, Statistics, Random, Test +using FixedPointNumbers, Statistics, Random, StableRNGs, Test using FixedPointNumbers: bitwidth, rawtype, nbitsfrac using Base.Checked diff --git a/test/fixed.jl b/test/fixed.jl index 8a69bf95..54082aa3 100644 --- a/test/fixed.jl +++ b/test/fixed.jl @@ -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 diff --git a/test/normed.jl b/test/normed.jl index 3a0708bf..aa5f0f26 100644 --- a/test/normed.jl +++ b/test/normed.jl @@ -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