From 96cdf5478550693d1e236a53e3390e2d59d59940 Mon Sep 17 00:00:00 2001 From: Ramakrishnan Muthukrishnan <vu3rdd@gmail.com> Date: Mon, 2 Jan 2012 20:44:55 +0530 Subject: [PATCH] test for internal definition and letrec --- src/sicp/metacircular2-test.rkt | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/sicp/metacircular2-test.rkt b/src/sicp/metacircular2-test.rkt index 563b0ec..a4c23ea 100644 --- a/src/sicp/metacircular2-test.rkt +++ b/src/sicp/metacircular2-test.rkt @@ -34,7 +34,35 @@ (* x z)) env1) 39 - "let* test")))) + "let* test") + (eval '(define (f x) + (define (even? n) + (if (= n 0) + true + (odd? (- n 1)))) + (define (odd? n) + (if (= n 0) + false + (even? (- n 1)))) + (odd? x)) + env1) + (check-equal? (eval '(f 2) env1) false "internal definitions") + (check-equal? (eval '(f 3) env1) true "internal definitions") + (eval '(define (f1 x) + (letrec ((even? + (lambda (n) + (if (= n 0) + true + (odd? (- n 1))))) + (odd? + (lambda (n) + (if (= n 0) + false + (even? (- n 1)))))) + (even? x))) + env1) + (check-equal? (eval '(f1 2) env1) true "internal definitions") + (check-equal? (eval '(f1 3) env1) false "internal definitions")))) (run-tests metacircular2-tests) \ No newline at end of file -- 2.45.2