summaryrefslogtreecommitdiff
path: root/lambda-calcul/haskell/test
diff options
context:
space:
mode:
authorArnaud Bailly <arnaud@pankzsoft.com>2025-11-05 09:15:46 +0100
committerArnaud Bailly <arnaud@pankzsoft.com>2025-11-05 09:15:46 +0100
commitae59f17cb3d58de7afca7f441d8bcf9a718e024c (patch)
treee1ca429a9a5468f6e69b998eef91bb16727054c7 /lambda-calcul/haskell/test
parent62651f13e08304d8fa6395fde7352984f48adb46 (diff)
downloadlambda-nantes-ae59f17cb3d58de7afca7f441d8bcf9a718e024c.tar.gz
handle defitions in untyped language
Diffstat (limited to 'lambda-calcul/haskell/test')
-rw-r--r--lambda-calcul/haskell/test/Minilang/Lambda/ParserSpec.hs10
-rw-r--r--lambda-calcul/haskell/test/Minilang/REPLSpec.hs11
2 files changed, 16 insertions, 5 deletions
diff --git a/lambda-calcul/haskell/test/Minilang/Lambda/ParserSpec.hs b/lambda-calcul/haskell/test/Minilang/Lambda/ParserSpec.hs
index e7816c6..e6f05b9 100644
--- a/lambda-calcul/haskell/test/Minilang/Lambda/ParserSpec.hs
+++ b/lambda-calcul/haskell/test/Minilang/Lambda/ParserSpec.hs
@@ -98,14 +98,14 @@ spec = parallel $ do
)
`shouldSatisfy` isRight
- it "parses a definition" $ do
- let defStr = "(def id (lam (x) x))"
- expectedAST = Def "id" (Abs ["x"] (Sym "x"))
- parse defStr `shouldBe` Right expectedAST
+ prop "parses a definition" $
+ forAll (genDef 5) $ \ast ->
+ let text = pretty ast
+ in parse text `shouldBe` Right ast
spine :: AST -> Int
spine = \case
- App x y rest -> 1 + spine x + length rest
+ App x _ rest -> 1 + spine x + length rest
_ -> 0
arity :: AST -> Int
diff --git a/lambda-calcul/haskell/test/Minilang/REPLSpec.hs b/lambda-calcul/haskell/test/Minilang/REPLSpec.hs
index cf6ef01..81ac25c 100644
--- a/lambda-calcul/haskell/test/Minilang/REPLSpec.hs
+++ b/lambda-calcul/haskell/test/Minilang/REPLSpec.hs
@@ -23,6 +23,17 @@ spec = parallel $
"y : <?>"
]
+ it "evaluates untyped MiniLang terms with definitions" $ do
+ let out =
+ withInput
+ ["(def id (lam (x) x))", "(id y)"]
+
+ out
+ `shouldBe` [ "Bye!",
+ "y : <?>",
+ "id : <?>"
+ ]
+
it "defaults untyped terms" $ do
let out =
withInput