-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-heap.scm
64 lines (54 loc) · 1.12 KB
/
test-heap.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
(use-modules (ice-9 format))
#;(use-modules (ice-9 pretty-print))
(load "heap-v1.scm")
(define test-data
'((3 3)
((quote (3 4)) (3 4))
("hello" "hello")
((+ 2 3) 5)
((cons 'a 'b) (a . b))
((let ((x 3)
(y 4)
(z 5))
(set! x (+ x z))
(* x y)) 32)
((let ((x (+ 2 3))
(y (+ 3 4)))
(cons x y)) (5 . 7))
((call/cc (lambda (k)
(begin
(k 5)
(+ 3 4)))) 5)
((lambda (x) x) "#<procedure>")
(((lambda (x) x) 5) 5)
((if #f "true" "false") "false")
((if #t "true" "false") "true")
((if 0 "true" "false") "true")
))
(define test
(lambda (exp res)
(let ((x (go exp)))
(if (equal? x res)
(begin
(format #t "~a -- passed~%" exp)
#t)
(begin
(format #t "~a -- failed~%" exp)
#f)))))
(define test-case
(lambda ()
(let ((tot 0)
(passed 0))
(for-each
(lambda (x)
;(record (exp res) x
(set! tot (+ tot 1))
(if (test (car x) (cadr x))
(set! passed (+ passed 1)))
;)
)
test-data)
(format #t " ---~%passed/total: ~a/~a~%"
passed tot))))
(format #t "ello~%")
(test-case)