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..1bd0f8a20 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 + , floatTests ] +floatTests :: TestTree +floatTests = testGroup "(Float)" + [ -- Check that https://github.com/haskell/random/issues/53 does not regress + + 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" $ + 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))