Commit ec4013e5 authored by Bastian Kauschke's avatar Bastian Kauschke
Browse files

add tests for Lexer.name

parent 42b6b693
......@@ -16,6 +16,7 @@ spec = do
complexSpec
hexSpec
fractionSpec
nameSpec
spaceSpec :: Spec
spaceSpec = describe "whitespace" $ do
......@@ -163,3 +164,32 @@ fractionSpec = describe "fraction" $ do
it "refuses to parse division by zero" $
p `shouldFailOn` "2 / 0"
nameSpec :: Spec
nameSpec = describe "name" $ do
let p = parse (L.name <* eof) ""
it "parses alphabetic" $ do
p "foo" `shouldParse` "foo"
p "q" `shouldParse` "q"
it "parses underscore" $ do
p "_" `shouldParse` "_"
p "_a_" `shouldParse` "_a_"
it "parses integers" $ do
p "12" `shouldParse` "12"
p "1_a43" `shouldParse` "1_a43"
it "refuses empty" $ do
p `shouldFailOn` ""
it "refuses braces" $ do
p `shouldFailOn` "("
p `shouldFailOn` "{}"
p `shouldFailOn` "[]"
p `shouldFailOn` "]"
it "refuses ambiguous symbols" $ do
p `shouldFailOn` "^"
p `shouldFailOn` ","
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment