From: Ramakrishnan Muthukrishnan Date: Wed, 18 Jan 2012 02:11:21 +0000 (+0530) Subject: add a factorial test X-Git-Url: https://git.rkrishnan.org/module-simplejson-index.html?a=commitdiff_plain;h=f5209b8f4c3c6f434c3643f7287e69d237d41f8d;p=sicp.git add a factorial test --- diff --git a/TODO b/TODO index 829d844..ee0aebd 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,7 @@ * Things to do in chapter 2. - Work on 2.91 - 2.97 after working on 3.3.3 - run all the program which uses `get' and `put', after implementing - it in chapter 3. + it in chapter 3. diff --git a/src/sicp/metacircular2-test.rkt b/src/sicp/metacircular2-test.rkt index 91ea502..1644f95 100644 --- a/src/sicp/metacircular2-test.rkt +++ b/src/sicp/metacircular2-test.rkt @@ -71,7 +71,13 @@ b (fib-iter (+ a b) a (- count 1))))) env1) - (check-equal? (eval '(fib 10) env1) 55 "named let")))) + (check-equal? (eval '(fib 10) env1) 55 "named let") + (eval '(define (factorial n) + (if (= n 1) + 1 + (* (factorial (- n 1)) n))) + env1) + (check-equal? (eval '(factorial 10) env1) 3628800 "factorial test")))) (run-tests metacircular2-tests) \ No newline at end of file