perga/tests/ExprTests.hs

53 lines
1 KiB
Haskell
Raw Normal View History

2024-11-14 19:56:33 -08:00
module ExprTests (tests) where
import Expr
import Test.HUnit
inner :: Expr
2024-11-14 19:56:33 -08:00
inner = Abs "x" (Var 0 "A") $ App (Var 2 "f") (Var 0 "x")
e1 :: Expr
e1 = Abs "A" Star inner
fFree :: Test
fFree = TestCase $ assertBool "f free" $ occursFree 0 e1
incE1 :: Test
incE1 =
TestCase $
assertEqual
"incIndices e1"
( Abs "A" Star $
Abs "x" (Var 0 "A") $
2024-11-14 19:56:33 -08:00
App (Var 3 "f") (Var 0 "x")
)
(incIndices e1)
after :: Expr
2024-11-14 19:56:33 -08:00
after = Abs "x" (Var 2 "B") $ App (Var 1 "f") (Var 0 "x")
substE1 :: Test
substE1 =
TestCase $
assertEqual
"e1[A := B]"
after
(subst 0 (Var 2 "B") inner)
betaNFe1 :: Test
betaNFe1 =
TestCase $
assertEqual
"e1 B"
after
2024-11-14 19:56:33 -08:00
(betaNF $ App e1 $ Var 2 "B")
tests :: Test
tests =
TestList
[ TestLabel "fFree" fFree
, TestLabel "incE1" incE1
, TestLabel "substE1" substE1
, TestLabel "betaNFe1" betaNFe1
]