packages feed

hunit-rematch-0.1.0.1: Test/Rematch/HUnit.hs

module Test.Rematch.HUnit where
import Test.HUnit(Assertion, assertFailure)
import Control.Rematch
import Control.Rematch.Run

-- |Run a matcher as an HUnit assertion
--
-- Example output:
--
-- @
--Expected: equalTo "a"
--     but: was "b"
-- @
expect :: a -> Matcher a -> Assertion
expect a matcher = case res of
  MatchSuccess -> return ()
  (MatchFailure msg) -> assertFailure msg
  where res = runMatch matcher a