megaparsec-tests-9.0.1: Test utilities and the test suite of Megaparsec
Copyright© 2019–present Megaparsec contributors
LicenseFreeBSD
MaintainerMark Karpov <markkarpov92@gmail.com>
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Test.Hspec.Megaparsec.AdHoc

Description

Ad-hoc helpers used in Megaparsec's test suite.

Synopsis

Types

type Parser = Parsec Void String Source #

The type of parser that consumes a String.

Helpers to run parsers

prs Source #

Arguments

:: Parser a

Parser to run

-> String

Input for the parser

-> Either (ParseErrorBundle String Void) a

Result of parsing

Apply parser to given input. This is a specialized version of parse that assumes empty file name.

prs' Source #

Arguments

:: Parser a

Parser to run

-> String

Input for the parser

-> (State String Void, Either (ParseErrorBundle String Void) a)

Result of parsing

Just like prs, but allows to inspect the final state of the parser.

prs_ Source #

Arguments

:: Parser a

Parser to run

-> String

Input for the parser

-> Either (ParseErrorBundle String Void) a

Result of parsing

Just like prs, but forces the parser to consume all input by adding eof:

prs_ p = parse (p <* eof) ""

grs Source #

Arguments

:: (forall m. MonadParsec Void String m => m a)

Parser to run

-> String

Input for the parser

-> (Either (ParseErrorBundle String Void) a -> Expectation)

How to check result of parsing

-> Expectation 

Just like prs, but interprets given parser as various monads (tries all supported monads transformers in turn).

grs' Source #

Arguments

:: (forall m. MonadParsec Void String m => m a)

Parser to run

-> String

Input for the parser

-> ((State String Void, Either (ParseErrorBundle String Void) a) -> Expectation)

How to check result of parsing

-> Expectation 

grs' to grs is as prs' to prs.

Other

nes :: a -> NonEmpty a Source #

Make a singleton non-empty list from a value.

abcRow :: Int -> Int -> Int -> String Source #

abcRow a b c generates string consisting of character “a” repeated a times, character “b” repeated b times, and character “c” repeated c times.

rightOrder Source #

Arguments

:: Parser String

The parser to test

-> String

Input for the parser

-> String

Expected result

-> Spec 

Check that the given parser returns the list in the right order.

scaleDown :: Gen a -> Gen a Source #

Scale down.

getTabWidth :: MonadParsec e s m => m Pos Source #

Get tab width from PosState. Use with care only for testing.

setTabWidth :: MonadParsec e s m => Pos -> m () Source #

Set tab width in PosState. Use with care only for testing.

strSourcePos :: Pos -> SourcePos -> String -> SourcePos Source #

A helper function that is used to advance SourcePos given a String.

Char and byte conversion

toChar :: Word8 -> Char Source #

Convert a byte to char.

fromChar :: Char -> Maybe Word8 Source #

Covert a char to byte.

Proxies

Orphan instances

Arbitrary Void Source # 
Instance details

Methods

arbitrary :: Gen Void #

shrink :: Void -> [Void] #

Arbitrary ByteString Source # 
Instance details

Arbitrary ByteString Source # 
Instance details

Arbitrary Text Source # 
Instance details

Methods

arbitrary :: Gen Text #

shrink :: Text -> [Text] #

Arbitrary Pos Source # 
Instance details

Methods

arbitrary :: Gen Pos #

shrink :: Pos -> [Pos] #

Arbitrary SourcePos Source # 
Instance details

Arbitrary Text Source # 
Instance details

Methods

arbitrary :: Gen Text #

shrink :: Text -> [Text] #

Arbitrary a => Arbitrary (NonEmpty a) Source # 
Instance details

Methods

arbitrary :: Gen (NonEmpty a) #

shrink :: NonEmpty a -> [NonEmpty a] #

Arbitrary t => Arbitrary (ErrorItem t) Source # 
Instance details

Methods

arbitrary :: Gen (ErrorItem t) #

shrink :: ErrorItem t -> [ErrorItem t] #

Arbitrary (ErrorFancy a) Source # 
Instance details

Arbitrary s => Arbitrary (PosState s) Source # 
Instance details

Methods

arbitrary :: Gen (PosState s) #

shrink :: PosState s -> [PosState s] #

(Arbitrary (Token s), Ord (Token s), Arbitrary e, Ord e) => Arbitrary (ParseError s e) Source # 
Instance details

Methods

arbitrary :: Gen (ParseError s e) #

shrink :: ParseError s e -> [ParseError s e] #

Arbitrary s => Arbitrary (State s e) Source # 
Instance details

Methods

arbitrary :: Gen (State s e) #

shrink :: State s e -> [State s e] #