From: Ramakrishnan Muthukrishnan Date: Thu, 27 May 2010 14:49:05 +0000 (+0530) Subject: added a few tests X-Git-Url: https://git.rkrishnan.org/vdrive/%5B/%5D%20/uri//%22news.html/%22?a=commitdiff_plain;h=580a47f400428a959d48ef6fa8938f43231b80de;p=sicp.git added a few tests --- diff --git a/src/sicp/ex1_42.clj b/src/sicp/ex1_42.clj index 1c0eef8..b11ca23 100644 --- a/src/sicp/ex1_42.clj +++ b/src/sicp/ex1_42.clj @@ -6,9 +6,17 @@ (defn compose [f g] (fn [x] (f (g x)))) + +(deftest test-compose-square-of-inc-of-6 + (is (= ((compose square inc) 6) + 49))) + +(deftest test-compose-square-of-square-of-2 + (is (= ((compose square square) 2) + 16))) + (comment -((compose square inc) 6) -;;=> 49 -((compose square square) 2) -;;=> 16 +;; from repl do + (use 'sicp.ex1_42 :reload) + (run-tests 'sicp.ex1_42) ) \ No newline at end of file diff --git a/src/sicp/ex1_43.clj b/src/sicp/ex1_43.clj index f7cb7ff..c13f25b 100644 --- a/src/sicp/ex1_43.clj +++ b/src/sicp/ex1_43.clj @@ -12,3 +12,10 @@ (defn repeated [f n] (repeated-1 f (compose f f) (- n 1))) +(deftest test-repeated-square-twotimes-of-5 + (is (= ((repeated square 2) 5) + 625))) + +(deftest test-repeated-square-twotimes-of-2 + (is (= ((repeated square 2) 2) + 16)))