{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Test.Validity.Shrinking.Property
( shrinkPreservesValidOnGenValid
, shrinkPreservesInvalidOnGenInvalid
, shrinkValidPreservesValid
, shrinkInvalidPreservesInvalid
, shrinkingStaysValid
, shrinkingStaysValidWithLimit
, shrinkingStaysInvalid
, shrinkingPreserves
, shrinkingPreservesWithLimit
, shrinkDoesNotShrinkToItself
, shrinkDoesNotShrinkToItselfWithLimit
, shrinkDoesNotShrinkToItselfOnValid
, shrinkDoesNotShrinkToItselfOnValidWithLimit
, shrinkDoesNotShrinkToItselfOnInvalid
, shrinkDoesNotShrinkToItselfOnInvalidWithLimit
, doesNotShrinkToItself
, doesNotShrinkToItselfWithLimit
) where
import Data.GenValidity
import Test.QuickCheck
shrinkPreservesValidOnGenValid ::
forall a. (Show a, GenValid a)
=> (a -> [a])
-> Property
shrinkPreservesValidOnGenValid = shrinkingStaysValid genValid
shrinkPreservesInvalidOnGenInvalid ::
forall a. (Show a, GenInvalid a)
=> (a -> [a])
-> Property
shrinkPreservesInvalidOnGenInvalid = shrinkingStaysValid genInvalid
shrinkValidPreservesValid ::
forall a. (Show a, GenValid a)
=> Gen a
-> Property
shrinkValidPreservesValid gen = shrinkingStaysValid gen shrinkValid
shrinkInvalidPreservesInvalid ::
forall a. (Show a, GenInvalid a)
=> Gen a
-> Property
shrinkInvalidPreservesInvalid gen = shrinkingStaysValid gen shrinkInvalid
shrinkingStaysValid ::
forall a. (Show a, Validity a)
=> Gen a
-> (a -> [a])
-> Property
shrinkingStaysValid gen s = shrinkingPreserves gen s isValid
shrinkingStaysValidWithLimit ::
forall a. (Show a, Validity a)
=> Gen a
-> (a -> [a])
-> Int
-> Property
shrinkingStaysValidWithLimit gen s l =
shrinkingPreservesWithLimit gen s l isValid
shrinkingStaysInvalid ::
forall a. (Show a, Validity a)
=> Gen a
-> (a -> [a])
-> Property
shrinkingStaysInvalid gen s = shrinkingPreserves gen s isInvalid
shrinkingPreserves ::
forall a. Show a
=> Gen a
-> (a -> [a])
-> (a -> Bool)
-> Property
shrinkingPreserves gen s p = forAll gen $ \d -> not (p d) || all p (s d)
shrinkingPreservesWithLimit ::
forall a. Show a
=> Gen a
-> (a -> [a])
-> Int
-> (a -> Bool)
-> Property
shrinkingPreservesWithLimit gen s l p =
forAll gen $ \d -> not (p d) || all p (take l $ s d)
shrinkDoesNotShrinkToItself ::
forall a. (Show a, Eq a, GenUnchecked a)
=> (a -> [a])
-> Property
shrinkDoesNotShrinkToItself = doesNotShrinkToItself genUnchecked
shrinkDoesNotShrinkToItselfWithLimit ::
forall a. (Show a, Eq a, GenUnchecked a)
=> (a -> [a])
-> Int
-> Property
shrinkDoesNotShrinkToItselfWithLimit =
doesNotShrinkToItselfWithLimit genUnchecked
shrinkDoesNotShrinkToItselfOnValid ::
forall a. (Show a, Eq a, GenValid a)
=> (a -> [a])
-> Property
shrinkDoesNotShrinkToItselfOnValid = doesNotShrinkToItself genValid
shrinkDoesNotShrinkToItselfOnValidWithLimit ::
forall a. (Show a, Eq a, GenValid a)
=> (a -> [a])
-> Int
-> Property
shrinkDoesNotShrinkToItselfOnValidWithLimit =
doesNotShrinkToItselfWithLimit genValid
shrinkDoesNotShrinkToItselfOnInvalid ::
forall a. (Show a, Eq a, GenInvalid a)
=> (a -> [a])
-> Property
shrinkDoesNotShrinkToItselfOnInvalid = doesNotShrinkToItself genInvalid
shrinkDoesNotShrinkToItselfOnInvalidWithLimit ::
forall a. (Show a, Eq a, GenInvalid a)
=> (a -> [a])
-> Int
-> Property
shrinkDoesNotShrinkToItselfOnInvalidWithLimit =
doesNotShrinkToItselfWithLimit genInvalid
doesNotShrinkToItself ::
forall a. (Show a, Eq a)
=> Gen a
-> (a -> [a])
-> Property
doesNotShrinkToItself gen s = forAll gen $ \a -> all (/= a) $ s a
doesNotShrinkToItselfWithLimit ::
forall a. (Show a, Eq a)
=> Gen a
-> (a -> [a])
-> Int
-> Property
doesNotShrinkToItselfWithLimit gen s l =
forAll gen $ \a -> all (/= a) $ take l $ s a