Skip to content
This repository was archived by the owner on Oct 4, 2020. It is now read-only.

Commit cfd009e

Browse files
committed
Add Testable instance for Gen`
1 parent f99b46a commit cfd009e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Test/StrongCheck.purs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ import Control.Monad.Eff (Eff)
2424
import Control.Monad.Eff.Console (CONSOLE, log)
2525
import Control.Monad.Eff.Exception (EXCEPTION, throwException, error)
2626
import Control.Monad.Eff.Random (RANDOM)
27+
import Control.Monad.Free (Free)
2728
import Control.Monad.Trampoline (runTrampoline)
2829

2930
import Data.Array as A
3031
import Data.Foldable (class Foldable)
3132
import Data.Int as Int
33+
import Data.Lazy (Lazy)
3234
import Data.List (List(..), length)
3335
import Data.List as List
3436
import Data.Maybe (maybe)
@@ -37,9 +39,9 @@ import Data.Tuple (Tuple(..))
3739

3840
import Math as Math
3941

40-
import Test.StrongCheck.Gen (Gen, GenState(..), collectAll, sample', decorateSeed)
41-
import Test.StrongCheck.LCG (Seed, randomSeed, runSeed)
4242
import Test.StrongCheck.Arbitrary (class Arbitrary, arbitrary)
43+
import Test.StrongCheck.Gen (GenT, Gen, GenState(..), collectAll, sample', decorateSeed)
44+
import Test.StrongCheck.LCG (Seed, randomSeed, runSeed)
4345

4446
import Test.StrongCheck.Arbitrary (class Arbitrary, arbitrary, class Coarbitrary, coarbitrary) as Exports
4547
import Test.StrongCheck.LCG (Seed, mkSeed) as Exports
@@ -80,6 +82,9 @@ instance testableResult :: Testable Result where
8082
instance testableFunction :: (Arbitrary t, Testable prop) => Testable (t -> prop) where
8183
test f = test <<< f =<< arbitrary
8284

85+
instance testableGen :: Testable prop => Testable (GenT (Free Lazy) prop) where
86+
test = flip bind test
87+
8388
-- | Checks the proposition for 100 random values.
8489
quickCheck :: forall eff prop. Testable prop => prop -> SC eff Unit
8590
quickCheck prop = quickCheck' 100 prop

0 commit comments

Comments
 (0)