hspec-parsec-0: Hspec expectations for testing Parsec parsers

Safe HaskellSafe
LanguageHaskell2010

Test.Hspec.Parsec

Description

Utility functions for testing Parsec parsers with Hspec.

Synopsis

Documentation

shouldParse Source #

Arguments

:: (HasCallStack, Show a, Eq a) 
=> Either ParseError a

Result of parsing as returned by function like parse

-> a

Desired result

-> Expectation 

Create an expectation by saying what the result should be.

parse letter "" "x" `shouldParse` 'x'

shouldFailOn Source #

Arguments

:: (HasCallStack, Show a) 
=> (s -> Either ParseError a)

Parser that takes stream and produces result or error message

-> s

Input that the parser should fail on

-> Expectation 

Check that a parser fails on a given input.

parse (char 'x') "" `shouldFailOn` "a"