diff options
Diffstat (limited to 'csc/cps-test.csc')
| -rw-r--r-- | csc/cps-test.csc | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/csc/cps-test.csc b/csc/cps-test.csc index ea1d177..d51d10c 100644 --- a/csc/cps-test.csc +++ b/csc/cps-test.csc @@ -6,6 +6,9 @@ make-constant make-define-syntax make-if + make-lambda + make-lambda-case + make-letrec make-lexical-ref make-lexical-set make-library-ref @@ -15,9 +18,11 @@ make-atom make-branch make-call-closure + make-closure make-kargs make-klabel make-ktail + make-lambda-args make-update) (only (csc loop) loop @@ -130,3 +135,57 @@ (cons 2 (make-klabel (make-atom (make-constant 2) 1)))) (soup->alist (ir1->ir2 (make-sequence (make-constant 1) (make-constant 2)))))) + + +(test closure + (assert-equal soup=? + (list + (cons 0 (make-klabel + (make-closure + (list (make-lambda-args 2 #t 3)) + 1))) + (cons 1 (make-ktail)) + (cons 2 (make-ktail)) + (cons 3 (make-kargs (list (make-lexical-ref 'a #f) + (make-lexical-ref 'b #f) + (make-lexical-ref 'c #f)) + (make-atom (make-constant 5) 2)))) + (soup->alist (ir1->ir2 (make-lambda + (make-lambda-case + '(a b) + 'c + '(#f #f #f) + (make-constant 5) + #f)))))) + + +(test letrec-to-lambda + (assert-equal soup=? + (list + ; God help you when it's time to debug this test. + (cons 0 (make-klabel + (make-closure + (list + (make-lambda-args 1 #f 7)) + 3))) + (cons 1 (make-ktail)) + (cons 2 (make-kargs (list (make-lexical-ref 'generated-symbol #f)) + (make-call-closure + (make-lexical-ref 'generated-symbol #f) + (list (make-lexical-ref 'generated-symbol #f)) + 1))) + (cons 3 (make-kargs (list (make-lexical-ref 'generated-symbol #f)) + (make-atom (make-constant #f) 2))) + (cons 4 (make-ktail)) + (cons 5 (make-klabel + (make-atom (make-constant 2) 4))) + (cons 6 (make-kargs (list (make-lexical-ref 'generated-symbol #f)) + (make-update (make-lexical-ref 'a #f) (make-lexical-ref 'generated-symbol #f) 5))) + (cons 7 (make-kargs (list (make-lexical-ref 'a #f)) + (make-atom (make-constant 1) 6)))) + (soup->alist (ir1->ir2 (make-letrec + #t + '(a) + '(#f) + (list (make-constant 1)) + (make-constant 2)))))) |
