tasty-smallcheck-0.8.2: SmallCheck support for the Tasty test framework.

Safe Haskell | Safe-Inferred
Language | Haskell2010

Test.Tasty.SmallCheck

Contents

- Orphan instances

Description

This module allows to use SmallCheck properties in tasty.

Synopsis

- testProperty :: Testable IO a => TestName -> a -> TestTree
- newtype SmallCheckDepth = SmallCheckDepth Int
- type Reason = String
- type Depth = Int
- class Monad m => Testable (m :: Type -> Type) a where
  - test :: a -> Property m
- data Property (m :: Type -> Type)
- (==>) :: forall (m :: Type -> Type) c a. (Testable m c, Testable m a) => c -> a -> Property m
- over :: forall a (m :: Type -> Type) b. (Show a, Testable m b) => Series m a -> (a -> b) -> Property m
- monadic :: Testable m a => m a -> Property m
- forAll :: forall (m :: Type -> Type) a. Testable m a => a -> Property m
- exists :: forall (m :: Type -> Type) a. Testable m a => a -> Property m
- existsUnique :: forall (m :: Type -> Type) a. Testable m a => a -> Property m
- changeDepth :: forall (m :: Type -> Type) a. Testable m a => (Depth -> Depth) -> a -> Property m
- changeDepth1 :: forall a (m :: Type -> Type) b. (Show a, Serial m a, Testable m b) => (Depth -> Depth) -> (a -> b) -> Property m

# Documentation

testProperty :: Testable IO a => TestName -> a -> TestTree Source #

Create a `Test` for a SmallCheck `Testable` property

newtype SmallCheckDepth Source #

The "depth" parameter for SmallCheck

Constructors

SmallCheckDepth Int |

#### Instances

Instances details

Enum SmallCheckDepth Source # |

Instance details

Defined in Test.Tasty.SmallCheck

Methods

succ :: SmallCheckDepth -> SmallCheckDepth Source #

pred :: SmallCheckDepth -> SmallCheckDepth Source #

toEnum :: Int -> SmallCheckDepth Source #

fromEnum :: SmallCheckDepth -> Int Source #

enumFrom :: SmallCheckDepth -> [SmallCheckDepth] Source #

enumFromThen :: SmallCheckDepth -> SmallCheckDepth -> [SmallCheckDepth] Source #

enumFromTo :: SmallCheckDepth -> SmallCheckDepth -> [SmallCheckDepth] Source #

enumFromThenTo :: SmallCheckDepth -> SmallCheckDepth -> SmallCheckDepth -> [SmallCheckDepth] Source #

Num SmallCheckDepth Source # |

Instance details

Defined in Test.Tasty.SmallCheck

Methods

(+) :: SmallCheckDepth -> SmallCheckDepth -> SmallCheckDepth Source #

(-) :: SmallCheckDepth -> SmallCheckDepth -> SmallCheckDepth Source #

(*) :: SmallCheckDepth -> SmallCheckDepth -> SmallCheckDepth Source #

negate :: SmallCheckDepth -> SmallCheckDepth Source #

abs :: SmallCheckDepth -> SmallCheckDepth Source #

signum :: SmallCheckDepth -> SmallCheckDepth Source #

fromInteger :: Integer -> SmallCheckDepth Source #

Integral SmallCheckDepth Source # |

Instance details

Defined in Test.Tasty.SmallCheck

Methods

quot :: SmallCheckDepth -> SmallCheckDepth -> SmallCheckDepth Source #

rem :: SmallCheckDepth -> SmallCheckDepth -> SmallCheckDepth Source #

div :: SmallCheckDepth -> SmallCheckDepth -> SmallCheckDepth Source #

mod :: SmallCheckDepth -> SmallCheckDepth -> SmallCheckDepth Source #

quotRem :: SmallCheckDepth -> SmallCheckDepth -> (SmallCheckDepth, SmallCheckDepth) Source #

divMod :: SmallCheckDepth -> SmallCheckDepth -> (SmallCheckDepth, SmallCheckDepth) Source #

toInteger :: SmallCheckDepth -> Integer Source #

Real SmallCheckDepth Source # |
Instance details Defined in Test.Tasty.SmallCheck Methods toRational :: SmallCheckDepth -> Rational Source #
Eq SmallCheckDepth Source # |
Instance details Defined in Test.Tasty.SmallCheck Methods (==) :: SmallCheckDepth -> SmallCheckDepth -> Bool Source # (/=) :: SmallCheckDepth -> SmallCheckDepth -> Bool Source #
Ord SmallCheckDepth Source # |

Instance details

Defined in Test.Tasty.SmallCheck

Methods

compare :: SmallCheckDepth -> SmallCheckDepth -> Ordering Source #

(<) :: SmallCheckDepth -> SmallCheckDepth -> Bool Source #

(<=) :: SmallCheckDepth -> SmallCheckDepth -> Bool Source #

(>) :: SmallCheckDepth -> SmallCheckDepth -> Bool Source #

(>=) :: SmallCheckDepth -> SmallCheckDepth -> Bool Source #

max :: SmallCheckDepth -> SmallCheckDepth -> SmallCheckDepth Source #

min :: SmallCheckDepth -> SmallCheckDepth -> SmallCheckDepth Source #

IsOption SmallCheckDepth Source # |
Instance details Defined in Test.Tasty.SmallCheck Methods defaultValue :: SmallCheckDepth Source # parseValue :: String -> Maybe SmallCheckDepth Source # optionName :: Tagged SmallCheckDepth String Source # optionHelp :: Tagged SmallCheckDepth String Source # showDefaultValue :: SmallCheckDepth -> Maybe String Source # optionCLParser :: Parser SmallCheckDepth Source #

type Reason = String Source #

An explanation for the test outcome.

Since: smallcheck-1.1

type Depth = Int Source #

Maximum depth of generated test values.

For data values, it is the depth of nested constructor applications.

For functional values, it is both the depth of nested case analysis and the depth of results.

Since: smallcheck-0.6

class Monad m => Testable (m :: Type -> Type) a where Source #

Class of tests that can be run in a monad. For pure tests, it is recommended to keep their types polymorphic in `m` rather than specialising it to `Identity`.

Since: smallcheck-1.0

Methods

test :: a -> Property m Source #

Since: smallcheck-1.0

#### Instances

Instances details

Monad m => Testable m Bool |
Instance details Defined in Test.SmallCheck.Property Methods test :: Bool -> Property m Source #
(Monad m, m ~ n) => Testable n (Property m) |
Instance details Defined in Test.SmallCheck.Property Methods test :: Property m -> Property n Source #
Monad m => Testable m (Either Reason Reason) | Works like the `Bool` instance, but includes an explanation of the result. `Left` and `Right` correspond to test failure and success respectively. Since: smallcheck-1.1
Instance details Defined in Test.SmallCheck.Property Methods test :: Either Reason Reason -> Property m Source #
(Serial m a, Show a, Testable m b) => Testable m (a -> b) |
Instance details Defined in Test.SmallCheck.Property Methods test :: (a -> b) -> Property m Source #

data Property (m :: Type -> Type) Source #

The type of properties over the monad `m`.

Since: smallcheck-1.0

#### Instances

Instances details

(Monad m, m ~ n) => Testable n (Property m) |
Instance details Defined in Test.SmallCheck.Property Methods test :: Property m -> Property n Source #
IsTest (Property IO) Source # |
Instance details Defined in Test.Tasty.SmallCheck Methods run :: OptionSet -> Property IO -> (Progress -> IO ()) -> IO Result Source # testOptions :: Tagged (Property IO) [OptionDescription] Source #

(==>) :: forall (m :: Type -> Type) c a. (Testable m c, Testable m a) => c -> a -> Property m infixr 0 Source #

The `==>` operator can be used to express a restricting condition under which a property should hold. It corresponds to implication in the classical logic.

Note that `==>` resets the quantification context for its operands to the default (universal).

Since: smallcheck-1.0

over :: forall a (m :: Type -> Type) b. (Show a, Testable m b) => Series m a -> (a -> b) -> Property m Source #

``over` s $ \x -> p x` makes `x` range over the `Series` `s` (by default, all variables range over the `series` for their types).

Note that, unlike the quantification operators, this affects only the variable following the operator and not subsequent variables.

`over` does not affect the quantification context.

Since: smallcheck-1.0

monadic :: Testable m a => m a -> Property m Source #

Execute a monadic test.

Since: smallcheck-1.0

forAll :: forall (m :: Type -> Type) a. Testable m a => a -> Property m Source #

Set the universal quantification context.

Since: smallcheck-1.0

exists :: forall (m :: Type -> Type) a. Testable m a => a -> Property m Source #

Set the existential quantification context.

Since: smallcheck-1.0

existsUnique :: forall (m :: Type -> Type) a. Testable m a => a -> Property m Source #

Set the uniqueness quantification context.

Bear in mind that \( \exists! x, y\colon p\, x \, y \) is not the same as \( \exists! x \colon \exists! y \colon p \, x \, y \).

For example, \( \exists! x \colon \exists! y \colon |x| = |y| \) is true (it holds only when \(x=y=0\)), but \( \exists! x, y \colon |x| = |y| \) is false (there are many such pairs).

As is customary in mathematics, ``existsUnique` $ \x y -> p x y` is equivalent to ``existsUnique` $ \(x, y) -> p x y` and not to ``existsUnique` $ \x -> `existsUnique` $ \y -> p x y` (the latter, of course, may be explicitly written when desired).

That is, all the variables affected by the same uniqueness context are quantified simultaneously as a tuple.

Since: smallcheck-1.0

changeDepth :: forall (m :: Type -> Type) a. Testable m a => (Depth -> Depth) -> a -> Property m Source #

Run property with a modified depth. Affects all quantified variables in the property.

Since: smallcheck-1.0

changeDepth1 :: forall a (m :: Type -> Type) b. (Show a, Serial m a, Testable m b) => (Depth -> Depth) -> (a -> b) -> Property m Source #

Quantify the function's argument over its `series`, but adjust the depth. This doesn't affect any subsequent variables.

Since: smallcheck-1.0

# Orphan instances

IsTest (Property IO) Source # |
Instance details Methods run :: OptionSet -> Property IO -> (Progress -> IO ()) -> IO Result Source # testOptions :: Tagged (Property IO) [OptionDescription] Source #