-
Notifications
You must be signed in to change notification settings - Fork 1
/
tests.rkt
77 lines (68 loc) · 1.92 KB
/
tests.rkt
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
65
66
67
68
69
70
71
72
73
74
75
76
77
#lang racket
(require rackunit
rackunit/text-ui)
(require "x-macro.rkt"
"xmainpe.rkt"
"xctmw.rkt"
"xctmwrl.rkt"
"xsepsd.rkt"
"xpiu.rkt"
"xpcd.rkt"
"x-misc.rkt"
"xcgr.rkt"
"xar.rkt"
"xcgr.rkt"
"xensg.rkt")
; Source program on Scheme with EXtensions
(define prog-sex
'((define (test1 x)
(rcall (test2 x)))
(define (test2 x)
(generalize x))))
; simple sex->rkt test: 'generalize' and 'rcall' should be removed from prog
(check-equal? (map ux:macroexpand prog-sex)
'((define (test1 x)
(test2 x))
(define (test2 x)
x)))
(define prog-zip
'((define (start x y)
(zipper x y))
(define (zipper x y)
(cond ((null? x) y)
((null? y) x)
(else
`(,(car x) ,(car y) . ,(zipper (cdr x) (cdr y))))))))
(define zip-mw
(uctmwrl:cut-let-prog
(uctmwrl:rem-let-prog
(uctmw:compile-program prog-zip))))
(define zip-ann
(mpairs->pairs*
(upcd:prevent-call-duplication!
(upiu:prevent-infinite-unfolding!
(usepsd:unmix-static-and-dynamic zip-mw '(s d))))))
(define zip123-mw
(let ([o-port (open-output-string "")])
(umainpe:generate-residual-program* o-port zip-ann '((1111 2222 3333)))
(read (open-input-string (get-output-string o-port)))))
(define zip123
(uensg:main "zip" "zip"
(ucgr:main "zip" "zip"
(uar:main "zip" "zip" (ucgr:main "zip" "zip" (list zip123-mw))))))
(check-equal?
(car zip123)
'(define (start-$1 y)
(if (null? y)
'(1111 2222 3333)
`(1111
,(car y)
unquote
(if (null? (cdr y))
'(2222 3333)
`(2222
,(cadr y)
unquote
(if (null? (cddr y))
'(3333)
`(3333 ,(caddr y) unquote (cdddr y)))))))))