summaryrefslogtreecommitdiff
path: root/lambda-calcul/haskell/test/Minilang
diff options
context:
space:
mode:
Diffstat (limited to 'lambda-calcul/haskell/test/Minilang')
-rw-r--r--lambda-calcul/haskell/test/Minilang/Lambda/ParserSpec.hs19
1 files changed, 15 insertions, 4 deletions
diff --git a/lambda-calcul/haskell/test/Minilang/Lambda/ParserSpec.hs b/lambda-calcul/haskell/test/Minilang/Lambda/ParserSpec.hs
index 284c1af..4d6f6e0 100644
--- a/lambda-calcul/haskell/test/Minilang/Lambda/ParserSpec.hs
+++ b/lambda-calcul/haskell/test/Minilang/Lambda/ParserSpec.hs
@@ -1,9 +1,20 @@
module Minilang.Lambda.ParserSpec where
-import Minilang.Lambda.Parser (AST (..), parse)
-import Test.Hspec (Spec, it, parallel, shouldBe)
+import Data.Text (Text, pack)
+import Minilang.Lambda.Parser (AST (..), initialChars, parse, restChars)
+import Test.Hspec (Spec, parallel, shouldBe)
+import Test.Hspec.QuickCheck (prop)
+import Test.QuickCheck (Arbitrary (..), elements, listOf)
spec :: Spec
spec = parallel $ do
- it "parses a variable" $ do
- parse "x" `shouldBe` Right (Sym "x")
+ prop "parses an identifier as a variable" $ \(Identifier ident) ->
+ parse ident `shouldBe` Right (Sym ident)
+
+newtype Identifier = Identifier Text
+ deriving (Eq, Show)
+
+instance Arbitrary Identifier where
+ arbitrary =
+ Identifier . pack
+ <$> ((:) <$> elements initialChars <*> listOf (elements restChars))