Add test for #6.
[packages/parsec.git] / test / Bugs / Bug6.hs
1
2 module Bugs.Bug6
3 ( main
4 ) where
5
6 import Test.HUnit hiding ( Test )
7 import Test.Framework
8 import Test.Framework.Providers.HUnit
9
10 import Text.Parsec
11 import Text.Parsec.String
12 import qualified Text.Parsec.Token as P
13 import Text.Parsec.Language (haskellDef)
14
15 import Util
16
17 main :: Test
18 main =
19 testCase "Look-ahead preserving error location (#6)" $
20 parseErrors variable "return" @?= ["'return' is a reserved keyword"]
21
22 variable :: Parser String
23 variable = do
24 x <- lookAhead (many1 letter)
25 if x == "return"
26 then fail "'return' is a reserved keyword"
27 else string x