hspec-expectations-match: An hspec expectation that asserts a value matches a pattern.

[ library, testing ] [ Propose Tags ]

This package provides expectations for use with hspec that use Template Haskell to assert that a value matches a particular pattern. The primary expectation is shouldMatch:

>>> $([|Just True|] `shouldMatch` [p|Just _|])
>>> $([|Nothing|] `shouldMatch` [p|Just _|])

Additionally, any bindings created by the pattern will be returned if the pattern is successfully matched, making it easier to extract the result of some assertion and use it to make further assertions.

>>> $([|Just True|] `shouldMatch` [p|Just x|])
True
>>> $([|[1, 2]|] `shouldMatch` [p|[x, y]|])
(1, 2)

[Skip to Readme]

Modules

[Index]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.1.0, 0.2.0.0
Change log CHANGELOG.md
Dependencies base (>=4.9 && <5), hspec-expectations (>=0.3.2 && <1), template-haskell (>=2.11 && <2.13), transformers-base (<1) [details]
License ISC
Copyright 2017 CJ Affiliate by Conversant
Author Alexis King <lexi.lambda@gmail.com>
Maintainer Alexis King <lexi.lambda@gmail.com>
Category Testing
Home page https://github.com/cjdev/hspec-expectations-match#readme
Bug tracker https://github.com/cjdev/hspec-expectations-match/issues
Source repo head: git clone https://github.com/cjdev/hspec-expectations-match
Uploaded by lexi_lambda at 2017-11-17T18:49:18Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 1869 total (9 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-11-17 [all 1 reports]

Readme for hspec-expectations-match-0.2.0.0

[back to package description]

hspec-expectations-match Build Status

hspec-expectations-match is a Haskell package that provides expectations for use with hspec that use Template Haskell to assert that a value matches a particular pattern. The primary expectation is shouldMatch:

{-# LANGUAGE TemplateHaskell #-}

ghci> $([|Just True|] `shouldMatch` [p|Just _|])
ghci> $([|Nothing|] `shouldMatch` [p|Just _|])
*** Exception: Nothing failed to match pattern (Just x)

Additionally, any bindings created by the pattern will be returned if the pattern is successfully matched, making it easier to extract the result of some assertion and use it to make further assertions.

ghci> $([|Just True|] `shouldMatch` [p|Just x|])
True
ghci> $([|[1, 2]|] `shouldMatch` [p|[x, y]|])
(1, 2)

For more information, see the documentation on Hackage.