From f913dcd9dfb3199787d627d32995441d35829fd0 Mon Sep 17 00:00:00 2001 From: Dominic Steinitz Date: Wed, 29 Apr 2020 11:46:24 +0100 Subject: [PATCH 1/3] Check issue remains fixed --- random.cabal | 3 ++- test/Spec.hs | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/random.cabal b/random.cabal index a8350727f..28d2f5e78 100644 --- a/random.cabal +++ b/random.cabal @@ -135,7 +135,8 @@ test-suite spec smallcheck >=1.1 && <1.2, tasty >=1.0 && <1.3, tasty-smallcheck >=0.8 && <0.9, - tasty-expected-failure >=0.11 && <0.12 + tasty-expected-failure >=0.11 && <0.12, + tasty-hunit >=0.10 && <0.11 benchmark legacy-bench type: exitcode-stdio-1.0 diff --git a/test/Spec.hs b/test/Spec.hs index 800b5d1b1..1c5c613b3 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -13,6 +13,7 @@ import Data.Word import Data.Int import System.Random import Test.Tasty +import Test.Tasty.HUnit import Test.Tasty.SmallCheck as SC import Test.SmallCheck.Series as SC import Data.Typeable @@ -71,8 +72,21 @@ main = -- , bitmaskSpec @Word64 -- , bitmaskSpec @Word , runSpec + , unitTests ] +unitTests :: TestTree +unitTests = testGroup "Unit tests" + [ -- Check that https://github.com/haskell/random/issues/53 does not regress + + testCase "Subnormal generation respects upper bound" $ + [] @?= (filter (>4.0e-45) $ take 10 $ randomRs (0,(4.0e-45::Float)) $ mkStdGen 0) + + , testCase "Subnormal generation includes upper bound" $ + 1.0e-45 `elem` (take 100 $ randomRs (0,(1.0e-45::Float)) $ mkStdGen 0) @? + "Does not contain 1.0e-45" + ] + showsType :: forall t . Typeable t => ShowS showsType = showsTypeRep (typeRep (Proxy :: Proxy t)) From b72f1a5fca38d409e2a1c09f3ceb4b4334c559e8 Mon Sep 17 00:00:00 2001 From: idontgetoutmuch Date: Wed, 29 Apr 2020 12:56:47 +0100 Subject: [PATCH 2/3] Update test/Spec.hs Co-Authored-By: Leonhard Markert --- test/Spec.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Spec.hs b/test/Spec.hs index 1c5c613b3..09eadff68 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -80,7 +80,7 @@ unitTests = testGroup "Unit tests" [ -- Check that https://github.com/haskell/random/issues/53 does not regress testCase "Subnormal generation respects upper bound" $ - [] @?= (filter (>4.0e-45) $ take 10 $ randomRs (0,(4.0e-45::Float)) $ mkStdGen 0) + [] @?= (filter (>4.0e-45) $ take 100000 $ randomRs (0,(4.0e-45::Float)) $ mkStdGen 0) , testCase "Subnormal generation includes upper bound" $ 1.0e-45 `elem` (take 100 $ randomRs (0,(1.0e-45::Float)) $ mkStdGen 0) @? From 8ca0d1ebb470ecc14ed625f926804672d26bada8 Mon Sep 17 00:00:00 2001 From: Dominic Steinitz Date: Wed, 29 Apr 2020 13:03:06 +0100 Subject: [PATCH 3/3] Respond to comments --- test/Spec.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/Spec.hs b/test/Spec.hs index 09eadff68..1bd0f8a20 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -72,14 +72,14 @@ main = -- , bitmaskSpec @Word64 -- , bitmaskSpec @Word , runSpec - , unitTests + , floatTests ] -unitTests :: TestTree -unitTests = testGroup "Unit tests" +floatTests :: TestTree +floatTests = testGroup "(Float)" [ -- Check that https://github.com/haskell/random/issues/53 does not regress - testCase "Subnormal generation respects upper bound" $ + testCase "Subnormal generation not above upper bound" $ [] @?= (filter (>4.0e-45) $ take 100000 $ randomRs (0,(4.0e-45::Float)) $ mkStdGen 0) , testCase "Subnormal generation includes upper bound" $