1818module Test.QuickCheck
1919 ( QC
2020 , quickCheck
21+ , quickCheckGen
2122 , quickCheck'
23+ , quickCheckGen'
2224 , quickCheckWithSeed
25+ , quickCheckGenWithSeed
2326 , quickCheckPure
27+ , quickCheckGenPure
2428 , class Testable
2529 , test
2630 , Result (..)
@@ -72,13 +76,28 @@ type QC eff a = Eff (console :: CONSOLE, random :: RANDOM, exception :: EXCEPTIO
7276quickCheck :: forall eff prop . Testable prop => prop -> QC eff Unit
7377quickCheck prop = quickCheck' 100 prop
7478
79+ -- | A version of `quickCheck` with the property specialized to `Gen`.
80+ -- |
81+ -- | The `quickCheckGen` variants are useful for writing property tests where a
82+ -- | `MonadGen` constraint (or QuickCheck's `Gen` directly) is being used,
83+ -- | rather than relying on `Arbitrary` instances. Especially useful for the
84+ -- | `MonadGen`-constrained properties as they will not infer correctly when
85+ -- | used with the `quickCheck` functions unless an explicit type annotation is
86+ -- | used.
87+ quickCheckGen :: forall eff prop . Testable prop => Gen prop -> QC eff Unit
88+ quickCheckGen = quickCheck
89+
7590-- | A variant of the `quickCheck` function which accepts an extra parameter
7691-- | representing the number of tests which should be run.
7792quickCheck' :: forall eff prop . Testable prop => Int -> prop -> QC eff Unit
7893quickCheck' n prop = do
7994 seed <- randomSeed
8095 quickCheckWithSeed seed n prop
8196
97+ -- | A version of `quickCheck'` with the property specialized to `Gen`.
98+ quickCheckGen' :: forall eff prop . Testable prop => Int -> Gen prop -> QC eff Unit
99+ quickCheckGen' = quickCheck'
100+
82101-- | A variant of the `quickCheck'` function that accepts a specific seed as
83102-- | well as the number tests that should be run.
84103quickCheckWithSeed
@@ -113,6 +132,10 @@ quickCheckWithSeed initialSeed n prop = do
113132 firstFailure <> First (Just { index, message, seed })
114133 }
115134
135+ -- | A version of `quickCheckWithSeed` with the property specialized to `Gen`.
136+ quickCheckGenWithSeed :: forall eff prop . Testable prop => Seed -> Int -> Gen prop -> QC eff Unit
137+ quickCheckGenWithSeed = quickCheckWithSeed
138+
116139type LoopState =
117140 { successes :: Int
118141 , firstFailure :: First { index :: Int , message :: String , seed :: Seed }
@@ -127,6 +150,10 @@ type LoopState =
127150quickCheckPure :: forall prop . Testable prop => Seed -> Int -> prop -> List Result
128151quickCheckPure s n prop = evalGen (replicateA n (test prop)) { newSeed: s, size: 10 }
129152
153+ -- | A version of `quickCheckPure` with the property specialized to `Gen`.
154+ quickCheckGenPure :: forall prop . Testable prop => Seed -> Int -> Gen prop -> List Result
155+ quickCheckGenPure = quickCheckPure
156+
130157-- | The `Testable` class represents _testable properties_.
131158-- |
132159-- | A testable property is a function of zero or more `Arbitrary` arguments,
0 commit comments