| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Test.Cardano.Ledger.Imp.Common
Synopsis
- data KeyPair (kd ∷ KeyRole) = KeyPair {
- vKey ∷ !(VKey kd)
- sKey ∷ !(SignKeyDSIGN DSIGN)
- mkAddr ∷ (MakeCredential p 'Payment, MakeStakeReference s) ⇒ p → s → Addr
- mkCredential ∷ MakeCredential c r ⇒ c → Credential r
- data Result
- = Success { }
- | GaveUp { }
- | Failure {
- numTests ∷ Int
- numDiscarded ∷ Int
- numShrinks ∷ Int
- numShrinkTries ∷ Int
- numShrinkFinal ∷ Int
- usedSeed ∷ QCGen
- usedSize ∷ Int
- reason ∷ String
- theException ∷ Maybe AnException
- output ∷ String
- failingTestCase ∷ [String]
- failingLabels ∷ [String]
- failingClasses ∷ Set String
- witnesses ∷ [Witness]
- | NoExpectedFailure { }
- class Testable prop where
- type SpecWith a = SpecM a ()
- type Spec = SpecWith ()
- type Selector a = a → Bool
- data Fun a b = Fun (a :-> b, b, Shrunk) (a → b)
- data Gen a
- class CoArbitrary a where
- coarbitrary ∷ a → Gen b → Gen b
- class Arbitrary2 (f ∷ Type → Type → Type) where
- liftArbitrary2 ∷ Gen a → Gen b → Gen (f a b)
- liftShrink2 ∷ (a → [a]) → (b → [b]) → f a b → [f a b]
- class Arbitrary1 (f ∷ Type → Type) where
- liftArbitrary ∷ Gen a → Gen (f a)
- liftShrink ∷ (a → [a]) → f a → [f a]
- class Arbitrary a where
- shrink ∷ a → [a]
- newtype PrintableString = PrintableString {}
- newtype UnicodeString = UnicodeString {}
- newtype ASCIIString = ASCIIString {}
- class ShrinkState s a where
- shrinkInit ∷ a → s
- shrinkState ∷ a → s → [(a, s)]
- data Shrinking s a = Shrinking s a
- data Smart a = Smart Int a
- newtype Shrink2 a = Shrink2 {
- getShrink2 ∷ a
- newtype Small a = Small {
- getSmall ∷ a
- newtype Large a = Large {
- getLarge ∷ a
- newtype NonPositive a = NonPositive {
- getNonPositive ∷ a
- newtype NonNegative a = NonNegative {
- getNonNegative ∷ a
- newtype NonZero a = NonZero {
- getNonZero ∷ a
- newtype Negative a = Negative {
- getNegative ∷ a
- newtype Positive a = Positive {
- getPositive ∷ a
- newtype SortedList a = Sorted {
- getSorted ∷ [a]
- data InfiniteList a = InfiniteList {
- getInfiniteList ∷ [a]
- infiniteListInternalData ∷ InfiniteListInternalData a
- newtype NonEmptyList a = NonEmpty {
- getNonEmpty ∷ [a]
- newtype OrderedList a = Ordered {
- getOrdered ∷ [a]
- newtype Fixed a = Fixed {
- getFixed ∷ a
- newtype Blind a = Blind {
- getBlind ∷ a
- class Function a where
- data Confidence = Confidence {}
- data Witness = (Typeable a, Show a) ⇒ Wit a
- data Discard = Discard
- data Property
- data Args = Args {
- replay ∷ Maybe (QCGen, Int)
- maxSuccess ∷ Int
- maxDiscardRatio ∷ Int
- maxSize ∷ Int
- chatty ∷ Bool
- maxShrinks ∷ Int
- type HasCallStack = ?callStack ∷ CallStack
- class Example e where
- type Arg e
- type family Arg e
- class ToExpr a where
- toExpr ∷ a → Expr
- listToExpr ∷ [a] → Expr
- class NFData a
- type ActionWith a = a → IO ()
- type Expectation = Assertion
- pattern Fn3 ∷ (a → b → c → d) → Fun (a, b, c) d
- pattern Fn2 ∷ (a → b → c) → Fun (a, b) c
- pattern Fn ∷ (a → b) → Fun a b
- hspec ∷ Spec → IO ()
- parallel ∷ SpecWith a → SpecWith a
- vector ∷ Arbitrary a ⇒ Int → Gen [a]
- void ∷ Functor f ⇒ f a → f ()
- (==>) ∷ Testable prop ⇒ Bool → prop → Property
- describe ∷ HasCallStack ⇒ String → SpecWith a → SpecWith a
- xdescribe ∷ HasCallStack ⇒ String → SpecWith a → SpecWith a
- it ∷ (HasCallStack, Example a) ⇒ String → a → SpecWith (Arg a)
- xit ∷ (HasCallStack, Example a) ⇒ String → a → SpecWith (Arg a)
- fit ∷ (HasCallStack, Example a) ⇒ String → a → SpecWith (Arg a)
- fdescribe ∷ HasCallStack ⇒ String → SpecWith a → SpecWith a
- prop ∷ (HasCallStack, Testable prop) ⇒ String → prop → Spec
- xprop ∷ (HasCallStack, Testable prop) ⇒ String → prop → Spec
- fprop ∷ (HasCallStack, Testable prop) ⇒ String → prop → Spec
- ansiDocToString ∷ Doc AnsiStyle → String
- discard ∷ a
- getSize ∷ Gen Int
- scale ∷ (Int → Int) → Gen a → Gen a
- chooseAny ∷ Random a ⇒ Gen a
- chooseEnum ∷ Enum a ⇒ (a, a) → Gen a
- chooseInt ∷ (Int, Int) → Gen Int
- chooseBoundedIntegral ∷ (Bounded a, Integral a) ⇒ (a, a) → Gen a
- chooseInteger ∷ (Integer, Integer) → Gen Integer
- generate ∷ Gen a → IO a
- sample' ∷ Gen a → IO [a]
- sample ∷ Show a ⇒ Gen a → IO ()
- suchThatMap ∷ Gen a → (a → Maybe b) → Gen b
- sublistOf ∷ [a] → Gen [a]
- shuffle ∷ [a] → Gen [a]
- infiniteListOf ∷ Gen a → Gen [a]
- arbitrary1 ∷ (Arbitrary1 f, Arbitrary a) ⇒ Gen (f a)
- shrink1 ∷ (Arbitrary1 f, Arbitrary a) ⇒ f a → [f a]
- arbitrary2 ∷ (Arbitrary2 f, Arbitrary a, Arbitrary b) ⇒ Gen (f a b)
- shrink2 ∷ (Arbitrary2 f, Arbitrary a, Arbitrary b) ⇒ f a b → [f a b]
- genericShrink ∷ (Generic a, RecursivelyShrink (Rep a), GSubterms (Rep a) a) ⇒ a → [a]
- recursivelyShrink ∷ (Generic a, RecursivelyShrink (Rep a)) ⇒ a → [a]
- subterms ∷ (Generic a, GSubterms (Rep a) a) ⇒ a → [a]
- shrinkList ∷ (a → [a]) → [a] → [[a]]
- applyArbitrary2 ∷ (Arbitrary a, Arbitrary b) ⇒ (a → b → r) → Gen r
- applyArbitrary3 ∷ (Arbitrary a, Arbitrary b, Arbitrary c) ⇒ (a → b → c → r) → Gen r
- applyArbitrary4 ∷ (Arbitrary a, Arbitrary b, Arbitrary c, Arbitrary d) ⇒ (a → b → c → d → r) → Gen r
- arbitrarySizedIntegral ∷ Integral a ⇒ Gen a
- arbitrarySizedNatural ∷ Integral a ⇒ Gen a
- arbitrarySizedFractional ∷ Fractional a ⇒ Gen a
- arbitraryBoundedIntegral ∷ (Bounded a, Integral a) ⇒ Gen a
- arbitraryBoundedRandom ∷ (Bounded a, Random a) ⇒ Gen a
- arbitraryBoundedEnum ∷ (Bounded a, Enum a) ⇒ Gen a
- arbitrarySizedBoundedIntegral ∷ (Bounded a, Integral a) ⇒ Gen a
- arbitraryUnicodeChar ∷ Gen Char
- arbitraryASCIIChar ∷ Gen Char
- arbitraryPrintableChar ∷ Gen Char
- shrinkNothing ∷ a → [a]
- shrinkMap ∷ Arbitrary a ⇒ (a → b) → (b → a) → b → [b]
- shrinkMapBy ∷ (a → b) → (b → a) → (a → [a]) → b → [b]
- shrinkIntegral ∷ Integral a ⇒ a → [a]
- shrinkBoundedEnum ∷ (Bounded a, Enum a, Eq a) ⇒ a → [a]
- shrinkRealFrac ∷ RealFrac a ⇒ a → [a]
- shrinkDecimal ∷ RealFrac a ⇒ a → [a]
- genericCoarbitrary ∷ (Generic a, GCoArbitrary (Rep a)) ⇒ a → Gen b → Gen b
- (><) ∷ (Gen a → Gen a) → (Gen a → Gen a) → Gen a → Gen a
- coarbitraryIntegral ∷ Integral a ⇒ a → Gen b → Gen b
- coarbitraryReal ∷ Real a ⇒ a → Gen b → Gen b
- coarbitraryShow ∷ Show a ⇒ a → Gen b → Gen b
- coarbitraryEnum ∷ Enum a ⇒ a → Gen b → Gen b
- orderedList ∷ (Ord a, Arbitrary a) ⇒ Gen [a]
- infiniteList ∷ Arbitrary a ⇒ Gen [a]
- functionBoundedEnum ∷ (Eq a, Bounded a, Enum a) ⇒ (a → b) → a :-> b
- functionRealFrac ∷ RealFrac a ⇒ (a → b) → a :-> b
- functionIntegral ∷ Integral a ⇒ (a → b) → a :-> b
- functionShow ∷ (Show a, Read a) ⇒ (a → c) → a :-> c
- functionVoid ∷ (∀ b. void → b) → void :-> c
- functionMap ∷ Function b ⇒ (a → b) → (b → a) → (a → c) → a :-> c
- applyFun ∷ Fun a b → a → b
- applyFun2 ∷ Fun (a, b) c → a → b → c
- applyFun3 ∷ Fun (a, b, c) d → a → b → c → d
- ioProperty ∷ Testable prop ⇒ IO prop → Property
- idempotentIOProperty ∷ Testable prop ⇒ IO prop → Property
- coerceWitness ∷ Typeable a ⇒ Witness → a
- castWitness ∷ Typeable a ⇒ Witness → Maybe a
- mapSize ∷ Testable prop ⇒ (Int → Int) → prop → Property
- shrinking ∷ Testable prop ⇒ (a → [a]) → a → (a → prop) → Property
- noShrinking ∷ Testable prop ⇒ prop → Property
- counterexample ∷ Testable prop ⇒ String → prop → Property
- printTestCase ∷ Testable prop ⇒ String → prop → Property
- whenFail ∷ Testable prop ⇒ IO () → prop → Property
- whenFail' ∷ Testable prop ⇒ IO () → prop → Property
- verbose ∷ Testable prop ⇒ prop → Property
- verboseShrinking ∷ Testable prop ⇒ prop → Property
- expectFailure ∷ Testable prop ⇒ prop → Property
- once ∷ Testable prop ⇒ prop → Property
- again ∷ Testable prop ⇒ prop → Property
- withMaxSuccess ∷ Testable prop ⇒ Int → prop → Property
- withDiscardRatio ∷ Testable prop ⇒ Int → prop → Property
- withMaxShrinks ∷ Testable prop ⇒ Int → prop → Property
- withMaxSize ∷ Testable prop ⇒ Int → prop → Property
- witness ∷ (Typeable a, Show a, Testable prop) ⇒ a → prop → Property
- checkCoverage ∷ Testable prop ⇒ prop → Property
- checkCoverageWith ∷ Testable prop ⇒ Confidence → prop → Property
- stdConfidence ∷ Confidence
- label ∷ Testable prop ⇒ String → prop → Property
- collect ∷ (Show a, Testable prop) ⇒ a → prop → Property
- classify ∷ Testable prop ⇒ Bool → String → prop → Property
- cover ∷ Testable prop ⇒ Double → Bool → String → prop → Property
- tabulate ∷ Testable prop ⇒ String → [String] → prop → Property
- coverTable ∷ Testable prop ⇒ String → [(String, Double)] → prop → Property
- within ∷ Testable prop ⇒ Int → prop → Property
- discardAfter ∷ Testable prop ⇒ Int → prop → Property
- forAll ∷ (Show a, Testable prop) ⇒ Gen a → (a → prop) → Property
- forAllShow ∷ Testable prop ⇒ Gen a → (a → String) → (a → prop) → Property
- forAllBlind ∷ Testable prop ⇒ Gen a → (a → prop) → Property
- forAllShrink ∷ (Show a, Testable prop) ⇒ Gen a → (a → [a]) → (a → prop) → Property
- forAllShrinkShow ∷ Testable prop ⇒ Gen a → (a → [a]) → (a → String) → (a → prop) → Property
- forAllShrinkBlind ∷ Testable prop ⇒ Gen a → (a → [a]) → (a → prop) → Property
- (.&.) ∷ (Testable prop1, Testable prop2) ⇒ prop1 → prop2 → Property
- (.&&.) ∷ (Testable prop1, Testable prop2) ⇒ prop1 → prop2 → Property
- conjoin ∷ Testable prop ⇒ [prop] → Property
- (.||.) ∷ (Testable prop1, Testable prop2) ⇒ prop1 → prop2 → Property
- disjoin ∷ Testable prop ⇒ [prop] → Property
- (===) ∷ (Eq a, Show a) ⇒ a → a → Property
- (=/=) ∷ (Eq a, Show a) ⇒ a → a → Property
- total ∷ NFData a ⇒ a → Property
- isSuccess ∷ Result → Bool
- stdArgs ∷ Args
- quickCheck ∷ Testable prop ⇒ prop → IO ()
- quickCheckWith ∷ Testable prop ⇒ Args → prop → IO ()
- quickCheckResult ∷ Testable prop ⇒ prop → IO Result
- quickCheckWithResult ∷ Testable prop ⇒ Args → prop → IO Result
- recheck ∷ Testable prop ⇒ Result → prop → IO ()
- verboseCheck ∷ Testable prop ⇒ prop → IO ()
- verboseCheckWith ∷ Testable prop ⇒ Args → prop → IO ()
- verboseCheckResult ∷ Testable prop ⇒ prop → IO Result
- verboseCheckWithResult ∷ Testable prop ⇒ Args → prop → IO Result
- polyQuickCheck ∷ Name → ExpQ
- polyVerboseCheck ∷ Name → ExpQ
- monomorphic ∷ Name → ExpQ
- forAllProperties ∷ Q Exp
- allProperties ∷ Q Exp
- quickCheckAll ∷ Q Exp
- verboseCheckAll ∷ Q Exp
- labelledExamples ∷ Testable prop ⇒ prop → IO ()
- labelledExamplesWith ∷ Testable prop ⇒ Args → prop → IO ()
- labelledExamplesResult ∷ Testable prop ⇒ prop → IO Result
- labelledExamplesWithResult ∷ Testable prop ⇒ Args → prop → IO Result
- when ∷ Applicative f ⇒ Bool → f () → f ()
- unless ∷ Applicative f ⇒ Bool → f () → f ()
- (>=>) ∷ Monad m ⇒ (a → m b) → (b → m c) → a → m c
- context ∷ HasCallStack ⇒ String → SpecWith a → SpecWith a
- focus ∷ SpecWith a → SpecWith a
- forM_ ∷ (Foldable t, Monad m) ⇒ t a → (a → m b) → m ()
- replicateM ∷ Applicative m ⇒ Int → m a → m [a]
- replicateM_ ∷ Applicative m ⇒ Int → m a → m ()
- runIO ∷ IO r → SpecM a r
- showExpr ∷ ToExpr a ⇒ a → String
- ansiExpr ∷ ToExpr a ⇒ a → Doc AnsiStyle
- ansiExprString ∷ ToExpr a ⇒ a → String
- diffExpr ∷ ToExpr a ⇒ a → a → Doc AnsiStyle
- diffExprString ∷ ToExpr a ⇒ a → a → String
- diffExprCompact ∷ ToExpr a ⇒ a → a → Doc AnsiStyle
- diffExprCompactString ∷ ToExpr a ⇒ a → a → String
- runGen ∷ Int → Int → Gen a → a
- sequential ∷ SpecWith a → SpecWith a
- modifyMaxSuccess ∷ (Int → Int) → SpecWith a → SpecWith a
- modifyMaxDiscardRatio ∷ (Int → Int) → SpecWith a → SpecWith a
- modifyMaxSize ∷ (Int → Int) → SpecWith a → SpecWith a
- modifyMaxShrinks ∷ (Int → Int) → SpecWith a → SpecWith a
- modifyArgs ∷ (Args → Args) → SpecWith a → SpecWith a
- before ∷ IO a → SpecWith a → Spec
- before_ ∷ IO () → SpecWith a → SpecWith a
- beforeWith ∷ (b → IO a) → SpecWith a → SpecWith b
- beforeAll ∷ HasCallStack ⇒ IO a → SpecWith a → Spec
- beforeAll_ ∷ HasCallStack ⇒ IO () → SpecWith a → SpecWith a
- beforeAllWith ∷ HasCallStack ⇒ (b → IO a) → SpecWith a → SpecWith b
- after ∷ ActionWith a → SpecWith a → SpecWith a
- after_ ∷ IO () → SpecWith a → SpecWith a
- around ∷ (ActionWith a → IO ()) → SpecWith a → Spec
- afterAll ∷ HasCallStack ⇒ ActionWith a → SpecWith a → SpecWith a
- afterAll_ ∷ HasCallStack ⇒ IO () → SpecWith a → SpecWith a
- around_ ∷ (IO () → IO ()) → SpecWith a → SpecWith a
- aroundWith ∷ (ActionWith a → ActionWith b) → SpecWith a → SpecWith b
- aroundAll ∷ HasCallStack ⇒ (ActionWith a → IO ()) → SpecWith a → Spec
- aroundAll_ ∷ HasCallStack ⇒ (IO () → IO ()) → SpecWith a → SpecWith a
- aroundAllWith ∷ HasCallStack ⇒ (ActionWith a → ActionWith b) → SpecWith a → SpecWith b
- mapSubject ∷ (b → a) → SpecWith a → SpecWith b
- ignoreSubject ∷ SpecWith () → SpecWith a
- xcontext ∷ HasCallStack ⇒ String → SpecWith a → SpecWith a
- specify ∷ (HasCallStack, Example a) ⇒ String → a → SpecWith (Arg a)
- xspecify ∷ (HasCallStack, Example a) ⇒ String → a → SpecWith (Arg a)
- fspecify ∷ (HasCallStack, Example a) ⇒ String → a → SpecWith (Arg a)
- fcontext ∷ HasCallStack ⇒ String → SpecWith a → SpecWith a
- pending ∷ HasCallStack ⇒ Expectation
- pendingWith ∷ HasCallStack ⇒ String → Expectation
- example ∷ Expectation → Expectation
- anyException ∷ Selector SomeException
- anyErrorCall ∷ Selector ErrorCall
- errorCall ∷ String → Selector ErrorCall
- anyIOException ∷ Selector IOException
- anyArithException ∷ Selector ArithException
- ledgerTestMain ∷ Spec → IO ()
- ledgerTestMainWith ∷ Config → Spec → IO ()
- ledgerHspecConfig ∷ Config
- tracedDiscard ∷ String → a
- io ∷ IO a → IO a
- assertBool ∷ (HasCallStack, MonadIO m) ⇒ String → Bool → m ()
- assertFailure ∷ (HasCallStack, MonadIO m) ⇒ String → m a
- assertColorFailure ∷ (HasCallStack, MonadIO m) ⇒ String → m a
- expectationFailure ∷ (HasCallStack, MonadIO m) ⇒ String → m ()
- shouldBe ∷ (HasCallStack, MonadIO m, Show a, Eq a) ⇒ a → a → m ()
- shouldSatisfy ∷ (HasCallStack, MonadIO m, Show a) ⇒ a → (a → Bool) → m ()
- shouldSatisfyExpr ∷ (HasCallStack, MonadIO m, ToExpr a) ⇒ a → (a → Bool) → m ()
- shouldStartWith ∷ (HasCallStack, MonadIO m, Show a, Eq a) ⇒ [a] → [a] → m ()
- shouldEndWith ∷ (HasCallStack, MonadIO m, Show a, Eq a) ⇒ [a] → [a] → m ()
- shouldContain ∷ (HasCallStack, MonadIO m, Show a, Eq a) ⇒ [a] → [a] → m ()
- shouldMatchList ∷ (HasCallStack, MonadIO m, Show a, Eq a) ⇒ [a] → [a] → m ()
- shouldReturn ∷ (HasCallStack, MonadIO m, Show a, Eq a) ⇒ m a → a → m ()
- shouldNotBe ∷ (HasCallStack, MonadIO m, Show a, Eq a) ⇒ a → a → m ()
- shouldNotSatisfy ∷ (HasCallStack, MonadIO m, Show a) ⇒ a → (a → Bool) → m ()
- shouldNotContain ∷ (HasCallStack, MonadIO m, Show a, Eq a) ⇒ [a] → [a] → m ()
- shouldNotReturn ∷ (HasCallStack, MonadIO m, Show a, Eq a) ⇒ m a → a → m ()
- shouldThrow ∷ (HasCallStack, Exception e, MonadUnliftIO m) ⇒ m a → Selector e → m ()
- shouldBeExpr ∷ (HasCallStack, ToExpr a, Eq a, MonadIO m) ⇒ a → a → m ()
- shouldBeRight ∷ (HasCallStack, Show a, Show b, Eq b, MonadIO m) ⇒ Either a b → b → m ()
- shouldBeLeft ∷ (HasCallStack, Show a, Eq a, Show b, MonadIO m) ⇒ Either a b → a → m ()
- shouldBeRightExpr ∷ (HasCallStack, ToExpr a, Eq b, ToExpr b, MonadIO m) ⇒ Either a b → b → m ()
- shouldBeLeftExpr ∷ (HasCallStack, ToExpr a, ToExpr b, Eq a, MonadIO m) ⇒ Either a b → a → m ()
- shouldContainExpr ∷ (HasCallStack, ToExpr a, Eq a, MonadIO m) ⇒ [a] → [a] → m ()
- expectRight ∷ (HasCallStack, Show a, MonadIO m) ⇒ Either a b → m b
- expectRightDeep_ ∷ (HasCallStack, Show a, NFData b, MonadIO m) ⇒ Either a b → m ()
- expectRightDeep ∷ (HasCallStack, Show a, NFData b, MonadIO m) ⇒ Either a b → m b
- expectRightExpr ∷ (HasCallStack, ToExpr a, MonadIO m) ⇒ Either a b → m b
- expectRightDeepExpr ∷ (HasCallStack, ToExpr a, NFData b, MonadIO m) ⇒ Either a b → m b
- expectRightDeepExpr_ ∷ (HasCallStack, ToExpr a, NFData b, MonadIO m) ⇒ Either a b → m ()
- expectLeft ∷ (HasCallStack, Show b, MonadIO m) ⇒ Either a b → m a
- expectLeftDeep_ ∷ (HasCallStack, NFData a, Show b, MonadIO m) ⇒ Either a b → m ()
- expectLeftExpr ∷ (HasCallStack, ToExpr b, MonadIO m) ⇒ Either a b → m a
- expectLeftDeep ∷ (HasCallStack, NFData a, Show b, MonadIO m) ⇒ Either a b → m a
- expectLeftDeepExpr ∷ (HasCallStack, ToExpr b, NFData a, MonadIO m) ⇒ Either a b → m a
- expectLeftDeepExpr_ ∷ (HasCallStack, ToExpr b, NFData a, MonadIO m) ⇒ Either a b → m ()
- expectJust ∷ (HasCallStack, MonadIO m) ⇒ Maybe a → m a
- expectJustDeep ∷ (HasCallStack, NFData a, MonadIO m) ⇒ Maybe a → m a
- expectJustDeep_ ∷ (HasCallStack, NFData a, MonadIO m) ⇒ Maybe a → m ()
- expectNothing ∷ (HasCallStack, Show a, MonadIO m) ⇒ Maybe a → m ()
- expectNothingExpr ∷ (HasCallStack, MonadIO m, ToExpr a) ⇒ Maybe a → m ()
- module Test.QuickCheck.GenT
- arbitrary ∷ (Arbitrary a, MonadGen m) ⇒ m a
- class StatefulGen g m ⇒ HasStatefulGen g (m ∷ Type → Type) | m → g where
- askStatefulGen ∷ m g
- class Monad m ⇒ StatefulGen g (m ∷ Type → Type)
- uniformM ∷ (HasStatefulGen g m, Uniform a) ⇒ m a
- uniformRM ∷ (HasStatefulGen g m, UniformRange a) ⇒ (a, a) → m a
- uniformListM ∷ (HasStatefulGen g m, Uniform a) ⇒ Int → m [a]
- uniformListRM ∷ (HasStatefulGen g m, UniformRange a) ⇒ (a, a) → Int → m [a]
- uniformByteStringM ∷ HasStatefulGen a m ⇒ Int → m ByteString
- uniformShortByteStringM ∷ HasStatefulGen a m ⇒ Int → m ShortByteString
- withImpInit ∷ ImpSpec t ⇒ SpecWith (ImpInit t) → Spec
- modifyImpInit ∷ (ImpInit t → ImpInit t) → SpecWith (ImpInit t) → SpecWith (ImpInit t)
Ledger
data KeyPair (kd ∷ KeyRole) Source #
Instances
mkAddr ∷ (MakeCredential p 'Payment, MakeStakeReference s) ⇒ p → s → Addr Source #
Construct a Testnet address from payment and staking components
mkCredential ∷ MakeCredential c r ⇒ c → Credential r Source #
Re-exports
Result represents the test result
Constructors
| Success | A successful test run |
Fields
| |
| GaveUp | Given up |
Fields
| |
| Failure | A failed test run |
Fields
| |
| NoExpectedFailure | A property that should have failed did not |
Fields
| |
class Testable prop where Source #
The class of properties, i.e., types which QuickCheck knows how to test.
Typically a property will be a function returning Bool or Property.
Minimal complete definition
Methods
property ∷ prop → Property Source #
Convert the thing to a property.
propertyForAllShrinkShow ∷ Gen a → (a → [a]) → (a → [String]) → (a → prop) → Property Source #
Optional; used internally in order to improve shrinking.
Tests a property but also quantifies over an extra value
(with a custom shrink and show function).
The Testable instance for functions defines
propertyForAllShrinkShow in a way that improves shrinking.
type Selector a = a → Bool Source #
A Selector is a predicate; it can simultaneously constrain the type and
value of an exception.
Generation of random shrinkable, showable functions.
To generate random values of type ,
you must have an instance Fun a b.Function a
A generator for values of type a.
The third-party packages
QuickCheck-GenT
and
quickcheck-transformer
provide monad transformer versions of Gen.
Instances
class CoArbitrary a where Source #
Used for random generation of functions.
You should consider using Fun instead, which
can show the generated functions as strings.
If you are using a recent GHC, there is a default definition of
coarbitrary using genericCoarbitrary, so if your type has a
Generic instance it's enough to say
instance CoArbitrary MyType
You should only use genericCoarbitrary for data types where
equality is structural, i.e. if you can't have two different
representations of the same value. An example where it's not
safe is sets implemented using binary search trees: the same
set can be represented as several different trees.
Here you would have to explicitly define
coarbitrary s = coarbitrary (toList s).
Minimal complete definition
Nothing
Methods
coarbitrary ∷ a → Gen b → Gen b Source #
Used to generate a function of type a -> b.
The first argument is a value, the second a generator.
You should use variant to perturb the random generator;
the goal is that different values for the first argument will
lead to different calls to variant. An example will help:
instance CoArbitrary a => CoArbitrary [a] where coarbitrary [] =variant0 coarbitrary (x:xs) =variant1 . coarbitrary (x,xs)
Instances
class Arbitrary2 (f ∷ Type → Type → Type) where Source #
Lifting of the Arbitrary class to binary type constructors.
Minimal complete definition
Methods
liftArbitrary2 ∷ Gen a → Gen b → Gen (f a b) Source #
liftShrink2 ∷ (a → [a]) → (b → [b]) → f a b → [f a b] Source #
Instances
| Arbitrary2 Either | |
Defined in Test.QuickCheck.Arbitrary | |
| Arbitrary2 (,) | |
Defined in Test.QuickCheck.Arbitrary Methods liftArbitrary2 ∷ Gen a → Gen b → Gen (a, b) Source # liftShrink2 ∷ (a → [a]) → (b → [b]) → (a, b) → [(a, b)] Source # | |
| Arbitrary2 (Const ∷ Type → Type → Type) | |
Defined in Test.QuickCheck.Arbitrary | |
| Arbitrary2 (Constant ∷ Type → Type → Type) | |
Defined in Test.QuickCheck.Arbitrary | |
class Arbitrary1 (f ∷ Type → Type) where Source #
Lifting of the Arbitrary class to unary type constructors.
Minimal complete definition
Instances
class Arbitrary a where Source #
Random generation and shrinking of values.
QuickCheck provides Arbitrary instances for most types in base,
except those which incur extra dependencies.
For a wider range of Arbitrary instances see the
quickcheck-instances
package.
Minimal complete definition
Methods
Produces a (possibly) empty list of all the possible immediate shrinks of the given value.
The default implementation returns the empty list, so will not try to
shrink the value. If your data type has no special invariants, you can
enable shrinking by defining shrink = , but by customising
the behaviour of genericShrinkshrink you can often get simpler counterexamples.
Most implementations of shrink should try at least three things:
- Shrink a term to any of its immediate subterms.
You can use
subtermsto do this. - Recursively apply
shrinkto all immediate subterms. You can userecursivelyShrinkto do this. - Type-specific shrinkings such as replacing a constructor by a simpler constructor.
For example, suppose we have the following implementation of binary trees:
data Tree a = Nil | Branch a (Tree a) (Tree a)
We can then define shrink as follows:
shrink Nil = [] shrink (Branch x l r) = -- shrink Branch to Nil [Nil] ++ -- shrink to subterms [l, r] ++ -- recursively shrink subterms [Branch x' l' r' | (x', l', r') <- shrink (x, l, r)]
There are a couple of subtleties here:
- QuickCheck tries the shrinking candidates in the order they
appear in the list, so we put more aggressive shrinking steps
(such as replacing the whole tree by
Nil) before smaller ones (such as recursively shrinking the subtrees). - It is tempting to write the last line as
[Branch x' l' r' | x' <- shrink x, l' <- shrink l, r' <- shrink r]but this is the wrong thing! It will force QuickCheck to shrinkx,landrin tandem, and shrinking will stop once one of the three is fully shrunk.
There is a fair bit of boilerplate in the code above.
We can avoid it with the help of some generic functions.
The function genericShrink tries shrinking a term to all of its
subterms and, failing that, recursively shrinks the subterms.
Using it, we can define shrink as:
shrink x = shrinkToNil x ++ genericShrink x
where
shrinkToNil Nil = []
shrinkToNil (Branch _ l r) = [Nil]genericShrink is a combination of subterms, which shrinks
a term to any of its subterms, and recursivelyShrink, which shrinks
all subterms of a term. These may be useful if you need a bit more
control over shrinking than genericShrink gives you.
A final gotcha: we cannot define shrink as simply
as this shrinks shrink x = Nil:genericShrink xNil to Nil, and shrinking will go into an
infinite loop.
If all this leaves you bewildered, you might try to begin with,
after deriving shrink = genericShrinkGeneric for your type. However, if your data type has any
special invariants, you will need to check that genericShrink can't break those invariants.
Instances
newtype PrintableString Source #
PrintableString: generates a printable unicode String.
The string will not contain surrogate pairs.
Constructors
| PrintableString | |
Fields | |
Instances
| Arbitrary PrintableString | |
Defined in Test.QuickCheck.Modifiers Methods | |
| Read PrintableString | |
Defined in Test.QuickCheck.Modifiers Methods readsPrec ∷ Int → ReadS PrintableString # readList ∷ ReadS [PrintableString] # | |
| Show PrintableString | |
Defined in Test.QuickCheck.Modifiers Methods showsPrec ∷ Int → PrintableString → ShowS # show ∷ PrintableString → String # showList ∷ [PrintableString] → ShowS # | |
| Eq PrintableString | |
Defined in Test.QuickCheck.Modifiers Methods (==) ∷ PrintableString → PrintableString → Bool # (/=) ∷ PrintableString → PrintableString → Bool # | |
| Ord PrintableString | |
Defined in Test.QuickCheck.Modifiers Methods compare ∷ PrintableString → PrintableString → Ordering # (<) ∷ PrintableString → PrintableString → Bool # (<=) ∷ PrintableString → PrintableString → Bool # (>) ∷ PrintableString → PrintableString → Bool # (>=) ∷ PrintableString → PrintableString → Bool # | |
newtype UnicodeString Source #
UnicodeString: generates a unicode String.
The string will not contain surrogate pairs.
Constructors
| UnicodeString | |
Fields | |
Instances
| Arbitrary UnicodeString | |
Defined in Test.QuickCheck.Modifiers | |
| Read UnicodeString | |
Defined in Test.QuickCheck.Modifiers Methods readsPrec ∷ Int → ReadS UnicodeString # readList ∷ ReadS [UnicodeString] # | |
| Show UnicodeString | |
Defined in Test.QuickCheck.Modifiers Methods showsPrec ∷ Int → UnicodeString → ShowS # show ∷ UnicodeString → String # showList ∷ [UnicodeString] → ShowS # | |
| Eq UnicodeString | |
Defined in Test.QuickCheck.Modifiers | |
| Ord UnicodeString | |
Defined in Test.QuickCheck.Modifiers Methods compare ∷ UnicodeString → UnicodeString → Ordering # (<) ∷ UnicodeString → UnicodeString → Bool # (<=) ∷ UnicodeString → UnicodeString → Bool # (>) ∷ UnicodeString → UnicodeString → Bool # (>=) ∷ UnicodeString → UnicodeString → Bool # | |
newtype ASCIIString Source #
ASCIIString: generates an ASCII string.
Constructors
| ASCIIString | |
Fields | |
Instances
| Arbitrary ASCIIString | |
Defined in Test.QuickCheck.Modifiers | |
| Read ASCIIString | |
Defined in Test.QuickCheck.Modifiers Methods readsPrec ∷ Int → ReadS ASCIIString # readList ∷ ReadS [ASCIIString] # | |
| Show ASCIIString | |
Defined in Test.QuickCheck.Modifiers Methods showsPrec ∷ Int → ASCIIString → ShowS # show ∷ ASCIIString → String # showList ∷ [ASCIIString] → ShowS # | |
| Eq ASCIIString | |
Defined in Test.QuickCheck.Modifiers | |
| Ord ASCIIString | |
Defined in Test.QuickCheck.Modifiers Methods compare ∷ ASCIIString → ASCIIString → Ordering # (<) ∷ ASCIIString → ASCIIString → Bool # (<=) ∷ ASCIIString → ASCIIString → Bool # (>) ∷ ASCIIString → ASCIIString → Bool # (>=) ∷ ASCIIString → ASCIIString → Bool # max ∷ ASCIIString → ASCIIString → ASCIIString # min ∷ ASCIIString → ASCIIString → ASCIIString # | |
class ShrinkState s a where Source #
Shrinking _ x: allows for maintaining a state during shrinking.
Constructors
| Shrinking s a |
Smart _ x: tries a different order when shrinking.
Shrink2 x: allows 2 shrinking steps at the same time when shrinking x
Constructors
| Shrink2 | |
Fields
| |
Instances
| Functor Shrink2 | |
| Arbitrary a ⇒ Arbitrary (Shrink2 a) | |
| Enum a ⇒ Enum (Shrink2 a) | |
Defined in Test.QuickCheck.Modifiers | |
| Num a ⇒ Num (Shrink2 a) | |
| Read a ⇒ Read (Shrink2 a) | |
| Integral a ⇒ Integral (Shrink2 a) | |
Defined in Test.QuickCheck.Modifiers | |
| Real a ⇒ Real (Shrink2 a) | |
Defined in Test.QuickCheck.Modifiers Methods toRational ∷ Shrink2 a → Rational # | |
| Show a ⇒ Show (Shrink2 a) | |
| Eq a ⇒ Eq (Shrink2 a) | |
| Ord a ⇒ Ord (Shrink2 a) | |
Defined in Test.QuickCheck.Modifiers | |
Small x: generates values of x drawn from a small range.
The opposite of Large.
Instances
| Functor Small | |
| Integral a ⇒ Arbitrary (Small a) | |
| Enum a ⇒ Enum (Small a) | |
Defined in Test.QuickCheck.Modifiers | |
| Ix a ⇒ Ix (Small a) | |
Defined in Test.QuickCheck.Modifiers | |
| Num a ⇒ Num (Small a) | |
| Read a ⇒ Read (Small a) | |
| Integral a ⇒ Integral (Small a) | |
Defined in Test.QuickCheck.Modifiers | |
| Real a ⇒ Real (Small a) | |
Defined in Test.QuickCheck.Modifiers Methods toRational ∷ Small a → Rational # | |
| Show a ⇒ Show (Small a) | |
| Eq a ⇒ Eq (Small a) | |
| Ord a ⇒ Ord (Small a) | |
Large x: by default, QuickCheck generates Ints drawn from a small
range. Large Int gives you values drawn from the entire range instead.
Instances
| Functor Large | |
| (Integral a, Bounded a) ⇒ Arbitrary (Large a) | |
| Enum a ⇒ Enum (Large a) | |
Defined in Test.QuickCheck.Modifiers | |
| Ix a ⇒ Ix (Large a) | |
Defined in Test.QuickCheck.Modifiers | |
| Num a ⇒ Num (Large a) | |
| Read a ⇒ Read (Large a) | |
| Integral a ⇒ Integral (Large a) | |
Defined in Test.QuickCheck.Modifiers | |
| Real a ⇒ Real (Large a) | |
Defined in Test.QuickCheck.Modifiers Methods toRational ∷ Large a → Rational # | |
| Show a ⇒ Show (Large a) | |
| Eq a ⇒ Eq (Large a) | |
| Ord a ⇒ Ord (Large a) | |
newtype NonPositive a Source #
NonPositive x: guarantees that x <= 0.
Constructors
| NonPositive | |
Fields
| |
Instances
newtype NonNegative a Source #
NonNegative x: guarantees that x >= 0.
Constructors
| NonNegative | |
Fields
| |
Instances
NonZero x: guarantees that x /= 0.
Constructors
| NonZero | |
Fields
| |
Instances
| Functor NonZero | |
| (Num a, Eq a, Arbitrary a) ⇒ Arbitrary (NonZero a) | |
| Enum a ⇒ Enum (NonZero a) | |
Defined in Test.QuickCheck.Modifiers | |
| Read a ⇒ Read (NonZero a) | |
| Show a ⇒ Show (NonZero a) | |
| Eq a ⇒ Eq (NonZero a) | |
| Ord a ⇒ Ord (NonZero a) | |
Defined in Test.QuickCheck.Modifiers | |
Negative x: guarantees that x < 0.
Constructors
| Negative | |
Fields
| |
Instances
| Functor Negative | |
| (Num a, Ord a, Arbitrary a) ⇒ Arbitrary (Negative a) | |
| Enum a ⇒ Enum (Negative a) | |
Defined in Test.QuickCheck.Modifiers | |
| Read a ⇒ Read (Negative a) | |
| Show a ⇒ Show (Negative a) | |
| Eq a ⇒ Eq (Negative a) | |
| Ord a ⇒ Ord (Negative a) | |
Defined in Test.QuickCheck.Modifiers | |
Positive x: guarantees that x > 0.
Constructors
| Positive | |
Fields
| |
Instances
| Functor Positive | |
| (Num a, Ord a, Arbitrary a) ⇒ Arbitrary (Positive a) | |
| Enum a ⇒ Enum (Positive a) | |
Defined in Test.QuickCheck.Modifiers | |
| Read a ⇒ Read (Positive a) | |
| Show a ⇒ Show (Positive a) | |
| Eq a ⇒ Eq (Positive a) | |
| Ord a ⇒ Ord (Positive a) | |
Defined in Test.QuickCheck.Modifiers | |
newtype SortedList a Source #
Sorted xs: guarantees that xs is sorted.
Instances
| Functor SortedList | |
Defined in Test.QuickCheck.Modifiers | |
| (Arbitrary a, Ord a) ⇒ Arbitrary (SortedList a) | |
Defined in Test.QuickCheck.Modifiers | |
| Read a ⇒ Read (SortedList a) | |
Defined in Test.QuickCheck.Modifiers Methods readsPrec ∷ Int → ReadS (SortedList a) # readList ∷ ReadS [SortedList a] # readPrec ∷ ReadPrec (SortedList a) # readListPrec ∷ ReadPrec [SortedList a] # | |
| Show a ⇒ Show (SortedList a) | |
Defined in Test.QuickCheck.Modifiers Methods showsPrec ∷ Int → SortedList a → ShowS # show ∷ SortedList a → String # showList ∷ [SortedList a] → ShowS # | |
| Eq a ⇒ Eq (SortedList a) | |
Defined in Test.QuickCheck.Modifiers | |
| Ord a ⇒ Ord (SortedList a) | |
Defined in Test.QuickCheck.Modifiers Methods compare ∷ SortedList a → SortedList a → Ordering # (<) ∷ SortedList a → SortedList a → Bool # (<=) ∷ SortedList a → SortedList a → Bool # (>) ∷ SortedList a → SortedList a → Bool # (>=) ∷ SortedList a → SortedList a → Bool # max ∷ SortedList a → SortedList a → SortedList a # min ∷ SortedList a → SortedList a → SortedList a # | |
data InfiniteList a Source #
InfiniteList xs _: guarantees that xs is an infinite list.
When a counterexample is found, only prints the prefix of xs
that was used by the program.
Here is a contrived example property:
prop_take_10 :: InfiniteList Char -> Bool prop_take_10 (InfiniteList xs _) = or [ x == 'a' | x <- take 10 xs ]
In the following counterexample, the list must start with "bbbbbbbbbb" but
the remaining (infinite) part can contain anything:
>>>quickCheck prop_take_10*** Failed! Falsified (after 1 test and 14 shrinks): "bbbbbbbbbb" ++ ...
Constructors
| InfiniteList | |
Fields
| |
Instances
| Arbitrary a ⇒ Arbitrary (InfiniteList a) | |
Defined in Test.QuickCheck.Modifiers | |
| Show a ⇒ Show (InfiniteList a) | |
Defined in Test.QuickCheck.Modifiers Methods showsPrec ∷ Int → InfiniteList a → ShowS # show ∷ InfiniteList a → String # showList ∷ [InfiniteList a] → ShowS # | |
newtype NonEmptyList a Source #
NonEmpty xs: guarantees that xs is non-empty.
Constructors
| NonEmpty | |
Fields
| |
Instances
newtype OrderedList a Source #
Ordered xs: guarantees that xs is ordered.
Constructors
| Ordered | |
Fields
| |
Instances
Fixed x: as x, but will not be shrunk.
Instances
| Functor Fixed | |
| Arbitrary a ⇒ Arbitrary (Fixed a) | |
| Enum a ⇒ Enum (Fixed a) | |
Defined in Test.QuickCheck.Modifiers | |
| Num a ⇒ Num (Fixed a) | |
| Read a ⇒ Read (Fixed a) | |
| Integral a ⇒ Integral (Fixed a) | |
Defined in Test.QuickCheck.Modifiers | |
| Real a ⇒ Real (Fixed a) | |
Defined in Test.QuickCheck.Modifiers Methods toRational ∷ Fixed a → Rational # | |
| Show a ⇒ Show (Fixed a) | |
| Eq a ⇒ Eq (Fixed a) | |
| Ord a ⇒ Ord (Fixed a) | |
Blind x: as x, but x does not have to be in the Show class.
Instances
| Functor Blind | |
| Arbitrary a ⇒ Arbitrary (Blind a) | |
| Enum a ⇒ Enum (Blind a) | |
Defined in Test.QuickCheck.Modifiers | |
| Num a ⇒ Num (Blind a) | |
| Integral a ⇒ Integral (Blind a) | |
Defined in Test.QuickCheck.Modifiers | |
| Real a ⇒ Real (Blind a) | |
Defined in Test.QuickCheck.Modifiers Methods toRational ∷ Blind a → Rational # | |
| Show (Blind a) | |
| Eq a ⇒ Eq (Blind a) | |
| Ord a ⇒ Ord (Blind a) | |
class Function a where Source #
The class Function a is used for random generation of showable
functions of type a -> b.
There is a default implementation for function, which you can use
if your type has structural equality. Otherwise, you can normally
use functionMap or functionShow.
Minimal complete definition
Nothing
Instances
data Confidence Source #
The statistical parameters used by checkCoverage.
Constructors
| Confidence | |
Fields
| |
Instances
| Show Confidence | |
Defined in Test.QuickCheck.State Methods showsPrec ∷ Int → Confidence → ShowS # show ∷ Confidence → String # showList ∷ [Confidence] → ShowS # | |
If a property returns Discard, the current test case is discarded,
the same as if a precondition was false.
An example is the definition of ==>:
(==>) :: Testable prop => Bool -> prop -> Property False ==> _ = property Discard True ==> p = property p
Constructors
| Discard |
The type of properties.
Instances
| Testable Property | |
| type Arg Property | |
Defined in Test.Hspec.Core.QuickCheck | |
| type Arg (a → Property) | |
Defined in Test.Hspec.Core.QuickCheck | |
Args specifies arguments to the QuickCheck driver
Constructors
| Args | |
Fields
| |
Instances
type HasCallStack = ?callStack ∷ CallStack #
Request a CallStack.
NOTE: The implicit parameter ?callStack :: CallStack is an
implementation detail and should not be considered part of the
CallStack API, we may decide to change the implementation in the
future.
Since: base-4.9.0.0
A type class for examples
Minimal complete definition
Instances
Instances
| type Arg Property | |
Defined in Test.Hspec.Core.QuickCheck | |
| type Arg Result | |
Defined in Test.Hspec.Core.Example | |
| type Arg Expectation | |
Defined in Test.Hspec.Core.Example | |
| type Arg Bool | |
Defined in Test.Hspec.Core.Example | |
| type Arg (ImpM t p) | |
Defined in Test.ImpSpec.Internal | |
| type Arg (a → ImpM t p) | |
Defined in Test.ImpSpec.Internal | |
| type Arg (a → Property) | |
Defined in Test.Hspec.Core.QuickCheck | |
| type Arg (a → Result) | |
Defined in Test.Hspec.Core.Example | |
| type Arg (a → Expectation) | |
Defined in Test.Hspec.Core.Example | |
| type Arg (a → Bool) | |
Defined in Test.Hspec.Core.Example | |
toExpr converts a Haskell value into
untyped Haskell-like syntax tree, Expr.
>>>toExpr ((1, Just 2) :: (Int, Maybe Int))App "_\215_" [App "1" [],App "Just" [App "2" []]]
Minimal complete definition
Nothing
Instances
A class of types that can be fully evaluated.
Since: deepseq-1.1.0.0
Instances
type ActionWith a = a → IO () Source #
An IO action that expects an argument of type a
type Expectation = Assertion Source #
pattern Fn2 ∷ (a → b → c) → Fun (a, b) c Source #
A modifier for testing binary functions.
prop_zipWith :: Fun (Int, Bool) Char -> [Int] -> [Bool] -> Bool prop_zipWith (Fn2 f) xs ys = zipWith f xs ys == [ f x y | (x, y) <- zip xs ys]
pattern Fn ∷ (a → b) → Fun a b Source #
A modifier for testing functions.
prop :: Fun String Integer -> Bool
prop (Fn f) = f "banana" == f "monkey"
|| f "banana" == f "elephant"Run a given spec and write a report to stdout.
Exit with exitFailure if at least one spec item fails.
Note: hspec handles command-line options and reads config files. This
is not always desirable. Use evalSpec and runSpecForest if you need
more control over these aspects.
parallel ∷ SpecWith a → SpecWith a Source #
parallel marks all spec items of the given spec to be safe for parallel
evaluation.
void ∷ Functor f ⇒ f a → f () #
discards or ignores the result of evaluation, such
as the return value of an void valueIO action.
Examples
Replace the contents of a with unit:Maybe Int
>>>void NothingNothing>>>void (Just 3)Just ()
Replace the contents of an
with unit, resulting in an Either Int Int:Either Int ()
>>>void (Left 8675309)Left 8675309>>>void (Right 8675309)Right ()
Replace every element of a list with unit:
>>>void [1,2,3][(),(),()]
Replace the second element of a pair with unit:
>>>void (1,2)(1,())
Discard the result of an IO action:
>>>mapM print [1,2]1 2 [(),()]>>>void $ mapM print [1,2]1 2
(==>) ∷ Testable prop ⇒ Bool → prop → Property infixr 0 Source #
Implication for properties: The resulting property holds if
the first argument is False (in which case the test case is discarded),
or if the given property holds. Note that using implication carelessly can
severely skew test case distribution: consider using cover to make sure
that your test data is still good quality.
describe ∷ HasCallStack ⇒ String → SpecWith a → SpecWith a Source #
The describe function combines a list of specs into a larger spec.
it ∷ (HasCallStack, Example a) ⇒ String → a → SpecWith (Arg a) Source #
The it function creates a spec item.
A spec item consists of:
- a textual description of a desired behavior
- an example for that behavior
describe "absolute" $ do
it "returns a positive number when given a negative number" $
absolute (-1) == 1fit ∷ (HasCallStack, Example a) ⇒ String → a → SpecWith (Arg a) Source #
fit is an alias for fmap focus . it
fdescribe ∷ HasCallStack ⇒ String → SpecWith a → SpecWith a Source #
fdescribe is an alias for fmap focus . describe
Returns the size parameter. Used to construct generators that depend on the size parameter.
For example, listOf, which uses the size parameter as an upper bound on
length of lists it generates, can be defined like this:
listOf :: Gen a -> Gen [a] listOf gen = do n <- getSize k <- choose (0,n) vectorOf k gen
You can also do this using sized.
scale ∷ (Int → Int) → Gen a → Gen a Source #
Adjust the size parameter, by transforming it with the given function.
chooseBoundedIntegral ∷ (Bounded a, Integral a) ⇒ (a, a) → Gen a Source #
A fast implementation of choose for bounded integral types.
generate ∷ Gen a → IO a Source #
Run a generator. The size passed to the generator is always 30;
if you want another size then you should explicitly use resize.
suchThatMap ∷ Gen a → (a → Maybe b) → Gen b Source #
Generates a value for which the given function returns a Just, and then
applies the function.
infiniteListOf ∷ Gen a → Gen [a] Source #
Generates an infinite list.
arbitrary1 ∷ (Arbitrary1 f, Arbitrary a) ⇒ Gen (f a) Source #
shrink1 ∷ (Arbitrary1 f, Arbitrary a) ⇒ f a → [f a] Source #
arbitrary2 ∷ (Arbitrary2 f, Arbitrary a, Arbitrary b) ⇒ Gen (f a b) Source #
genericShrink ∷ (Generic a, RecursivelyShrink (Rep a), GSubterms (Rep a) a) ⇒ a → [a] Source #
Shrink a term to any of its immediate subterms, and also recursively shrink all subterms.
recursivelyShrink ∷ (Generic a, RecursivelyShrink (Rep a)) ⇒ a → [a] Source #
Recursively shrink all immediate subterms.
shrinkList ∷ (a → [a]) → [a] → [[a]] Source #
Shrink a list of values given a shrinking function for individual values.
applyArbitrary2 ∷ (Arbitrary a, Arbitrary b) ⇒ (a → b → r) → Gen r Source #
Apply a binary function to random arguments.
applyArbitrary3 ∷ (Arbitrary a, Arbitrary b, Arbitrary c) ⇒ (a → b → c → r) → Gen r Source #
Apply a ternary function to random arguments.
applyArbitrary4 ∷ (Arbitrary a, Arbitrary b, Arbitrary c, Arbitrary d) ⇒ (a → b → c → d → r) → Gen r Source #
Apply a function of arity 4 to random arguments.
arbitrarySizedIntegral ∷ Integral a ⇒ Gen a Source #
Generates an integral number. The number can be positive or negative and its maximum absolute value depends on the size parameter.
arbitrarySizedNatural ∷ Integral a ⇒ Gen a Source #
Generates a natural number. The number's maximum value depends on the size parameter.
arbitrarySizedFractional ∷ Fractional a ⇒ Gen a Source #
Uniformly generates a fractional number. The number can be positive or negative and its maximum absolute value depends on the size parameter.
arbitraryBoundedIntegral ∷ (Bounded a, Integral a) ⇒ Gen a Source #
Generates an integral number. The number is chosen uniformly from
the entire range of the type. You may want to use
arbitrarySizedBoundedIntegral instead.
arbitraryBoundedRandom ∷ (Bounded a, Random a) ⇒ Gen a Source #
Generates an element of a bounded type. The element is chosen from the entire range of the type.
arbitraryBoundedEnum ∷ (Bounded a, Enum a) ⇒ Gen a Source #
Generates an element of a bounded enumeration.
arbitrarySizedBoundedIntegral ∷ (Bounded a, Integral a) ⇒ Gen a Source #
Generates an integral number from a bounded domain. The number is chosen from the entire range of the type, but small numbers are generated more often than big numbers. Inspired by demands from Phil Wadler.
arbitraryUnicodeChar ∷ Gen Char Source #
Generates any Unicode character (but not a surrogate)
arbitraryASCIIChar ∷ Gen Char Source #
Generates a random ASCII character (0-127).
arbitraryPrintableChar ∷ Gen Char Source #
Generates a printable Unicode character.
shrinkNothing ∷ a → [a] Source #
Returns no shrinking alternatives.
shrinkMap ∷ Arbitrary a ⇒ (a → b) → (b → a) → b → [b] Source #
Map a shrink function to another domain. This is handy if your data type has special invariants, but is almost isomorphic to some other type.
shrinkOrderedList :: (Ord a, Arbitrary a) => [a] -> [[a]] shrinkOrderedList = shrinkMap sort id shrinkSet :: (Ord a, Arbitrary a) => Set a -> [Set a] shrinkSet = shrinkMap fromList toList
shrinkMapBy ∷ (a → b) → (b → a) → (a → [a]) → b → [b] Source #
Non-overloaded version of shrinkMap.
shrinkIntegral ∷ Integral a ⇒ a → [a] Source #
Shrink an integral number.
shrinkBoundedEnum ∷ (Bounded a, Enum a, Eq a) ⇒ a → [a] Source #
Shrink an element of a bounded enumeration.
Example
data MyEnum = E0 | E1 | E2 | E3 | E4 | E5 | E6 | E7 | E8 | E9 deriving (Bounded, Enum, Eq, Ord, Show)
>>>shrinkBoundedEnum E9[E0,E5,E7,E8]
>>>shrinkBoundedEnum E5[E0,E3,E4]
>>>shrinkBoundedEnum E0[]
shrinkRealFrac ∷ RealFrac a ⇒ a → [a] Source #
Shrink a fraction, preferring numbers with smaller
numerators or denominators. See also shrinkDecimal.
shrinkDecimal ∷ RealFrac a ⇒ a → [a] Source #
Shrink a real number, preferring numbers with shorter
decimal representations. See also shrinkRealFrac.
genericCoarbitrary ∷ (Generic a, GCoArbitrary (Rep a)) ⇒ a → Gen b → Gen b Source #
Generic CoArbitrary implementation.
(><) ∷ (Gen a → Gen a) → (Gen a → Gen a) → Gen a → Gen a Source #
Combine two generator perturbing functions, for example the
results of calls to variant or coarbitrary.
coarbitraryIntegral ∷ Integral a ⇒ a → Gen b → Gen b Source #
A coarbitrary implementation for integral numbers.
coarbitraryReal ∷ Real a ⇒ a → Gen b → Gen b Source #
A coarbitrary implementation for real numbers.
coarbitraryShow ∷ Show a ⇒ a → Gen b → Gen b Source #
coarbitrary helper for lazy people :-).
coarbitraryEnum ∷ Enum a ⇒ a → Gen b → Gen b Source #
A coarbitrary implementation for enums.
infiniteList ∷ Arbitrary a ⇒ Gen [a] Source #
Generates an infinite list.
functionRealFrac ∷ RealFrac a ⇒ (a → b) → a :-> b Source #
functionIntegral ∷ Integral a ⇒ (a → b) → a :-> b Source #
functionVoid ∷ (∀ b. void → b) → void :-> c Source #
functionMap ∷ Function b ⇒ (a → b) → (b → a) → (a → c) → a :-> c Source #
applyFun ∷ Fun a b → a → b Source #
Extracts the value of a function.
Fn is the pattern equivalent of this function.
prop :: Fun String Integer -> Bool
prop f = applyFun f "banana" == applyFun f "monkey"
|| applyFun f "banana" == applyFun f "elephant"applyFun2 ∷ Fun (a, b) c → a → b → c Source #
Extracts the value of a binary function.
Fn2 is the pattern equivalent of this function.
prop_zipWith :: Fun (Int, Bool) Char -> [Int] -> [Bool] -> Bool prop_zipWith f xs ys = zipWith (applyFun2 f) xs ys == [ applyFun2 f x y | (x, y) <- zip xs ys]
applyFun3 ∷ Fun (a, b, c) d → a → b → c → d Source #
Extracts the value of a ternary function. Fn3 is the
pattern equivalent of this function.
ioProperty ∷ Testable prop ⇒ IO prop → Property Source #
Do I/O inside a property.
Warning: any random values generated inside of the argument to ioProperty
will not currently be shrunk. For best results, generate all random values
before calling ioProperty, or use idempotentIOProperty if that is safe.
idempotentIOProperty ∷ Testable prop ⇒ IO prop → Property Source #
Do I/O inside a property.
Warning: during shrinking, the I/O may not always be re-executed.
Instead, the I/O may be executed once and then its result retained.
If this is not acceptable, use ioProperty instead.
coerceWitness ∷ Typeable a ⇒ Witness → a Source #
mapSize ∷ Testable prop ⇒ (Int → Int) → prop → Property Source #
Adjust the test case size for a property, by transforming it with the given function.
Arguments
| ∷ Testable prop | |
| ⇒ (a → [a]) |
|
| → a | The original argument |
| → (a → prop) | |
| → Property |
Shrinks the argument to a property if it fails. Shrinking is done automatically for most types. This function is only needed when you want to override the default behavior.
noShrinking ∷ Testable prop ⇒ prop → Property Source #
Disables shrinking for a property altogether.
Only quantification inside the call to noShrinking is affected.
counterexample ∷ Testable prop ⇒ String → prop → Property Source #
Adds the given string to the counterexample if the property fails.
printTestCase ∷ Testable prop ⇒ String → prop → Property Source #
Adds the given string to the counterexample if the property fails.
whenFail ∷ Testable prop ⇒ IO () → prop → Property Source #
Performs an IO action after the last failure of a property.
whenFail' ∷ Testable prop ⇒ IO () → prop → Property Source #
Performs an IO action every time a property fails. Thus,
if shrinking is done, this can be used to keep track of the
failures along the way.
verbose ∷ Testable prop ⇒ prop → Property Source #
Prints out the generated test case every time the property is tested.
Only variables quantified over inside the verbose are printed.
Note: for technical reasons, the test case is printed out after
the property is tested. To debug a property that goes into an
infinite loop, use within to add a timeout instead.
verboseShrinking ∷ Testable prop ⇒ prop → Property Source #
Prints out the generated test case every time the property fails, including during shrinking.
Only variables quantified over inside the verboseShrinking are printed.
Note: for technical reasons, the test case is printed out after
the property is tested. To debug a property that goes into an
infinite loop, use within to add a timeout instead.
expectFailure ∷ Testable prop ⇒ prop → Property Source #
Indicates that a property is supposed to fail. QuickCheck will report an error if it does not fail.
once ∷ Testable prop ⇒ prop → Property Source #
Modifies a property so that it only will be tested once.
Opposite of again.
again ∷ Testable prop ⇒ prop → Property Source #
Modifies a property so that it will be tested repeatedly.
Opposite of once.
withMaxSuccess ∷ Testable prop ⇒ Int → prop → Property Source #
Configures how many times a property will be tested.
For example,
quickCheck (withMaxSuccess 1000 p)
will test p up to 1000 times.
withDiscardRatio ∷ Testable prop ⇒ Int → prop → Property Source #
Configures how many times a property is allowed to be discarded before failing.
For example,
quickCheck (withDiscardRatio 10 p)
will allow p to fail up to 10 times per successful test.
withMaxShrinks ∷ Testable prop ⇒ Int → prop → Property Source #
Configure the maximum number of times a property will be shrunk.
For example,
quickCheck (withMaxShrinks 100 p)
will cause p to only attempt 100 shrinks on failure.
withMaxSize ∷ Testable prop ⇒ Int → prop → Property Source #
Configure the maximum size a property will be tested at.
witness ∷ (Typeable a, Show a, Testable prop) ⇒ a → prop → Property Source #
Return a value in the witnesses field of the Result returned by quickCheckResult. Witnesses
are returned outer-most first.
In ghci, for example:
>>>[Wit x] <- fmap witnesses . quickCheckResult $ \ x -> witness x $ x == (0 :: Int)*** Failed! Falsified (after 2 tests): 1>>>x1>>>:t xx :: Int
checkCoverage ∷ Testable prop ⇒ prop → Property Source #
Check that all coverage requirements defined by cover and coverTable
are met, using a statistically sound test, and fail if they are not met.
Ordinarily, a failed coverage check does not cause the property to fail.
This is because the coverage requirement is not tested in a statistically
sound way. If you use cover to express that a certain value must appear 20%
of the time, QuickCheck will warn you if the value only appears in 19 out of
100 test cases - but since the coverage varies randomly, you may have just
been unlucky, and there may not be any real problem with your test
generation.
When you use checkCoverage, QuickCheck uses a statistical test to account
for the role of luck in coverage failures. It will run as many tests as
needed until it is sure about whether the coverage requirements are met. If a
coverage requirement is not met, the property fails.
Example:
quickCheck (checkCoverage prop_foo)
checkCoverageWith ∷ Testable prop ⇒ Confidence → prop → Property Source #
Check coverage requirements using a custom confidence level.
See stdConfidence.
An example of making the statistical test less stringent in order to improve performance:
quickCheck (checkCoverageWith stdConfidence{certainty = 10^6} prop_foo)stdConfidence ∷ Confidence Source #
The standard parameters used by checkCoverage: certainty = 10^9,
tolerance = 0.9. See Confidence for the meaning of the parameters.
label ∷ Testable prop ⇒ String → prop → Property Source #
Attaches a label to a test case. This is used for reporting test case distribution.
For example:
prop_reverse_reverse :: [Int] -> Property
prop_reverse_reverse xs =
label ("length of input is " ++ show (length xs)) $
reverse (reverse xs) === xs>>>quickCheck prop_reverse_reverse+++ OK, passed 100 tests: 7% length of input is 7 6% length of input is 3 5% length of input is 4 4% length of input is 6 ...
Each use of label in your property results in a separate
table of test case distribution in the output. If this is
not what you want, use tabulate.
collect ∷ (Show a, Testable prop) ⇒ a → prop → Property Source #
Attaches a label to a test case. This is used for reporting test case distribution.
collect x = label (show x)
For example:
prop_reverse_reverse :: [Int] -> Property
prop_reverse_reverse xs =
collect (length xs) $
reverse (reverse xs) === xs>>>quickCheck prop_reverse_reverse+++ OK, passed 100 tests: 7% 7 6% 3 5% 4 4% 6 ...
Each use of collect in your property results in a separate
table of test case distribution in the output. If this is
not what you want, use tabulate.
Arguments
| ∷ Testable prop | |
| ⇒ Bool |
|
| → String | Label. |
| → prop | |
| → Property |
Reports how many test cases satisfy a given condition.
For example:
prop_sorted_sort :: [Int] -> Property prop_sorted_sort xs = sorted xs ==> classify (length xs > 1) "non-trivial" $ sort xs === xs
>>>quickCheck prop_sorted_sort+++ OK, passed 100 tests (22% non-trivial).
Arguments
| ∷ Testable prop | |
| ⇒ Double | The required percentage (0-100) of test cases. |
| → Bool |
|
| → String | Label for the test case class. |
| → prop | |
| → Property |
Checks that at least the given proportion of successful test cases belong to the given class. Discarded tests (i.e. ones with a false precondition) do not affect coverage.
Note: If the coverage check fails, QuickCheck prints out a warning, but
the property does not fail. To make the property fail, use checkCoverage.
For example:
prop_sorted_sort :: [Int] -> Property prop_sorted_sort xs = sorted xs ==> cover 50 (length xs > 1) "non-trivial" $ sort xs === xs
>>>quickCheck prop_sorted_sort+++ OK, passed 100 tests; 135 discarded (26% non-trivial). Only 26% non-trivial, but expected 50%
tabulate ∷ Testable prop ⇒ String → [String] → prop → Property Source #
Collects information about test case distribution into a table.
The arguments to tabulate are the table's name and a list of values
associated with the current test case. After testing, QuickCheck prints the
frequency of all collected values. The frequencies are expressed as a
percentage of the total number of values collected.
You should prefer tabulate to label when each test case is associated
with a varying number of values. Here is a (not terribly useful) example,
where the test data is a list of integers and we record all values that
occur in the list:
prop_sorted_sort :: [Int] -> Property prop_sorted_sort xs = sorted xs ==> tabulate "List elements" (map show xs) $ sort xs === xs
>>>quickCheck prop_sorted_sort+++ OK, passed 100 tests; 1684 discarded. List elements (109 in total): 3.7% 0 3.7% 17 3.7% 2 3.7% 6 2.8% -6 2.8% -7
Here is a more useful example. We are testing a chatroom, where the user can log in, log out, or send a message:
data Command = LogIn | LogOut | SendMessage String deriving (Data, Show) instance Arbitrary Command where ...
There are some restrictions on command sequences; for example, the user must
log in before doing anything else. The function valid :: [Command] -> Bool
checks that a command sequence is allowed. Our property then has the form:
prop_chatroom :: [Command] -> Property
prop_chatroom cmds =
valid cmds ==>
...The use of ==> may skew test case distribution. We use collect to see the
length of the command sequences, and tabulate to get the frequencies of the
individual commands:
prop_chatroom :: [Command] -> Property
prop_chatroom cmds =
wellFormed cmds LoggedOut ==>
'collect' (length cmds) $
'tabulate' "Commands" (map (show . 'Data.Data.toConstr') cmds) $
...>>>quickCheckWith stdArgs{maxDiscardRatio = 1000} prop_chatroom+++ OK, passed 100 tests; 2775 discarded: 60% 0 20% 1 15% 2 3% 3 1% 4 1% 5 Commands (68 in total): 62% LogIn 22% SendMessage 16% LogOut
coverTable ∷ Testable prop ⇒ String → [(String, Double)] → prop → Property Source #
Checks that the values in a given table appear a certain proportion of
the time. A call to coverTable table [(x1, p1), ..., (xn, pn)] asserts
that of the values in table, x1 should appear at least p1 percent of
the time that table appears, x2 at least p2 percent of the time that
table appears, and so on.
Note: If the coverage check fails, QuickCheck prints out a warning, but
the property does not fail. To make the property fail, use checkCoverage.
Continuing the example from the tabular combinator...
data Command = LogIn | LogOut | SendMessage String deriving (Data, Show)
prop_chatroom :: [Command] -> Property
prop_chatroom cmds =
wellFormed cmds LoggedOut ==>
'tabulate' "Commands" (map (show . 'Data.Data.toConstr') cmds) $
......we can add a coverage requirement as follows, which checks that LogIn,
LogOut and SendMessage each occur at least 25% of the time:
prop_chatroom :: [Command] -> Property
prop_chatroom cmds =
wellFormed cmds LoggedOut ==>
coverTable "Commands" [("LogIn", 25), ("LogOut", 25), ("SendMessage", 25)] $
'tabulate' "Commands" (map (show . 'Data.Data.toConstr') cmds) $
... property goes here ...>>>quickCheck prop_chatroom+++ OK, passed 100 tests; 2909 discarded: 56% 0 17% 1 10% 2 6% 3 5% 4 3% 5 3% 7 Commands (111 in total): 51.4% LogIn 30.6% SendMessage 18.0% LogOut Table 'Commands' had only 18.0% LogOut, but expected 25.0%
within ∷ Testable prop ⇒ Int → prop → Property Source #
Considers a property failed if it does not complete within the given number of microseconds.
Note: if the property times out, variables quantified inside the
within will not be printed. Therefore, you should use within
only in the body of your property.
Good: prop_foo a b c = within 1000000 ...
Bad: prop_foo = within 1000000 $ \a b c -> ...
Bad: prop_foo a b c = ...; main = quickCheck (within 1000000 prop_foo)
discardAfter ∷ Testable prop ⇒ Int → prop → Property Source #
Discards the test case if it does not complete within the given number of microseconds. This can be useful when testing algorithms that have pathological cases where they run extremely slowly.
forAll ∷ (Show a, Testable prop) ⇒ Gen a → (a → prop) → Property Source #
Explicit universal quantification: uses an explicitly given test case generator.
forAllShow ∷ Testable prop ⇒ Gen a → (a → String) → (a → prop) → Property Source #
Like forAll, but with an explicitly given show function.
forAllBlind ∷ Testable prop ⇒ Gen a → (a → prop) → Property Source #
Like forAll, but without printing the generated value.
forAllShrink ∷ (Show a, Testable prop) ⇒ Gen a → (a → [a]) → (a → prop) → Property Source #
Like forAll, but tries to shrink the argument for failing test cases.
forAllShrinkShow ∷ Testable prop ⇒ Gen a → (a → [a]) → (a → String) → (a → prop) → Property Source #
Like forAllShrink, but with an explicitly given show function.
forAllShrinkBlind ∷ Testable prop ⇒ Gen a → (a → [a]) → (a → prop) → Property Source #
Like forAllShrink, but without printing the generated value.
(.&.) ∷ (Testable prop1, Testable prop2) ⇒ prop1 → prop2 → Property infixr 1 Source #
Nondeterministic choice: p1 .&. p2 picks randomly one of
p1 and p2 to test. If you test the property 100 times it
makes 100 random choices.
(.&&.) ∷ (Testable prop1, Testable prop2) ⇒ prop1 → prop2 → Property infixr 1 Source #
Conjunction: p1 .&&. p2 passes if both p1 and p2 pass.
(.||.) ∷ (Testable prop1, Testable prop2) ⇒ prop1 → prop2 → Property infixr 1 Source #
Disjunction: p1 .||. p2 passes unless p1 and p2 simultaneously fail.
(===) ∷ (Eq a, Show a) ⇒ a → a → Property infix 4 Source #
Like ==, but prints a counterexample when it fails.
(=/=) ∷ (Eq a, Show a) ⇒ a → a → Property infix 4 Source #
Like /=, but prints a counterexample when it fails.
total ∷ NFData a ⇒ a → Property Source #
Checks that a value is total, i.e., doesn't crash when evaluated.
quickCheck ∷ Testable prop ⇒ prop → IO () Source #
Tests a property and prints the results to stdout.
By default up to 100 tests are performed, which may not be enough
to find all bugs. To run more tests, use withMaxSuccess.
If you want to get the counterexample as a Haskell value, rather than just printing it, try the quickcheck-with-counterexamples package.
quickCheckWith ∷ Testable prop ⇒ Args → prop → IO () Source #
Tests a property, using test arguments, and prints the results to stdout.
quickCheckResult ∷ Testable prop ⇒ prop → IO Result Source #
Tests a property, produces a test result, and prints the results to stdout.
quickCheckWithResult ∷ Testable prop ⇒ Args → prop → IO Result Source #
Tests a property, using test arguments, produces a test result, and prints the results to stdout.
recheck ∷ Testable prop ⇒ Result → prop → IO () Source #
Re-run a property with the seed and size that failed in a run of quickCheckResult.
verboseCheck ∷ Testable prop ⇒ prop → IO () Source #
Tests a property and prints the results and all test cases generated to stdout.
This is just a convenience function that means the same as .quickCheck . verbose
Note: for technical reasons, the test case is printed out after
the property is tested. To debug a property that goes into an
infinite loop, use within to add a timeout instead.
verboseCheckWith ∷ Testable prop ⇒ Args → prop → IO () Source #
Tests a property, using test arguments, and prints the results and all test cases generated to stdout.
This is just a convenience function that combines quickCheckWith and verbose.
Note: for technical reasons, the test case is printed out after
the property is tested. To debug a property that goes into an
infinite loop, use within to add a timeout instead.
verboseCheckResult ∷ Testable prop ⇒ prop → IO Result Source #
Tests a property, produces a test result, and prints the results and all test cases generated to stdout.
This is just a convenience function that combines quickCheckResult and verbose.
Note: for technical reasons, the test case is printed out after
the property is tested. To debug a property that goes into an
infinite loop, use within to add a timeout instead.
verboseCheckWithResult ∷ Testable prop ⇒ Args → prop → IO Result Source #
Tests a property, using test arguments, produces a test result, and prints the results and all test cases generated to stdout.
This is just a convenience function that combines quickCheckWithResult and verbose.
Note: for technical reasons, the test case is printed out after
the property is tested. To debug a property that goes into an
infinite loop, use within to add a timeout instead.
polyQuickCheck ∷ Name → ExpQ Source #
Test a polymorphic property, defaulting all type variables to Integer.
Invoke as $(, where polyQuickCheck 'prop)prop is a property.
Note that just evaluating in GHCi will seem to
work, but will silently default all type variables to quickCheck prop()!
$( means the same as
polyQuickCheck 'prop).
If you want to supply custom arguments to quickCheck $(monomorphic 'prop)polyQuickCheck,
you will have to combine quickCheckWith and monomorphic yourself.
If you want to use polyQuickCheck in the same file where you defined the
property, the same scoping problems pop up as in quickCheckAll:
see the note there about return [].
polyVerboseCheck ∷ Name → ExpQ Source #
Test a polymorphic property, defaulting all type variables to Integer.
This is just a convenience function that combines verboseCheck and monomorphic.
If you want to use polyVerboseCheck in the same file where you defined the
property, the same scoping problems pop up as in quickCheckAll:
see the note there about return [].
monomorphic ∷ Name → ExpQ Source #
Monomorphise an arbitrary property by defaulting all type variables to Integer.
For example, if f has type
then Ord a => [a] -> [a]$( has type monomorphic 'f)[.Integer] -> [Integer]
If you want to use monomorphic in the same file where you defined the
property, the same scoping problems pop up as in quickCheckAll:
see the note there about return [].
forAllProperties ∷ Q Exp Source #
Test all properties in the current module, using a custom
quickCheck function. The same caveats as with quickCheckAll
apply.
$ has type forAllProperties(.
An example invocation is Property -> IO Result) -> IO Bool$,
which does the same thing as forAllProperties quickCheckResult$.quickCheckAll
forAllProperties has the same issue with scoping as quickCheckAll:
see the note there about return [].
allProperties ∷ Q Exp Source #
List all properties in the current module.
$ has type allProperties[(.String, Property)]
allProperties has the same issue with scoping as quickCheckAll:
see the note there about return [].
quickCheckAll ∷ Q Exp Source #
Test all properties in the current module.
The name of the property must begin with prop_.
Polymorphic properties will be defaulted to Integer.
Returns True if all tests succeeded, False otherwise.
To use quickCheckAll, add a definition to your module along
the lines of
return [] runTests = $quickCheckAll
and then execute runTests.
Note: the bizarre return [] in the example above is needed on
GHC 7.8 and later; without it, quickCheckAll will not be able to find
any of the properties. For the curious, the return [] is a
Template Haskell splice that makes GHC insert the empty list
of declarations at that point in the program; GHC typechecks
everything before the return [] before it starts on the rest
of the module, which means that the later call to quickCheckAll
can see everything that was defined before the return []. Yikes!
verboseCheckAll ∷ Q Exp Source #
Test all properties in the current module.
This is just a convenience function that combines quickCheckAll and verbose.
verboseCheckAll has the same issue with scoping as quickCheckAll:
see the note there about return [].
labelledExamples ∷ Testable prop ⇒ prop → IO () Source #
Given a property, which must use label, collect, classify or cover
to associate labels with test cases, find an example test case for each possible label.
The example test cases are minimised using shrinking.
For example, suppose we test and record the number
of times that delete x xsx occurs in xs:
prop_delete :: Int -> [Int] -> Property prop_delete x xs = classify (count x xs == 0) "count x xs == 0" $ classify (count x xs == 1) "count x xs == 1" $ classify (count x xs >= 2) "count x xs >= 2" $ counterexample (show (delete x xs)) $ count x (delete x xs) == max 0 (count x xs-1) where count x xs = length (filter (== x) xs)
labelledExamples generates three example test cases, one for each label:
>>>labelledExamples prop_delete*** Found example of count x xs == 0 0 [] [] *** Found example of count x xs == 1 0 [0] [] *** Found example of count x xs >= 2 5 [5,5] [5] +++ OK, passed 100 tests: 78% count x xs == 0 21% count x xs == 1 1% count x xs >= 2
labelledExamplesWith ∷ Testable prop ⇒ Args → prop → IO () Source #
A variant of labelledExamples that takes test arguments.
labelledExamplesResult ∷ Testable prop ⇒ prop → IO Result Source #
A variant of labelledExamples that returns a result.
labelledExamplesWithResult ∷ Testable prop ⇒ Args → prop → IO Result Source #
A variant of labelledExamples that takes test arguments and returns a result.
when ∷ Applicative f ⇒ Bool → f () → f () #
Conditional execution of Applicative expressions. For example,
when debug (putStrLn "Debugging")
will output the string Debugging if the Boolean value debug
is True, and otherwise do nothing.
unless ∷ Applicative f ⇒ Bool → f () → f () #
The reverse of when.
(>=>) ∷ Monad m ⇒ (a → m b) → (b → m c) → a → m c infixr 1 #
Left-to-right composition of Kleisli arrows.
'(bs ' can be understood as the >=> cs) ado expression
do b <- bs a cs b
replicateM ∷ Applicative m ⇒ Int → m a → m [a] #
performs the action replicateM n actact n times,
and then returns the list of results:
Examples
>>>import Control.Monad.State>>>runState (replicateM 3 $ state $ \s -> (s, s + 1)) 1([1,2,3],4)
replicateM_ ∷ Applicative m ⇒ Int → m a → m () #
runIO ∷ IO r → SpecM a r Source #
Run an IO action while constructing the spec tree.
SpecM is a monad to construct a spec tree, without executing any spec
items. runIO allows you to run IO actions during this construction phase.
The IO action is always run when the spec tree is constructed (e.g. even
when --dry-run is specified).
If you do not need the result of the IO action to construct the spec tree,
beforeAll may be more suitable for your use case.
ansiExprString ∷ ToExpr a ⇒ a → String Source #
diffExprString ∷ ToExpr a ⇒ a → a → String Source #
diffExprCompactString ∷ ToExpr a ⇒ a → a → String Source #
sequential ∷ SpecWith a → SpecWith a Source #
sequential marks all spec items of the given spec to be evaluated sequentially.
modifyMaxSuccess ∷ (Int → Int) → SpecWith a → SpecWith a Source #
Use a modified maxSuccess for given spec.
modifyMaxDiscardRatio ∷ (Int → Int) → SpecWith a → SpecWith a Source #
Use a modified maxDiscardRatio for given spec.
modifyMaxSize ∷ (Int → Int) → SpecWith a → SpecWith a Source #
Use a modified maxSize for given spec.
modifyMaxShrinks ∷ (Int → Int) → SpecWith a → SpecWith a Source #
Use a modified maxShrinks for given spec.
beforeWith ∷ (b → IO a) → SpecWith a → SpecWith b Source #
Run a custom action before every spec item.
beforeAll ∷ HasCallStack ⇒ IO a → SpecWith a → Spec Source #
Run a custom action before the first spec item.
beforeAll_ ∷ HasCallStack ⇒ IO () → SpecWith a → SpecWith a Source #
Run a custom action before the first spec item.
beforeAllWith ∷ HasCallStack ⇒ (b → IO a) → SpecWith a → SpecWith b Source #
Run a custom action with an argument before the first spec item.
around ∷ (ActionWith a → IO ()) → SpecWith a → Spec Source #
Run a custom action before and/or after every spec item.
afterAll ∷ HasCallStack ⇒ ActionWith a → SpecWith a → SpecWith a Source #
Run a custom action after the last spec item.
afterAll_ ∷ HasCallStack ⇒ IO () → SpecWith a → SpecWith a Source #
Run a custom action after the last spec item.
around_ ∷ (IO () → IO ()) → SpecWith a → SpecWith a Source #
Run a custom action before and/or after every spec item.
aroundWith ∷ (ActionWith a → ActionWith b) → SpecWith a → SpecWith b Source #
Run a custom action before and/or after every spec item.
aroundAll ∷ HasCallStack ⇒ (ActionWith a → IO ()) → SpecWith a → Spec Source #
Wrap an action around the given spec.
aroundAll_ ∷ HasCallStack ⇒ (IO () → IO ()) → SpecWith a → SpecWith a Source #
Wrap an action around the given spec.
aroundAllWith ∷ HasCallStack ⇒ (ActionWith a → ActionWith b) → SpecWith a → SpecWith b Source #
Wrap an action around the given spec. Changes the arg type inside.
mapSubject ∷ (b → a) → SpecWith a → SpecWith b Source #
Modify the subject under test.
Note that this resembles a contravariant functor on the first type parameter
of SpecM. This is because the subject is passed inwards, as an argument
to the spec item.
ignoreSubject ∷ SpecWith () → SpecWith a Source #
Ignore the subject under test for a given spec.
xcontext ∷ HasCallStack ⇒ String → SpecWith a → SpecWith a Source #
xcontext is an alias for xdescribe.
specify ∷ (HasCallStack, Example a) ⇒ String → a → SpecWith (Arg a) Source #
specify is an alias for it.
xspecify ∷ (HasCallStack, Example a) ⇒ String → a → SpecWith (Arg a) Source #
xspecify is an alias for xit.
fspecify ∷ (HasCallStack, Example a) ⇒ String → a → SpecWith (Arg a) Source #
fspecify is an alias for fit.
fcontext ∷ HasCallStack ⇒ String → SpecWith a → SpecWith a Source #
fcontext is an alias for fdescribe.
pending ∷ HasCallStack ⇒ Expectation Source #
pending can be used to mark a spec item as pending.
If you want to textually specify a behavior but do not have an example yet, use this:
describe "fancyFormatter" $ do
it "can format text in a way that everyone likes" $
pendingpendingWith ∷ HasCallStack ⇒ String → Expectation Source #
pendingWith is similar to pending, but it takes an additional string
argument that can be used to specify the reason for why the spec item is pending.
example ∷ Expectation → Expectation Source #
example is a type restricted version of id. It can be used to get better
error messages on type mismatches.
Compare e.g.
it "exposes some behavior" $ example $ do putStrLn
with
it "exposes some behavior" $ do putStrLn
ledgerTestMain ∷ Spec → IO () Source #
tracedDiscard ∷ String → a Source #
Same as discard but outputs a debug trace message
Enforce the type of expectation
Useful with polymorphic expectations that are defined below.
Example
Because shouldBeExpr is polymorphic in m, compiler will choke with a unification
error. This is due to the fact that hspec's it expects a polymorphic Example.
it "MyTest" $ do "foo" `shouldBeExpr` "bar"
However, this is easily solved by io:
it "MyTest" $ io $ do "foo" `shouldBeExpr` "bar"
Expectations
Lifted expectations
assertBool ∷ (HasCallStack, MonadIO m) ⇒ String → Bool → m () Source #
Lifted version of assertBool
assertFailure ∷ (HasCallStack, MonadIO m) ⇒ String → m a Source #
Just like expectationFailure, but does not force the return type to unit. Lifted
version of assertFailure
assertColorFailure ∷ (HasCallStack, MonadIO m) ⇒ String → m a Source #
expectationFailure ∷ (HasCallStack, MonadIO m) ⇒ String → m () Source #
shouldBe ∷ (HasCallStack, MonadIO m, Show a, Eq a) ⇒ a → a → m () infix 1 Source #
actual `shouldBe` expected sets the expectation that actual is equal
to expected.
shouldSatisfy ∷ (HasCallStack, MonadIO m, Show a) ⇒ a → (a → Bool) → m () infix 1 Source #
v `shouldSatisfy` p sets the expectation that p v is True.
shouldSatisfyExpr ∷ (HasCallStack, MonadIO m, ToExpr a) ⇒ a → (a → Bool) → m () Source #
shouldStartWith ∷ (HasCallStack, MonadIO m, Show a, Eq a) ⇒ [a] → [a] → m () infix 1 Source #
list `shouldStartWith` prefix sets the expectation that list starts with prefix,
shouldEndWith ∷ (HasCallStack, MonadIO m, Show a, Eq a) ⇒ [a] → [a] → m () infix 1 Source #
list `shouldEndWith` suffix sets the expectation that list ends with suffix,
shouldContain ∷ (HasCallStack, MonadIO m, Show a, Eq a) ⇒ [a] → [a] → m () infix 1 Source #
list `shouldContain` sublist sets the expectation that sublist is contained,
wholly and intact, anywhere in list.
shouldMatchList ∷ (HasCallStack, MonadIO m, Show a, Eq a) ⇒ [a] → [a] → m () infix 1 Source #
xs `shouldMatchList` ys sets the expectation that xs has the same
elements that ys has, possibly in another order
shouldReturn ∷ (HasCallStack, MonadIO m, Show a, Eq a) ⇒ m a → a → m () infix 1 Source #
action `shouldReturn` expected sets the expectation that action
returns expected.
shouldNotBe ∷ (HasCallStack, MonadIO m, Show a, Eq a) ⇒ a → a → m () infix 1 Source #
actual `shouldNotBe` notExpected sets the expectation that actual is not
equal to notExpected
shouldNotSatisfy ∷ (HasCallStack, MonadIO m, Show a) ⇒ a → (a → Bool) → m () infix 1 Source #
v `shouldNotSatisfy` p sets the expectation that p v is False.
shouldNotContain ∷ (HasCallStack, MonadIO m, Show a, Eq a) ⇒ [a] → [a] → m () infix 1 Source #
list `shouldNotContain` sublist sets the expectation that sublist is not
contained anywhere in list.
shouldNotReturn ∷ (HasCallStack, MonadIO m, Show a, Eq a) ⇒ m a → a → m () infix 1 Source #
action `shouldNotReturn` notExpected sets the expectation that action
does not return notExpected.
shouldThrow ∷ (HasCallStack, Exception e, MonadUnliftIO m) ⇒ m a → Selector e → m () infix 1 Source #
Lifted version of shouldThrow.
Non-standard expectations
shouldBeExpr ∷ (HasCallStack, ToExpr a, Eq a, MonadIO m) ⇒ a → a → m () infix 1 Source #
shouldBeRight ∷ (HasCallStack, Show a, Show b, Eq b, MonadIO m) ⇒ Either a b → b → m () infix 1 Source #
shouldBeLeft ∷ (HasCallStack, Show a, Eq a, Show b, MonadIO m) ⇒ Either a b → a → m () infix 1 Source #
shouldBeRightExpr ∷ (HasCallStack, ToExpr a, Eq b, ToExpr b, MonadIO m) ⇒ Either a b → b → m () infix 1 Source #
Same as shouldBeExpr, except it checks that the value is Right
shouldBeLeftExpr ∷ (HasCallStack, ToExpr a, ToExpr b, Eq a, MonadIO m) ⇒ Either a b → a → m () infix 1 Source #
Same as shouldBeExpr, except it checks that the value is Left
shouldContainExpr ∷ (HasCallStack, ToExpr a, Eq a, MonadIO m) ⇒ [a] → [a] → m () Source #
expectRight ∷ (HasCallStack, Show a, MonadIO m) ⇒ Either a b → m b Source #
Return value on the Right and fail otherwise. Lifted version of expectRight.
expectRightDeep_ ∷ (HasCallStack, Show a, NFData b, MonadIO m) ⇒ Either a b → m () Source #
Same as expectRightDeep, but discards the result
expectRightDeep ∷ (HasCallStack, Show a, NFData b, MonadIO m) ⇒ Either a b → m b Source #
Same as expectRight, but also evaluate the returned value to NF
expectRightExpr ∷ (HasCallStack, ToExpr a, MonadIO m) ⇒ Either a b → m b Source #
Same as expectRight, but use ToExpr instead of Show
expectRightDeepExpr ∷ (HasCallStack, ToExpr a, NFData b, MonadIO m) ⇒ Either a b → m b Source #
Same as expectRightDeep, but use ToExpr instead of Show
expectRightDeepExpr_ ∷ (HasCallStack, ToExpr a, NFData b, MonadIO m) ⇒ Either a b → m () Source #
Same as expectRightDeepExpr, but discard the contents of Right
expectLeft ∷ (HasCallStack, Show b, MonadIO m) ⇒ Either a b → m a Source #
Return value on the Left and fail otherwise
expectLeftDeep_ ∷ (HasCallStack, NFData a, Show b, MonadIO m) ⇒ Either a b → m () Source #
Same as expectLeftDeep, but discards the result
expectLeftExpr ∷ (HasCallStack, ToExpr b, MonadIO m) ⇒ Either a b → m a Source #
Same as expectLeft, but use ToExpr instead of Show
expectLeftDeep ∷ (HasCallStack, NFData a, Show b, MonadIO m) ⇒ Either a b → m a Source #
Same as expectLeft, but also evaluate the returned value to NF
expectLeftDeepExpr ∷ (HasCallStack, ToExpr b, NFData a, MonadIO m) ⇒ Either a b → m a Source #
Same as expectLeftDeep, but use ToExpr instead of Show
expectLeftDeepExpr_ ∷ (HasCallStack, ToExpr b, NFData a, MonadIO m) ⇒ Either a b → m () Source #
Same as expectLeftDeepExpr, but discard the contents of Left
expectJust ∷ (HasCallStack, MonadIO m) ⇒ Maybe a → m a Source #
expectJustDeep ∷ (HasCallStack, NFData a, MonadIO m) ⇒ Maybe a → m a Source #
expectJustDeep_ ∷ (HasCallStack, NFData a, MonadIO m) ⇒ Maybe a → m () Source #
expectNothing ∷ (HasCallStack, Show a, MonadIO m) ⇒ Maybe a → m () Source #
expectNothingExpr ∷ (HasCallStack, MonadIO m, ToExpr a) ⇒ Maybe a → m () Source #
MonadGen
module Test.QuickCheck.GenT
Random interface
class StatefulGen g m ⇒ HasStatefulGen g (m ∷ Type → Type) | m → g where Source #
Minimal complete definition
Nothing
Methods
askStatefulGen ∷ m g Source #
Instances
| (HasGenEnv env g, StatefulGen g (ReaderT env m), Monad m) ⇒ HasStatefulGen g (ReaderT env m) | |
Defined in Test.ImpSpec.Random Methods askStatefulGen ∷ ReaderT env m g Source # | |
| HasStatefulGen (IOGenM QCGen) (ImpM t) | |
Defined in Test.ImpSpec.Internal Methods askStatefulGen ∷ ImpM t (IOGenM QCGen) Source # | |
class Monad m ⇒ StatefulGen g (m ∷ Type → Type) Source #
StatefulGen is an interface to monadic pseudo-random number generators.
Since: random-1.2.0
Minimal complete definition
Instances
uniformM ∷ (HasStatefulGen g m, Uniform a) ⇒ m a Source #
uniformRM ∷ (HasStatefulGen g m, UniformRange a) ⇒ (a, a) → m a Source #
uniformListM ∷ (HasStatefulGen g m, Uniform a) ⇒ Int → m [a] Source #
uniformListRM ∷ (HasStatefulGen g m, UniformRange a) ⇒ (a, a) → Int → m [a] Source #
uniformByteStringM ∷ HasStatefulGen a m ⇒ Int → m ByteString Source #
uniformShortByteStringM ∷ HasStatefulGen a m ⇒ Int → m ShortByteString Source #
Re-exports from ImpSpec
Orphan instances
| MonadUnliftIO m ⇒ MonadUnliftIO (GenT m) Source # | |