-
Notifications
You must be signed in to change notification settings - Fork 36
/
test-simple-interp.scm
48 lines (45 loc) · 1.48 KB
/
test-simple-interp.scm
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
36
37
38
39
40
41
42
43
44
45
46
47
48
(test "running backwards"
(run 5 (q) (evalo q '(closure y x ((x . (closure z z ()))))))
'(((lambda (x) (lambda (y) x)) (lambda (z) z))
((lambda (x) (x (lambda (y) x))) (lambda (z) z))
(((lambda (x) (lambda (y) x))
((lambda (_.0) _.0) (lambda (z) z)))
(sym _.0))
(((lambda (_.0) _.0)
((lambda (x) (lambda (y) x)) (lambda (z) z)))
(sym _.0))
((((lambda (_.0) _.0) (lambda (x) (lambda (y) x)))
(lambda (z) z))
(sym _.0))))
(test "eval-exp-lc 1"
(run* (q) (evalo '(((lambda (x) (lambda (y) x)) (lambda (z) z)) (lambda (a) a)) q))
'((closure z z ())))
(test "eval-exp-lc 2"
(run* (q) (evalo '((lambda (x) (lambda (y) x)) (lambda (z) z)) q))
'((closure y x ((x . (closure z z ()))))))
(test "fully-running-backwards"
(run 5 (q)
(fresh (e v)
(evalo e v)
(== `(,e ==> ,v) q)))
'((((lambda (_.0) _.1)
==> (closure _.0 _.1 ())) (sym _.0))
((((lambda (_.0) _.0) (lambda (_.1) _.2))
==>
(closure _.1 _.2 ()))
(sym _.0 _.1))
((((lambda (_.0) (lambda (_.1) _.2)) (lambda (_.3) _.4))
==>
(closure _.1 _.2 ((_.0 . (closure _.3 _.4 ())))))
(=/= ((_.0 lambda)))
(sym _.0 _.1 _.3))
((((lambda (_.0) (_.0 _.0)) (lambda (_.1) _.1))
==>
(closure _.1 _.1 ()))
(sym _.0 _.1))
((((lambda (_.0) (_.0 _.0))
(lambda (_.1) (lambda (_.2) _.3)))
==>
(closure _.2 _.3 ((_.1 . (closure _.1 (lambda (_.2) _.3) ())))))
(=/= ((_.1 lambda)))
(sym _.0 _.1 _.2))))