diff --git a/deps.edn b/deps.edn index 29f6b7b7..0a30b667 100644 --- a/deps.edn +++ b/deps.edn @@ -135,7 +135,8 @@ com.layerware/hugsql-core {:mvn/version "0.5.3"} com.github.seancorfield/expectations {:mvn/version "2.0.157"} com.rpl/specter {:mvn/version "1.1.4"} - com.github.askonomm/clarktown {:mvn/version "1.1.2"}} + com.github.askonomm/clarktown {:mvn/version "1.1.2"} + org.clojure/math.numeric-tower {:git/tag "math.numeric-tower-0.0.5", :git/sha "12eb9c5", :git/url "https://github.com/clojure/math.numeric-tower"}} :classpath-overrides {org.clojure/clojure nil org.clojure/spec.alpha nil}} :clj-nvd diff --git a/doc/libraries.csv b/doc/libraries.csv index b568ad77..b6d89c55 100644 --- a/doc/libraries.csv +++ b/doc/libraries.csv @@ -74,6 +74,7 @@ org.clojure/data.generators,https://github.com/clojure/data.generators org.clojure/data.json,https://github.com/clojure/data.json org.clojure/data.zip,https://github.com/clojure/data.zip org.clojure/math.combinatorics,https://github.com/clojure/math.combinatorics +org.clojure/math.numeric-tower,https://github.com/clojure/math.numeric-tower org.clojure/test.check,https://github.com/clojure/test.check org.clojure/tools.gitlibs,https://github.com/clojure/tools.gitlibs org.clojure/tools.namespace,https://github.com/babashka/tools.namespace diff --git a/script/add-libtest.clj b/script/add_libtest.clj similarity index 99% rename from script/add-libtest.clj rename to script/add_libtest.clj index 9eeea5f2..dd968c1e 100755 --- a/script/add-libtest.clj +++ b/script/add_libtest.clj @@ -11,11 +11,11 @@ (:require [babashka.deps :as deps] [babashka.fs :as fs] [babashka.tasks :refer [shell]] - [org.httpkit.client :as http] - [clojure.string :as str] + [clojure.edn :as edn] [clojure.java.io :as io] + [clojure.string :as str] [clojure.tools.cli :as cli] - [clojure.edn :as edn])) + [org.httpkit.client :as http])) (deps/add-deps '{:deps {org.clojure/tools.gitlibs {:mvn/version "2.4.172"} borkdude/rewrite-edn {:mvn/version "0.1.0"} diff --git a/test-resources/lib_tests/bb-tested-libs.edn b/test-resources/lib_tests/bb-tested-libs.edn index 60c502de..9cd8076e 100644 --- a/test-resources/lib_tests/bb-tested-libs.edn +++ b/test-resources/lib_tests/bb-tested-libs.edn @@ -113,4 +113,5 @@ com.github.seancorfield/expectations {:git-url "https://github.com/clojure-expectations/clojure-test", :test-namespaces (expectations.clojure.test-test), :git-sha "b30fefd97d9eb7d1f47e06956521f354cb926b03"} com.rpl/specter {:git-url "https://github.com/redplanetlabs/specter", :test-namespaces (com.rpl.specter.cljs-test-helpers com.rpl.specter.test-helpers com.rpl.specter.core-test com.rpl.specter.zipper-test), :git-sha "67e86806020b9d02fbca8cdb1efad3002fc81a32"} com.github.askonomm/clarktown {:git-url "https://github.com/askonomm/clarktown", :test-namespaces (clarktown.core-test clarktown.parsers.horizontal-line-block-test clarktown.parsers.italic-test clarktown.parsers.link-and-image-test clarktown.parsers.empty-block-test clarktown.parsers.inline-code-test clarktown.parsers.heading-block-test clarktown.parsers.bold-test clarktown.parsers.quote-block-test clarktown.parsers.code-block-test clarktown.parsers.strikethrough-test), :git-sha "059bfa7bd9bfdde0c75646bf1dfc20d23da8a02c"} + org.clojure/math.numeric-tower {:git-url "https://github.com/clojure/math.numeric-tower", :test-namespaces (clojure.math.test-numeric-tower), :git-sha "97827be66f35feebc3c89ba81c546fef4adc7947"} } diff --git a/test-resources/lib_tests/clojure/math/test_numeric_tower.clj b/test-resources/lib_tests/clojure/math/test_numeric_tower.clj new file mode 100644 index 00000000..ba0ba266 --- /dev/null +++ b/test-resources/lib_tests/clojure/math/test_numeric_tower.clj @@ -0,0 +1,129 @@ +(ns clojure.math.test-numeric-tower + (:use clojure.test + clojure.math.numeric-tower)) + +(deftest test-expt + (are [x y] (= x y) + (expt 2 3) 8 + (expt (expt 2 16) 2) (expt 2 32) + (expt 4/3 2) 16/9 + (expt 2 -10) 1/1024 + (expt 0.5M 2) 0.25M + (expt 5 4.2) (Math/pow 5 4.2) + (expt 5.3 4) (Math/pow 5.3 4) + (expt 5.3 4) (Math/pow 5.3 4) + (expt 2 0) 1 + (expt (java.math.BigInteger. "4") 0) (java.math.BigInteger. "1") + (expt 4M 0) 1M + (expt 8M 1) 8M + (expt 16M 16) 18446744073709551616M)) + +(when-available clojure.lang.BigInt + (deftest test-expt-bigint + (are [x y] (= x y) + (expt (bigint 4) 0) (bigint 1)))) + +(deftest test-abs + (are [x y] (= x y) + (abs -2) 2 + (abs 0) 0 + (abs 5) 5 + (abs 123456789123456789) 123456789123456789 + (abs -123456789123456789) 123456789123456789 + (abs 5/3) 5/3 + (abs -4/3) 4/3 + (abs 4.3M) 4.3M + (abs -4.3M) 4.3M + (abs 2.8) 2.8 + (abs -2.8) 2.8)) + +(deftest test-gcd + (are [x y] (= x y) + (gcd 4 3) 1 + (gcd 24 12) 12 + (gcd 24 27) 3 + (gcd 1 0) 1 + (gcd 0 1) 1 + (gcd 0 0) 0) + (is (thrown? IllegalArgumentException (gcd nil 0))) + (is (thrown? IllegalArgumentException (gcd 0 nil))) + (is (thrown? IllegalArgumentException (gcd 7.0 0)))) + +(deftest test-lcm + (are [x y] (= x y) + (lcm 2 3) 6 + (lcm 3 2) 6 + (lcm -2 3) 6 + (lcm 2 -3) 6 + (lcm -2 -3) 6 + (lcm 4 10) 20 + (lcm 1 0) 0 + (lcm 0 1) 0 + (lcm 0 0) 0) + (is (thrown? IllegalArgumentException (lcm nil 0))) + (is (thrown? IllegalArgumentException (lcm 0 nil))) + (is (thrown? IllegalArgumentException (lcm 7.0 0)))) + +(deftest test-floor + (are [x y] (== x y) + (floor 6) 6 + (floor -6) -6 + (floor 123456789123456789) 123456789123456789 + (floor -123456789123456789) -123456789123456789 + (floor 4/3) 1 + (floor -4/3) -2 + (floor 4.3M) 4 + (floor -4.3M) -5 + (floor 4.3) 4.0 + (floor -4.3) -5.0)) + +(deftest test-ceil + (are [x y] (== x y) + (ceil 6) 6 + (ceil -6) -6 + (ceil 123456789123456789) 123456789123456789 + (ceil -123456789123456789) -123456789123456789 + (ceil 4/3) 2 + (ceil -4/3) -1 + (ceil 4.3M) 5 + (ceil -4.3M) -4 + (ceil 4.3) 5.0 + (ceil -4.3) -4.0)) + +(deftest test-round + (are [x y] (== x y) + (round 6) 6 + (round -6) -6 + (round 123456789123456789) 123456789123456789 + (round -123456789123456789) -123456789123456789 + (round 4/3) 1 + (round 5/3) 2 + (round 5/2) 3 + (round -4/3) -1 + (round -5/3) -2 + (round -5/2) -2 + (round 4.3M) 4 + (round 4.7M) 5 + (round -4.3M) -4 + (round -4.7M) -5 + (round 4.5M) 5 + (round -4.5M) -4 + (round 4.3) 4 + (round 4.7) 5 + (round -4.3) -4 + (round -4.7) -5 + (round 4.5) 5 + (round -4.5) -4)) + +(deftest test-sqrt + (are [x y] (= x y) + (sqrt 9) 3 + (sqrt 16/9) 4/3 + (sqrt 0.25M) 0.5M + (sqrt 2) (Math/sqrt 2))) + +(deftest test-exact-integer-sqrt + (are [x y] (= x y) + (exact-integer-sqrt 15) [3 6] + (exact-integer-sqrt (inc (expt 2 32))) [(expt 2 16) 1] + (exact-integer-sqrt 1000000000000) [1000000 0]))