From 580a47f400428a959d48ef6fa8938f43231b80de Mon Sep 17 00:00:00 2001 From: Ramakrishnan Muthukrishnan Date: Thu, 27 May 2010 20:19:05 +0530 Subject: [PATCH] added a few tests --- src/sicp/ex1_42.clj | 16 ++++++++++++---- src/sicp/ex1_43.clj | 7 +++++++ 2 files changed, 19 insertions(+), 4 deletions(-) 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))) -- 2.45.2