basic substitution implemented
This commit is contained in:
parent
f64bf8be2b
commit
fee6a0e4a3
2 changed files with 27 additions and 4 deletions
|
|
@ -1,8 +1,19 @@
|
|||
module EvaluationSpec (spec) where
|
||||
|
||||
import Evaluation (subst)
|
||||
import Parser (Expr (Abstraction, Application, Variable))
|
||||
import Test.Hspec
|
||||
|
||||
spec :: Spec
|
||||
spec = do
|
||||
describe "Evaluation" $ do
|
||||
it "can evaluation expressions" $
|
||||
True `shouldBe` True
|
||||
describe "subst" $ do
|
||||
it "cannot substitute mismatched variables" $
|
||||
subst (Variable "x") "y" (Variable "z") `shouldBe` Variable "x"
|
||||
it "can substitute matched variables" $
|
||||
subst (Variable "x") "x" (Variable "z") `shouldBe` Variable "z"
|
||||
it "can substitute nested variables" $
|
||||
subst absWithZ "z" absI `shouldNotBe` absWithZMaker absI
|
||||
where
|
||||
absWithZMaker z = Abstraction "x" (Application z (Variable "x"))
|
||||
absWithZ = absWithZMaker (Variable "z")
|
||||
absI = Abstraction "i" (Variable "i")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue