Fakultas Ilmu Komputer UI

Commit 6cc049ac authored by Sean Gillespie's avatar Sean Gillespie
Browse files

Refactor based on static analysis

parent dbc536ac
......@@ -33,7 +33,7 @@ spec = do
it "reduces simple applications" $ do
let e1 = Abs "x" (Var "x")
e2 = (Var "y")
e2 = Var "y"
betaReduce' e1 e2 `shouldBe` Var "y"
it "reduces nested abstractions" $ do
......@@ -97,14 +97,14 @@ spec = do
etaConvert expr `shouldBe` expr
describe "freeVarsOf" $ do
it "Returns simple vars" $ do
it "Returns simple vars" $
freeVarsOf (Var "x") `shouldBe` ["x"]
it "Does not return bound vars" $ do
it "Does not return bound vars" $
freeVarsOf (Abs "x" (Var "x")) `shouldBe` []
it "Returns nested simple vars" $ do
it "Returns nested simple vars" $
freeVarsOf (Abs "x" (Var "y")) `shouldBe` ["y"]
it "Returns applied simple vars" $ do
it "Returns applied simple vars" $
freeVarsOf (App (Var "x") (Var "y")) `shouldBe` ["x", "y"]
......@@ -12,19 +12,19 @@ spec = do
evalString "\\x. x" `shouldBe` Right (Abs "x" (Var "x"))
evalString "f y" `shouldBe` Right (App (Var "f") (Var "y"))
it "reduces simple applications" $ do
it "reduces simple applications" $
evalString "(\\x .x) y" `shouldBe` Right (Var "y")
it "reduces applications with nested redexes" $ do
it "reduces applications with nested redexes" $
evalString "(\\f x. f x) (\\y. y)" `shouldBe` Right (Abs "x" (Var "x"))
describe "uniques" $ do
let alphabet = reverse ['a'..'z']
len = length alphabet
it "starts with plain alphabet" $ do
it "starts with plain alphabet" $
take len uniques `shouldBe` map (:[]) alphabet
it "adds index afterwards" $ do
it "adds index afterwards" $
take len (drop len uniques) `shouldBe` map (:['0']) alphabet
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment