diff options
| author | Arnaud Bailly <arnaud@pankzsoft.com> | 2025-10-27 16:35:06 +0100 |
|---|---|---|
| committer | Arnaud Bailly <arnaud@pankzsoft.com> | 2025-10-27 16:35:06 +0100 |
| commit | b899a23e2db86a0a12c5de9ee82588819c1caf89 (patch) | |
| tree | 6bc96098e24f6284ad41761c9d7a0e7c971e2a79 /lambda-calcul/haskell/test/Minilang/Lambda/EvalSpec.hs | |
| parent | 46d94d86705a7fd0a7c5d0d7c6a74f11669641ca (diff) | |
| download | lambda-nantes-b899a23e2db86a0a12c5de9ee82588819c1caf89.tar.gz | |
Fix evaluation with environment by introducing Value
Diffstat (limited to 'lambda-calcul/haskell/test/Minilang/Lambda/EvalSpec.hs')
| -rw-r--r-- | lambda-calcul/haskell/test/Minilang/Lambda/EvalSpec.hs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lambda-calcul/haskell/test/Minilang/Lambda/EvalSpec.hs b/lambda-calcul/haskell/test/Minilang/Lambda/EvalSpec.hs index 11cf394..718b46d 100644 --- a/lambda-calcul/haskell/test/Minilang/Lambda/EvalSpec.hs +++ b/lambda-calcul/haskell/test/Minilang/Lambda/EvalSpec.hs @@ -2,7 +2,7 @@ module Minilang.Lambda.EvalSpec (spec) where import Control.Concurrent (threadDelay) import Control.Concurrent.Async (race_) -import Minilang.Lambda.Eval (Term (..), eval, evalNeed) +import Minilang.Lambda.Eval (Term (..), Value (..), eval, evalNeed) import Test.Hspec (Spec, describe, it, shouldBe) spec :: Spec @@ -21,31 +21,31 @@ spec = do describe "call-by-value eval" $ do it "evaluates 'x' as itself" $ do let term = Var "x" - eval term [] `shouldBe` Var "x" + eval term [] `shouldBe` V "x" it "evaluates '((λ x. x) y)' as 'y'" $ do let term = App (Lam "x" (Var "x")) (Var "y") - eval term [] `shouldBe` Var "y" + eval term [] `shouldBe` V "y" it "evaluates '((λ x y. y) z t y)' as '(t y)'" $ do let snd' = Lam "x" (Lam "y" (Var "y")) let term = App (App (App snd' (Var "z")) (Var "t")) (Var "y") - eval term [] `shouldBe` App (Var "t") (Var "y") + eval term [] `shouldBe` Ap (V "t") (V "y") it "evaluates '((λ x y. x) z t)' as 'z'" $ do let term = App (App fst' (Var "z")) (Var "t") - eval term [] `shouldBe` Var "z" + eval term [] `shouldBe` V "z" it "diverges on evaluating argument bound to ω" $ shouldDiverge $ eval term [] describe "call-by-need eval" $ do it "evaluates 'x' as itself" $ do - evalNeed (Var "x") [] `shouldBe` Var "x" + evalNeed (Var "x") [] `shouldBe` V "x" it "evaluates '(λ x y . y) ⊥ z' as 'z'" $ do - evalNeed term [] `shouldBe` Var "z" + evalNeed term [] `shouldBe` V "z" it "diverges on evaluating ω" $ shouldDiverge $ evalNeed omega [] -shouldDiverge :: Term -> IO () +shouldDiverge :: Value -> IO () shouldDiverge t = race_ (t `seq` fail "Did not diverge") |
