GitXplorerGitXplorer
a

hspec-attoparsec

public
14 stars
3 forks
0 issues

Commits

List of commits on branch master.
Unverified
c15edddb0653c72a040c7b697acdf6e2e5cd0298

bump version

aalpmestan committed 10 years ago
Unverified
f17dce617089ff463f341bb1c0c7bb43e6d032ba

Merge pull request #2 from solatis/master

aalpmestan committed 10 years ago
Unverified
c8bc69eef55a31a744d153c4592e96f8506a1eb9

Fixes build error

ssolatis committed 10 years ago
Unverified
a517ff9ca596a884842f62b8ddf2cc3a7994ec56

Fixes previous build error

ssolatis committed 10 years ago
Unverified
42eaaaf9bff1ca7df2a11b6c49f15d18799342e1

Got positioning of cabal update wrong

ssolatis committed 10 years ago
Unverified
df577510886611546c8f3293b74d0f8a414fd3a0

Removes duplicate script

ssolatis committed 10 years ago

README

The README file for this repository.

hspec-attoparsec

Build Status

This (small) package provides handy functions for testing attoparsec parsers with hspec.

To see it in action, what better way is there than looking at hspec-attoparsec's own test suite!

{-# LANGUAGE OverloadedStrings #-}
module Test.Hspec.AttoparsecSpec where

import Control.Applicative
import Data.Attoparsec.Text
import Data.Text
import Test.Hspec
import Test.Hspec.Attoparsec

main :: IO ()
main = hspec spec

spec :: Spec
spec = do
  describe "shouldParse" $
    it "works on: \"x\" ~> char 'x'" $
      ("x" :: Text) ~> char 'x'
        `shouldParse` 'x'

  describe "parseSatisfies" $ do
    it "works on: \"x\" and (=='x')" $
      ("x" :: Text) ~> char 'x'
        `parseSatisfies` (=='x')

    it "\">>>\" satisfies length == 3 when parser as a list of char" $
      (">>>" :: Text) ~> many (char '>')
        `parseSatisfies` ((==3) . Prelude.length)

  describe "shouldFailOn" $
    it "char 'x' fails on \"ha\"" $
      char 'x' `shouldFailOn` ("ha" :: Text)

  describe "shouldSucceedOn" $
    it "char 'x' succeeds on \"x\"" $
      char 'x' `shouldSucceedOn` ("x" :: Text)

  describe "leavesUnconsumed" $
    it "works on \"xa\" ~?> char 'x'" $
      ("xa" :: Text) ~?> char 'x'
        `leavesUnconsumed` "a"

    it "char 'x' leaves nothing unconsumed on \"x\"" $
      ("x" :: Text) ~?> char 'x'
        `leavesUnconsumed` ""