hspec-core-2.11.16: A Testing Framework for Haskell

Safe Haskell | None
Language | Haskell2010

Test.Hspec.Core.Extension.Item

Contents

- Types
- Operations

Description

Warning: This API is experimental.

Synopsis

- data Item a = Item {
  - itemRequirement :: String
  - itemLocation :: Maybe Location
  - itemIsParallelizable :: Maybe Bool
  - itemIsFocused :: Bool
  - itemAnnotations :: Annotations
  - itemExample :: Params -> (ActionWith a -> IO ()) -> ProgressCallback -> IO Result
  }
- data Location = Location {
  - locationFile :: FilePath
  - locationLine :: Int
  - locationColumn :: Int
  }
- data Params = Params {
  - paramsQuickCheckArgs :: Args
  - paramsSmallCheckDepth :: Maybe Int
  }
- type ActionWith a = a -> IO ()
- type Progress = (Int, Int)
- type ProgressCallback = Progress -> IO ()
- data Result = Result {
  - resultInfo :: String
  - resultStatus :: ResultStatus
  }
- data ResultStatus
  - = Success
  - | Pending (Maybe Location) (Maybe String)
  - | Failure (Maybe Location) FailureReason
- data FailureReason
  - = NoReason
  - | Reason String
  - | ColorizedReason String
  - | ExpectedButGot (Maybe String) String String
  - | Error (Maybe String) SomeException
- isFocused :: Item a -> Bool
- pending :: Item a -> Item a
- pendingWith :: String -> Item a -> Item a
- setAnnotation :: Typeable value => value -> Item a -> Item a
- getAnnotation :: Typeable value => Item a -> Maybe value

# Types

data Item a Source #

`Item` is used to represent spec items internally. A spec item consists of:

- a textual description of a desired behavior
- an example for that behavior
- additional meta information

Everything that is an instance of the `Example` type class can be used as an example, including QuickCheck properties, Hspec expectations and HUnit assertions.

Constructors

Item |

Fields

- itemRequirement :: String

  Textual description of behavior

- itemLocation :: Maybe Location

  Source location of the spec item

- itemIsParallelizable :: Maybe Bool

  A flag that indicates whether it is safe to evaluate this spec item in parallel with other spec items

- itemIsFocused :: Bool

  A flag that indicates whether this spec item is focused

- itemAnnotations :: Annotations

  Arbitrary additional data that can be used by third-party extensions.

  Since: 2.12.0

- itemExample :: Params -> (ActionWith a -> IO ()) -> ProgressCallback -> IO Result

  Example for behavior

data Location Source #

`Location` is used to represent source locations.

Constructors

Location |

Fields

- locationFile :: FilePath
- locationLine :: Int
- locationColumn :: Int

#### Instances

Instances details

Read Location Source # |
Instance details Defined in Test.Hspec.Core.Example.Location Methods readsPrec :: Int -> ReadS Location Source # readList :: ReadS [Location] Source # readPrec :: ReadPrec Location Source # readListPrec :: ReadPrec [Location] Source #
Show Location Source # |
Instance details Defined in Test.Hspec.Core.Example.Location Methods showsPrec :: Int -> Location -> ShowS Source # show :: Location -> String Source # showList :: [Location] -> ShowS Source #
Eq Location Source # |
Instance details Defined in Test.Hspec.Core.Example.Location Methods (==) :: Location -> Location -> Bool Source # (/=) :: Location -> Location -> Bool Source #

data Params Source #

QuickCheck and SmallCheck related parameters.

Constructors

Params |

Fields

- paramsQuickCheckArgs :: Args
- paramsSmallCheckDepth :: Maybe Int

#### Instances

Instances details

Show Params Source # |
Instance details Defined in Test.Hspec.Core.Example Methods showsPrec :: Int -> Params -> ShowS Source # show :: Params -> String Source # showList :: [Params] -> ShowS Source #

type ActionWith a = a -> IO () Source #

An `IO` action that expects an argument of type `a`.

This type is what `Example`s are ultimately unlifted into for execution.

type Progress = (Int, Int) Source #

`(CurrentItem, TotalItems)` tuple.

type ProgressCallback = Progress -> IO () Source #

Callback used by composite test items that contain many tests to report their progress towards finishing them all.

This is used, for example, to report how many QuickCheck examples are finished.

data Result Source #

The result of running an example

Constructors

Result |

Fields

- resultInfo :: String
- resultStatus :: ResultStatus

#### Instances

Instances details

Show Result Source # |
Instance details Defined in Test.Hspec.Core.Example Methods showsPrec :: Int -> Result -> ShowS Source # show :: Result -> String Source # showList :: [Result] -> ShowS Source #
Example Result Source # |

Instance details

Defined in Test.Hspec.Core.Example

Associated Types

type Arg Result |
Instance details Defined in Test.Hspec.Core.Example type Arg Result = ()

Methods

evaluateExample :: Result -> Params -> (ActionWith (Arg Result) -> IO ()) -> ProgressCallback -> IO Result Source #

Example (a -> Result) Source # |

Instance details

Defined in Test.Hspec.Core.Example

Associated Types

type Arg (a -> Result) |
Instance details Defined in Test.Hspec.Core.Example type Arg (a -> Result) = a

Methods

evaluateExample :: (a -> Result) -> Params -> (ActionWith (Arg (a -> Result)) -> IO ()) -> ProgressCallback -> IO Result Source #

type Arg Result Source # |
Instance details Defined in Test.Hspec.Core.Example type Arg Result = ()
type Arg (a -> Result) Source # |
Instance details Defined in Test.Hspec.Core.Example type Arg (a -> Result) = a

data ResultStatus Source #

Constructors

Success |
Pending (Maybe Location) (Maybe String) |
Failure (Maybe Location) FailureReason |

#### Instances

Instances details

Exception ResultStatus Source # |
Instance details Defined in Test.Hspec.Core.Example Methods toException :: ResultStatus -> SomeException Source # fromException :: SomeException -> Maybe ResultStatus Source # displayException :: ResultStatus -> String Source # backtraceDesired :: ResultStatus -> Bool Source #
Show ResultStatus Source # |
Instance details Defined in Test.Hspec.Core.Example Methods showsPrec :: Int -> ResultStatus -> ShowS Source # show :: ResultStatus -> String Source # showList :: [ResultStatus] -> ShowS Source #

data FailureReason Source #

Constructors

NoReason |
Reason String |
ColorizedReason String |
ExpectedButGot (Maybe String) String String |
Error (Maybe String) SomeException |

#### Instances

Instances details

NFData FailureReason Source # |
Instance details Defined in Test.Hspec.Core.Example Methods rnf :: FailureReason -> () Source #
Show FailureReason Source # |
Instance details Defined in Test.Hspec.Core.Example Methods showsPrec :: Int -> FailureReason -> ShowS Source # show :: FailureReason -> String Source # showList :: [FailureReason] -> ShowS Source #

# Operations

isFocused :: Item a -> Bool Source #

pending :: Item a -> Item a Source #

pendingWith :: String -> Item a -> Item a Source #

setAnnotation :: Typeable value => value -> Item a -> Item a Source #

getAnnotation :: Typeable value => Item a -> Maybe value Source #