From 6ed861350752ccb6f5bfbf8610207d99e5e8eacf Mon Sep 17 00:00:00 2001 From: Ramakrishnan Muthukrishnan Date: Wed, 5 May 2010 19:46:51 +0530 Subject: [PATCH] fixed some unit tests --- src/sicp/ex1_31.clj | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/sicp/ex1_31.clj b/src/sicp/ex1_31.clj index a1c8dd7..6878fde 100644 --- a/src/sicp/ex1_31.clj +++ b/src/sicp/ex1_31.clj @@ -20,16 +20,18 @@ (prod identity 1 inc n)) (deftest test-factorial-of-6 - (is (factorial 6) 720)) + (is (= (factorial 6) + (reduce * (range 1 7))))) (deftest test-factorial-of-10 - (is (factorial 10) 3628800)) + (is (= (factorial 10) + (reduce * (range 1 11))))) (defn prod-pi [a b] (prod #(/ (* % (+ % 2)) (square (+ % 1.0))) a #(+ % 2) b)) (deftest test-pi-2-digits-accuracy - (is (> (Math/abs (- 3.14159 (* 4 (prod-pi 2 1000)))) 0.001) true)) + (is (= (> (Math/abs (- 3.14159 (* 4 (prod-pi 2 1000)))) 0.001) true))) (defn iter-prod [term a next b result] (if (> a b) @@ -40,4 +42,5 @@ (iter-prod term a next b 1)) (deftest test-iprod-for-prod-of-1-to-10 - (is (iprod identity 1 inc 10) (prod identity 1 inc 10))) + (is (= (iprod identity 1 inc 10) + (prod identity 1 inc 10)))) -- 2.45.2