summaryrefslogtreecommitdiff
path: root/lambda-calcul/haskell/test/Minilang/Lambda/DeBruijnSpec.hs
blob: ef8903c4ba1c6d0e756cf674988778b11d59b0f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
module Minilang.Lambda.DeBruijnSpec where

import Minilang.Lambda.DeBruijn (DeBruijn (..), eval, toDeBruijn)
import qualified Minilang.Lambda.Eval as Eval
import Test.Hspec (Spec, it, shouldBe)

spec :: Spec
spec = do
  it "convert term to deBruijn representation" $ do
    let term = Eval.Lam "x" (Eval.Lam "y" (Eval.Var "x"))
        deBruijn = toDeBruijn term

    deBruijn `shouldBe` Lam (Lam (Var 1))

  it "evaluates deBruijn term" $ do
    let term = App (App (Lam (Lam (Var 1))) (Var 12)) (Var 34)

    eval term `shouldBe` Var 12