more tests

This commit is contained in:
Danny Yoo 2011-03-19 19:40:12 -04:00
parent 3aa643720a
commit 948cd65dad
2 changed files with 41 additions and 2 deletions

View File

@ -279,7 +279,7 @@
[body (let-body exp)])
(cond
[(= 0 (length vars))
(parse `(begin ,@body))]
(parse `(begin ,@body) cenv)]
[(= 1 (length vars))
(make-Let1 (parse (car rhss) (extend-lexical-environment/placeholders cenv 1))
(parse `(begin ,@body)
@ -289,7 +289,7 @@
(make-Let (length vars)
(map (lambda (rhs) (parse rhs rhs-cenv)) rhss)
(parse `(begin ,@body)
(extend-lexical-environment/names vars))))])))
(extend-lexical-environment/names cenv vars))))])))
(define (parse-letrec exp cenv)
(let ([vars (let-variables exp)]

View File

@ -192,3 +192,42 @@
(make-LocalRef 5)))
(make-LocalRef 3)))
(list (make-EnvWholePrefixReference 0)))))
(test (parse '(let ()
x))
(make-Top (make-Prefix '(x))
(make-ToplevelRef 0 0)))
(test (parse '(let ([x 3])
x))
(make-Top (make-Prefix '())
(make-Let1 (make-Constant 3)
(make-LocalRef 0))))
(test (parse '(let ([x 3]
[y 4])
x
y))
(make-Top (make-Prefix '())
(make-Let 2
(list (make-Constant 3)
(make-Constant 4))
(make-Seq (list (make-LocalRef 0)
(make-LocalRef 1))))))
(test (parse '(let ([x 3]
[y 4])
(let ([x y]
[y x])
x
y)))
(make-Top (make-Prefix '())
(make-Let 2
(list (make-Constant 3) (make-Constant 4))
(make-Let 2
(list (make-LocalRef 3)
(make-LocalRef 2))
(make-Seq (list (make-LocalRef 0)
(make-LocalRef 1)))))))