megaparsec/old-tests/Bugs/Bug6.hs
mrkkrp b062a397ee made format of error messages conventional
Closes #56.

In particular, file name and textual position are represented like this:

  filename.hs:5:6:
    error message

This format should be more conventional, so various tools will be able
to parse it and provide some support (for example, Emacs can work with
this format).
2015-10-14 17:48:44 +06:00

24 lines
514 B
Haskell

module Bugs.Bug6 (main) where
import Text.Megaparsec
import Text.Megaparsec.String
import Test.Framework
import Test.Framework.Providers.HUnit
import Test.HUnit hiding (Test)
import Util
main :: Test
main =
testCase "Look-ahead preserving error location (#6)" $
parseErrors variable "return" @?= [" 'return' is a reserved keyword"]
variable :: Parser String
variable = do
x <- lookAhead (some letterChar)
if x == "return"
then fail "'return' is a reserved keyword"
else string x