-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLFLEEMPTestes.hs
35 lines (26 loc) · 1.04 KB
/
LFLEEMPTestes.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
module LFLEEMPTestes where
import LFLE01EMP
import Test.HUnit
add = DecFuncao "add" ["x","y"] ((Soma (Ref "z"))(Soma (Ref "x")(Ref "y")))
sub = DecFuncao "sub" ["x","y"] ((Subtracao (Ref "z"))(Subtracao (Ref "x")(Ref "y")))
mult = DecFuncao "mult" ["x","y"] ((Multiplicacao (Ref "z"))(Multiplicacao (Ref "x")(Ref "y")))
amb = [add, sub, mult]
apAdd = Aplicacao "add" [(Valor 1), (Valor 2)]
apSub = Aplicacao "sub" [(Valor 1), (Valor 2)]
apMul = Aplicacao "mult" [(Valor 1), (Valor 2)]
let01 = Let "z" (Valor 4)(apAdd)
-- Let "z" (Valor 4)(Aplicacao "apAdd" [(Valor 1), (Valor2)])
let02 = Let "z" (Valor 4)(apSub)
let03 = Let "z" (Valor 4)(apMul)
avAdd = avaliar let01 amb
avSub = avaliar let02 amb
avMul = avaliar let03 amb
-- avaliar (Let "z" (Valor 4)(Aplicacao "apAdd" [(Valor 1), (Valor 2)])) (DecFuncao "add" ["x","y"] (Soma (Ref "z")(Soma (Ref "x")(Ref "y"))))
-- let z = 4
-- in let add x y = z+x+y
-- in add 1 2
-- >9
-- let z = 4
-- in let sub x y = z-(y-x)
-- in sub 2 1
-- >5