Created more tests

This commit is contained in:
Julia Schor 2022-01-09 23:12:57 -05:00
parent 65aafdd66d
commit 0428281cd8
3 changed files with 47 additions and 4 deletions

View File

@ -1,9 +1,8 @@
(ns propeller.tools.calculus-test (ns propeller.tools.calculus-test
(:require [clojure.test :as t] (:require [clojure.test :as t]
[propeller.tools.calculus :as c])) [propeller.tools.calculus :as c]))
(t/deftest deriv_test (t/deftest deriv-test
(t/is (letfn [(cubic [x] (let [a (double x)] (* a a a)))] (t/is (letfn [(cubic [x] (let [a (double x)] (* a a a)))]
(< (max (- (c/deriv cubic 2) 12) (- (- (c/deriv cubic 2) 12))) 0.001) (< (max (- (c/deriv cubic 2) 12) (- (- (c/deriv cubic 2) 12))) 0.001)))
)
)
) )

View File

@ -0,0 +1,20 @@
(ns propeller.tools.character-test
(:require [clojure.test :as t]
[propeller.tools.character :as c]))
(t/deftest get-ascii-test
(t/is (= 97 (c/get-ascii (first "abc")))))
(t/deftest is-letter-test
(t/is (c/is-letter (first "abc")))
;(t/is (= false (c/is-letter 97)))
)
(t/deftest is-digit-test
(t/is (c/is-digit (first "545")))
(t/is (c/is-digit (char \5))))
(t/deftest is-whitespace-test
(t/is (c/is-whitespace (char \tab)))
(t/is (c/is-whitespace (first " hello")))
(t/is (c/is-whitespace (char \newline)))
)

View File

@ -0,0 +1,24 @@
(ns propeller.tools.math-test
(:require [clojure.test :as t]
[propeller.tools.math :as m]))
(t/deftest not-lazy-test
(t/is (= 1 (m/abs -1)))
(t/is (= 1 (m/abs 1)))
(t/is (= 0 (m/abs 0))))
(t/deftest approx=-test
(t/is (m/approx= 3 5 2))
(t/is (not (m/approx= 5 3 1.5)))
(t/is (m/approx= -1 -5 9)))
(t/deftest ceil-test
(t/is (= 5.0 (m/ceil 4.9)))
(t/is (= 5.0 (m/ceil 4.5)))
(t/is (= -10.0 (m/ceil -10.5 ))))
(t/deftest cos-test
(t/is (= 1.0 (m/cos 0)))
(t/is (= -1.0 (m/cos (* 3 m/PI)))))
(t/deftest div
(t/is ))