mirror of
https://github.com/mrkkrp/megaparsec.git
synced 2024-12-27 02:02:42 +03:00
fd8ecf5d03
Fixes #2.
29 lines
672 B
Haskell
29 lines
672 B
Haskell
|
|
module Tokens
|
|
( tokensTests
|
|
) where
|
|
|
|
import Test.HUnit hiding ( Test )
|
|
import Test.Framework
|
|
import Test.Framework.Providers.HUnit
|
|
|
|
import Text.Parsec
|
|
import Text.Parsec.String
|
|
import qualified Text.Parsec.Token as P
|
|
import Text.Parsec.Language (haskellDef)
|
|
|
|
tokensTests :: [Test]
|
|
tokensTests =
|
|
return $
|
|
testCase "Control Char Parsing" $
|
|
parseString "\"test\\^Bstring\"" @?= "test\^Bstring"
|
|
|
|
where
|
|
parseString :: String -> String
|
|
parseString input =
|
|
case parse parser "Example" input of
|
|
Left{} -> error "Parse failure"
|
|
Right str -> str
|
|
|
|
parser :: Parser String
|
|
parser = P.stringLiteral $ P.makeTokenParser haskellDef |