Skip to content

Commit

Permalink
Merge pull request #117 from idontgetoutmuch/unit-tests
Browse files Browse the repository at this point in the history
Check issue remains fixed
  • Loading branch information
idontgetoutmuch authored Apr 29, 2020
2 parents 99990d1 + 8ca0d1e commit 22a374e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion random.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions test/Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))

Expand Down

0 comments on commit 22a374e

Please sign in to comment.