about summary refs log tree commit diff
path: root/users/grfn/xanthous/test/Xanthous/RandomSpec.hs
blob: 187336f086501c628992d97985aecdf201273634 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
--------------------------------------------------------------------------------
module Xanthous.RandomSpec (main, test) where
--------------------------------------------------------------------------------
import Test.Prelude
--------------------------------------------------------------------------------
import Control.Monad.Random
--------------------------------------------------------------------------------
import Xanthous.Random
--------------------------------------------------------------------------------

main :: IO ()
main = defaultMain test

test :: TestTree
test = testGroup "Xanthous.Random"
  [ testGroup "chooseSubset"
    [ testProperty "chooses a subset"
      $ \(l :: [Int]) (Positive (r :: Double)) -> randomTest $ do
        ss <- chooseSubset r l
        pure $ all (`elem` l) ss

    ]
  ]
  where
    randomTest prop = evalRandT prop . mkStdGen =<< arbitrary