foundation-0.0.15: Alternative prelude with batteries and no dependencies

LicenseBSD-style
MaintainerFoundation maintainers
Safe HaskellNone
LanguageHaskell2010

Foundation.Check

Contents

Description

An implementation of a test framework and property expression & testing

Synopsis

Documentation

data Gen a #

Generator monad

Instances

Monad Gen # 

Methods

(>>=) :: Gen a -> (a -> Gen b) -> Gen b #

(>>) :: Gen a -> Gen b -> Gen b #

return :: a -> Gen a #

fail :: String -> Gen a #

Functor Gen # 

Methods

fmap :: (a -> b) -> Gen a -> Gen b #

(<$) :: a -> Gen b -> Gen a #

Applicative Gen # 

Methods

pure :: a -> Gen a #

(<*>) :: Gen (a -> b) -> Gen a -> Gen b #

(*>) :: Gen a -> Gen b -> Gen b #

(<*) :: Gen a -> Gen b -> Gen a #

class Arbitrary a where #

How to generate an arbitrary value for a

Minimal complete definition

arbitrary

Methods

arbitrary :: Gen a #

Instances

Arbitrary Bool # 

Methods

arbitrary :: Gen Bool #

Arbitrary Char # 

Methods

arbitrary :: Gen Char #

Arbitrary Double # 

Methods

arbitrary :: Gen Double #

Arbitrary Float # 

Methods

arbitrary :: Gen Float #

Arbitrary Int # 

Methods

arbitrary :: Gen Int #

Arbitrary Int8 # 

Methods

arbitrary :: Gen Int8 #

Arbitrary Int16 # 

Methods

arbitrary :: Gen Int16 #

Arbitrary Int32 # 

Methods

arbitrary :: Gen Int32 #

Arbitrary Int64 # 

Methods

arbitrary :: Gen Int64 #

Arbitrary Integer # 
Arbitrary Word # 

Methods

arbitrary :: Gen Word #

Arbitrary Word8 # 

Methods

arbitrary :: Gen Word8 #

Arbitrary Word16 # 

Methods

arbitrary :: Gen Word16 #

Arbitrary Word32 # 

Methods

arbitrary :: Gen Word32 #

Arbitrary Word64 # 

Methods

arbitrary :: Gen Word64 #

Arbitrary Natural # 
Arbitrary String # 

Methods

arbitrary :: Gen String #

Arbitrary AsciiString # 
Arbitrary Word256 # 
Arbitrary Word128 # 
Arbitrary Char7 # 

Methods

arbitrary :: Gen Char7 #

Arbitrary a => Arbitrary [a] # 

Methods

arbitrary :: Gen [a] #

Arbitrary a => Arbitrary (Maybe a) # 

Methods

arbitrary :: Gen (Maybe a) #

(NatWithinBound Word64 n, KnownNat n) => Arbitrary (Zn64 n) # 

Methods

arbitrary :: Gen (Zn64 n) #

KnownNat n => Arbitrary (Zn n) # 

Methods

arbitrary :: Gen (Zn n) #

Arbitrary (CountOf ty) # 

Methods

arbitrary :: Gen (CountOf ty) #

(Arbitrary l, Arbitrary r) => Arbitrary (Either l r) # 

Methods

arbitrary :: Gen (Either l r) #

(Arbitrary a, Arbitrary b) => Arbitrary (a, b) # 

Methods

arbitrary :: Gen (a, b) #

(Arbitrary a, Arbitrary b, Arbitrary c) => Arbitrary (a, b, c) # 

Methods

arbitrary :: Gen (a, b, c) #

(Arbitrary a, Arbitrary b, Arbitrary c, Arbitrary d) => Arbitrary (a, b, c, d) # 

Methods

arbitrary :: Gen (a, b, c, d) #

(Arbitrary a, Arbitrary b, Arbitrary c, Arbitrary d, Arbitrary e) => Arbitrary (a, b, c, d, e) # 

Methods

arbitrary :: Gen (a, b, c, d, e) #

(Arbitrary a, Arbitrary b, Arbitrary c, Arbitrary d, Arbitrary e, Arbitrary f) => Arbitrary (a, b, c, d, e, f) # 

Methods

arbitrary :: Gen (a, b, c, d, e, f) #

oneof :: NonEmpty [Gen a] -> Gen a #

elements :: NonEmpty [a] -> Gen a #

frequency :: NonEmpty [(Word, Gen a)] -> Gen a #

Call one of the generator weighted

data Test where #

different type of tests supported

Constructors

Unit :: String -> IO () -> Test 
Property :: IsProperty prop => String -> prop -> Test 
Group :: String -> [Test] -> Test 
CheckPlan :: String -> Check () -> Test 

testName :: Test -> String #

Name of a test

Property

data PropertyCheck #

The type of check this test did for a property

data Property #

Constructors

Prop 

Fields

Instances

class IsProperty p where #

Minimal complete definition

property

Methods

property :: p -> Property #

Instances

(===) :: (Show a, Eq a, Typeable a) => a -> a -> PropertyCheck infix 4 #

A property that check for equality of its 2 members.

propertyCompare #

Arguments

:: (Show a, Typeable a) 
=> String

name of the function used for comparaison, e.g. (<)

-> (a -> a -> Bool)

function used for value comparaison

-> a

value left of the operator

-> a

value right of the operator

-> PropertyCheck 

A property that check for a specific comparaison of its 2 members.

This is equivalent to === but with compare

propertyAnd :: PropertyCheck -> PropertyCheck -> PropertyCheck #

A conjuctive property composed of 2 properties that need to pass

forAll :: (Show a, IsProperty prop) => Gen a -> (a -> prop) -> Property #

Running a generator for a specific type under a property

Check Plan

data Check a #

Instances

Monad Check # 

Methods

(>>=) :: Check a -> (a -> Check b) -> Check b #

(>>) :: Check a -> Check b -> Check b #

return :: a -> Check a #

fail :: String -> Check a #

Functor Check # 

Methods

fmap :: (a -> b) -> Check a -> Check b #

(<$) :: a -> Check b -> Check a #

Applicative Check # 

Methods

pure :: a -> Check a #

(<*>) :: Check (a -> b) -> Check a -> Check b #

(*>) :: Check a -> Check b -> Check b #

(<*) :: Check a -> Check b -> Check a #

MonadState Check # 

Associated Types

type State (Check :: * -> *) :: * #

Methods

withState :: (State Check -> (a, State Check)) -> Check a #

type State Check # 

validate :: IsProperty prop => String -> prop -> Check () #

pick :: String -> IO a -> Check a #

iterateProperty :: CountOf TestResult -> GenParams -> (Word64 -> GenRng) -> Property -> IO (PropertyResult, CountOf TestResult) #