Fakultas Ilmu Komputer UI
Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Ari Angga Nugraha
ariangganugraha-funpro2020-lambda
Commits
6cc049ac
Commit
6cc049ac
authored
Dec 31, 2016
by
Sean Gillespie
Browse files
Refactor based on static analysis
parent
dbc536ac
Changes
2
Hide whitespace changes
Inline
Side-by-side
test/Language/Lambda/EvalSpec.hs
View file @
6cc049ac
...
...
@@ -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"
]
test/Language/LambdaSpec.hs
View file @
6cc049ac
...
...
@@ -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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment