Skip to content

Commit

Permalink
Improvements in auto test
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Smet committed Oct 19, 2023
1 parent 123baa3 commit ea48239
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions src/sicp/chapter_1/part_1/ex_1_6.clj
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
(defn sqrt-iter
[guess x]
(if (good-enough? guess x)
guess
(sqrt-iter (improve guess x) x)))
guess
(sqrt-iter (improve guess x) x)))

(defn sqrt-iter-new-if
[guess x]
(new-if (good-enough? guess x)
guess
(sqrt-iter (improve guess x) x)))
guess
(sqrt-iter (improve guess x) x)))

; What happens when Alyssa attempts to use this to compute square roots? Explain.
4 changes: 2 additions & 2 deletions src/sicp/chapter_1/part_2/ex_1_9.clj
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
[a b]
(if (= a 0)
b
(inc (+ (dec a) b)))) ; linear recursive
(inc (+ (dec a) b)))) ; linear recursive

(defn plus-v2
[a b]
(if (= a 0)
b
(+ (dec a) (inc b)))) ; linear iteration
(+ (dec a) (inc b)))) ; linear iteration

; Using the substitution model, illustrate the process generated by each procedure in evaluating (+ 4 5).
; Are these processes iterative or recursive?
2 changes: 1 addition & 1 deletion test/sicp/chapter_1/part_1/ex_1_5_test.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns sicp.chapter-1.part_1.ex-1-5-test
(:require [clojure.test :refer [deftest is]]
[sicp.chapter-1.part_1.ex-1-5 :refer [test_1_5 p]]))
[sicp.chapter-1.part_1.ex-1-5 :refer [p test_1_5]]))

(deftest test_1_5-test
; Normal: Operand "p" will not be evaluated until it's needed by some primitive operation. So result is 0.
Expand Down
4 changes: 2 additions & 2 deletions test/sicp/chapter_1/part_2/ex_1_18_test.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns sicp.chapter-1.part_2.ex-1-18-test
(:require [clojure.test :refer [deftest is]])
(:require [sicp.chapter-1.part_2.ex-1-18 :refer [mult]]))
(:require [clojure.test :refer [deftest is]]
[sicp.chapter-1.part_2.ex-1-18 :refer [mult]]))

(deftest mult-test
(is (= 0 (mult 0 19))))
4 changes: 2 additions & 2 deletions test/sicp/chapter_1/part_2/ex_1_20_test.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns sicp.chapter-1.part_2.ex-1-20-test
(:require [clojure.test :refer [deftest is]])
(:require [sicp.chapter-1.part_2.ex-1-20 :refer [gcd]]))
(:require [clojure.test :refer [deftest is]]
[sicp.chapter-1.part_2.ex-1-20 :refer [gcd]]))

(deftest gcd-test
(is (= 2 (gcd 206 40))) ; 4 times
Expand Down
4 changes: 2 additions & 2 deletions test/sicp/chapter_1/part_2/ex_1_21_test.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns sicp.chapter-1.part_2.ex-1-21-test
(:require [clojure.test :refer [deftest is]])
(:require [sicp.chapter-1.part_2.ex-1-21 :refer [smallest-divisor]]))
(:require [clojure.test :refer [deftest is]]
[sicp.chapter-1.part_2.ex-1-21 :refer [smallest-divisor]]))

(deftest smallest-divisor-test
(is (= 199 (smallest-divisor 199)))
Expand Down
4 changes: 2 additions & 2 deletions test/sicp/chapter_1/part_2/ex_1_22_test.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns sicp.chapter-1.part_2.ex-1-22-test
(:require [clojure.test :refer [deftest is]])
(:require [sicp.chapter-1.part_2.ex-1-22 :refer [find-primes]]))
(:require [clojure.test :refer [deftest is]]
[sicp.chapter-1.part_2.ex-1-22 :refer [find-primes]]))

(deftest find-primes-test
(is (= 5 (find-primes 1 5)))) ; Change arguments and see the output

0 comments on commit ea48239

Please sign in to comment.