@@ -4,7 +4,8 @@ import Control.Applicative
4
4
import Control.Arrow (second )
5
5
import Control.Monad
6
6
import Data.Typeable
7
- import Test.QuickCheck hiding (generate )
7
+ import Test.QuickCheck (Gen , Property , Testable )
8
+ import Test.QuickCheck qualified as QC
8
9
import Test.QuickCheck.DynamicLogic.CanGenerate
9
10
import Test.QuickCheck.DynamicLogic.Quantify
10
11
import Test.QuickCheck.DynamicLogic.SmartShrinking
@@ -359,8 +360,8 @@ forAllUniqueScripts s f k =
359
360
let d = unDynFormula f sz
360
361
n = unsafeNextVarIndex $ vars s
361
362
in case generate chooseUniqueNextStep d n s 500 of
362
- Nothing -> counterexample " Generating Non-unique script in forAllUniqueScripts" False
363
- Just test -> validDLTest test . applyMonitoring d test . property $ k (scriptFromDL test)
363
+ Nothing -> QC. counterexample " Generating Non-unique script in forAllUniqueScripts" False
364
+ Just test -> validDLTest test . applyMonitoring d test . QC. property $ k (scriptFromDL test)
364
365
365
366
-- | Creates a `Property` from `DynFormula` with some specialised isomorphism for shrinking purpose.
366
367
forAllMappedScripts
@@ -373,22 +374,22 @@ forAllMappedScripts
373
374
forAllMappedScripts to from f k =
374
375
QC. withSize $ \ n ->
375
376
let d = unDynFormula f n
376
- in forAllShrinkBlind
377
- (Smart 0 <$> sized ((from <$> ) . generateDLTest d))
377
+ in QC. forAllShrinkBlind
378
+ (QC. Smart 0 <$> QC. sized ((from <$> ) . generateDLTest d))
378
379
(shrinkSmart ((from <$> ) . shrinkDLTest d . to))
379
- $ \ (Smart _ script) ->
380
+ $ \ (QC. Smart _ script) ->
380
381
withDLScript d k (to script)
381
382
382
383
withDLScript :: (DynLogicModel s , Testable a ) => DynLogic s -> (Actions s -> a ) -> DynLogicTest s -> Property
383
384
withDLScript d k test =
384
- validDLTest test . applyMonitoring d test . property $ k (scriptFromDL test)
385
+ validDLTest test . applyMonitoring d test . QC. property $ k (scriptFromDL test)
385
386
386
387
withDLScriptPrefix :: (DynLogicModel s , Testable a ) => DynFormula s -> (Actions s -> a ) -> DynLogicTest s -> Property
387
388
withDLScriptPrefix f k test =
388
389
QC. withSize $ \ n ->
389
390
let d = unDynFormula f n
390
391
test' = unfailDLTest d test
391
- in validDLTest test' . applyMonitoring d test' . property $ k (scriptFromDL test')
392
+ in validDLTest test' . applyMonitoring d test' . QC. property $ k (scriptFromDL test')
392
393
393
394
-- | Validate generated test case.
394
395
--
@@ -401,9 +402,9 @@ withDLScriptPrefix f k test =
401
402
validDLTest :: StateModel s => DynLogicTest s -> Property -> Property
402
403
validDLTest test prop =
403
404
case test of
404
- DLScript {} -> counterexample (show test) prop
405
- Stuck {} -> property Discard
406
- _other -> counterexample (show test) False
405
+ DLScript {} -> QC. counterexample (show test) prop
406
+ Stuck {} -> QC. property QC. Discard
407
+ _other -> QC. counterexample (show test) False
407
408
408
409
generateDLTest :: DynLogicModel s => DynLogic s -> Int -> Gen (DynLogicTest s )
409
410
generateDLTest d size = generate chooseNextStep d 0 (initialStateFor d) size
@@ -516,7 +517,7 @@ nextSteps' gen (ForAll q f) = do
516
517
nextSteps' gen (Monitor _f d) = nextSteps' gen d
517
518
518
519
chooseOneOf :: [(Double , a )] -> Gen a
519
- chooseOneOf steps = frequency [(round (w / never), return s) | (w, s) <- steps]
520
+ chooseOneOf steps = QC. frequency [(round (w / never), return s) | (w, s) <- steps]
520
521
521
522
never :: Double
522
523
never = 1.0e-9
@@ -586,7 +587,7 @@ keepTryingUntil :: Int -> Gen a -> (a -> Bool) -> Gen (Maybe a)
586
587
keepTryingUntil 0 _ _ = return Nothing
587
588
keepTryingUntil n g p = do
588
589
x <- g
589
- if p x then return $ Just x else scale (+ 1 ) $ keepTryingUntil (n - 1 ) g p
590
+ if p x then return $ Just x else QC. scale (+ 1 ) $ keepTryingUntil (n - 1 ) g p
590
591
591
592
shrinkDLTest :: DynLogicModel s => DynLogic s -> DynLogicTest s -> [DynLogicTest s ]
592
593
shrinkDLTest _ (Looping _) = []
@@ -710,7 +711,7 @@ demonicAlt ds = foldr1 (Alt Demonic) ds
710
711
711
712
propPruningGeneratedScriptIsNoop :: DynLogicModel s => DynLogic s -> Property
712
713
propPruningGeneratedScriptIsNoop d =
713
- forAll (sized $ \ n -> choose (1 , max 1 n) >>= generateDLTest d) $ \ test ->
714
+ QC. forAll (QC. sized $ \ n -> QC. choose (1 , max 1 n) >>= generateDLTest d) $ \ test ->
714
715
let script = case test of
715
716
BadPrecondition s _ _ -> s
716
717
Looping s -> s
0 commit comments