Skip to content

Commit

Permalink
Update clj-kondo settings and refactor test file imports
Browse files Browse the repository at this point in the history
The clj-kondo command in the lint task has been updated to run in parallel, setting the fail level as a warning. This amendment should improve performance by running in a non-blocking mode. The clojure.test import usage in the book_2_
  • Loading branch information
Denis Smet committed Feb 11, 2024
1 parent 652cea3 commit 25af23c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 27 deletions.
2 changes: 1 addition & 1 deletion bb.edn
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
(run 'fix:cljstyle))
; Linters
lint:eastwood (shell "clojure -M:test:eastwood")
lint:kondo (shell "clj-kondo --parallel --lint test src")
lint:kondo (shell "clj-kondo --parallel --fail-level warning --lint test src")
; Local development
pre-push (do (run 'fix)
(run 'lint)
Expand Down
47 changes: 21 additions & 26 deletions test/sicp/chapter_2/part_5/book_2_5_test.clj
Original file line number Diff line number Diff line change
@@ -1,38 +1,33 @@
(ns sicp.chapter-2.part-5.book-2-5-test
(:require
[clojure.test :refer [deftest is]]
[sicp.chapter-2.part-5.book-2-5 :refer [add
div
install-rational-package
install-scheme-number-package
make-rational
make-scheme-number
mul
sub]]))
[sicp.chapter-2.part-5.book-2-5 :as b25]))

(install-scheme-number-package)
(install-rational-package)
(deftest install-test
(is (= :done (b25/install-scheme-number-package)))
(is (= :done (b25/install-rational-package)))
(is (= :done (b25/install-complex-package))))

(deftest add-test
(is (= (make-scheme-number 3) (add (make-scheme-number 1) (make-scheme-number 2))))
(is (= (make-scheme-number 4) (add (make-scheme-number 2) (make-scheme-number 2))))
(is (= (make-rational 4 1) (add (make-rational 2 1) (make-rational 2 1))))
(is (= (make-rational 1 1) (add (make-rational 2 3) (make-rational 1 3)))))
(is (= (b25/make-scheme-number 3) (b25/add (b25/make-scheme-number 1) (b25/make-scheme-number 2))))
(is (= (b25/make-scheme-number 4) (b25/add (b25/make-scheme-number 2) (b25/make-scheme-number 2))))
(is (= (b25/make-rational 4 1) (b25/add (b25/make-rational 2 1) (b25/make-rational 2 1))))
(is (= (b25/make-rational 1 1) (b25/add (b25/make-rational 2 3) (b25/make-rational 1 3)))))

(deftest sub-test
(is (= (make-scheme-number 1) (sub (make-scheme-number 4) (make-scheme-number 3))))
(is (= (make-scheme-number -6) (sub (make-scheme-number 4) (make-scheme-number 10))))
(is (= (make-rational 0 1) (sub (make-rational 2 1) (make-rational 2 1))))
(is (= (make-rational 1 3) (sub (make-rational 2 3) (make-rational 1 3)))))
(is (= (b25/make-scheme-number 1) (b25/sub (b25/make-scheme-number 4) (b25/make-scheme-number 3))))
(is (= (b25/make-scheme-number -6) (b25/sub (b25/make-scheme-number 4) (b25/make-scheme-number 10))))
(is (= (b25/make-rational 0 1) (b25/sub (b25/make-rational 2 1) (b25/make-rational 2 1))))
(is (= (b25/make-rational 1 3) (b25/sub (b25/make-rational 2 3) (b25/make-rational 1 3)))))

(deftest mul-test
(is (= (make-scheme-number 12) (mul (make-scheme-number 4) (make-scheme-number 3))))
(is (= (make-scheme-number -40) (mul (make-scheme-number -4) (make-scheme-number 10))))
(is (= (make-rational 4 1) (mul (make-rational 2 1) (make-rational 2 1))))
(is (= (make-rational 2 9) (mul (make-rational 2 3) (make-rational 1 3)))))
(is (= (b25/make-scheme-number 12) (b25/mul (b25/make-scheme-number 4) (b25/make-scheme-number 3))))
(is (= (b25/make-scheme-number -40) (b25/mul (b25/make-scheme-number -4) (b25/make-scheme-number 10))))
(is (= (b25/make-rational 4 1) (b25/mul (b25/make-rational 2 1) (b25/make-rational 2 1))))
(is (= (b25/make-rational 2 9) (b25/mul (b25/make-rational 2 3) (b25/make-rational 1 3)))))

(deftest div-test
(is (= (make-scheme-number 20) (div (make-scheme-number 100) (make-scheme-number 5))))
(is (= (make-scheme-number 1/2) (div (make-scheme-number 3) (make-scheme-number 6))))
(is (= (make-rational 1 1) (div (make-rational 2 1) (make-rational 2 1))))
(is (= (make-rational 2 1) (div (make-rational 2 3) (make-rational 1 3)))))
(is (= (b25/make-scheme-number 20) (b25/div (b25/make-scheme-number 100) (b25/make-scheme-number 5))))
(is (= (b25/make-scheme-number 1/2) (b25/div (b25/make-scheme-number 3) (b25/make-scheme-number 6))))
(is (= (b25/make-rational 1 1) (b25/div (b25/make-rational 2 1) (b25/make-rational 2 1))))
(is (= (b25/make-rational 2 1) (b25/div (b25/make-rational 2 3) (b25/make-rational 1 3)))))

0 comments on commit 25af23c

Please sign in to comment.