From 524bd990d1539b6620ad26c81b28273f3c9d3ce4 Mon Sep 17 00:00:00 2001 From: Andrey Listopadov Date: Sun, 17 Oct 2021 13:00:25 +0300 Subject: fix: bump fennel-test to v0.0.3 --- tests/core.fnl | 117 +++++++++++++++++++++++++++++++++++++++++++------------ tests/fn.fnl | 4 +- tests/macros.fnl | 18 ++++----- 3 files changed, 104 insertions(+), 35 deletions(-) (limited to 'tests') diff --git a/tests/core.fnl b/tests/core.fnl index ab3b08a..bdb2ede 100644 --- a/tests/core.fnl +++ b/tests/core.fnl @@ -1,14 +1,83 @@ (require-macros :init-macros) -(require-macros :fennel-test.test) - -(macro require-module [module] - `(local ,(collect [k (pairs (require module))] - (values k (sym k))) - (require ,module))) - -(require-module :init) - -(deftest equality +(require-macros :fennel-test) + +(local {: add + : apply + : assoc + : boolean? + : butlast + : comp + : complement + : concat + : conj + : cons + : constantly + : dec + : disj + : dissoc + : div + : double? + : empty? + : eq + : even? + : every? + : false? + : filter + : find + : first + : ge + : get + : get-in + : get-method + : gt + : hash-map + : hash-set + : identity + : inc + : int? + : keys + : kvseq + : last + : le + : lt + : map? + : mapv + : memoize + : methods + : mul + : multifn? + : neg-int? + : neg? + : nil? + : not-any? + : not-empty + : nthrest + : odd? + : ordered-set + : partition + : pos-int? + : pos? + : range + : reduce + : reduce-kv + : reduced + : remove-all-methods + : remove-method + : rest + : reverse + : seq + : set? + : some + : string? + : sub + : take + : true? + : vals + : vector + : vector? + : zero?} (require :init)) + +(deftest test-equality (testing "comparing base-types" (assert-not (pcall eq)) (assert-eq 1 1) @@ -54,7 +123,7 @@ (assert-eq [1 2 3] {1 1 2 2 3 3}) (assert-eq {4 1} [nil nil nil 1]))) -(deftest range +(deftest test-range (testing "range" (assert-not (pcall range)) (assert-eq (range 10) [0 1 2 3 4 5 6 7 8 9]) @@ -62,7 +131,7 @@ (assert-eq [0 0.2 0.4 0.6 0.8] [0 0.2 0.4 0.6 0.8]) (assert-eq (range 0 1 0.2) (range 0 1 0.2)))) -(deftest predicates +(deftest test-predicates (testing "zero?" (assert-is (zero? 0)) (assert-is (zero? -0)) @@ -189,7 +258,7 @@ (assert-not (pcall boolean?)) (assert-not (pcall boolean? 1 2)))) -(deftest sequence-functions +(deftest test-sequence-functions (testing "seq" (assert-not (pcall seq)) (assert-not (pcall seq [] [])) @@ -452,7 +521,7 @@ (assert-eq (find {:a 1 :b 2 :c 3} :d) nil))) -(deftest function-manipulation +(deftest test-function-manipulation (testing "constantly" (assert-not (pcall constantly)) (assert-not (pcall constantly nil nil)) @@ -517,7 +586,7 @@ (assert-eq (identity f) f) (assert-eq (identity a) a))) -(deftest sequence-predicates +(deftest test-sequence-predicates (testing "some" (assert-not (pcall some)) (assert-not (pcall some pos-int?)) @@ -558,7 +627,7 @@ (assert-eq (not-empty [1]) [1]) (assert-eq (not-empty {:a 1}) {:a 1}))) -(deftest math-functions +(deftest test-math-functions (testing "inc" (assert-eq (inc 1) 2) (assert-eq (inc -1) 0) @@ -571,7 +640,7 @@ (assert-not (pcall dec)) (assert-not (pcall dec nil)))) -(deftest table-access +(deftest test-table-access (testing "get" (assert-eq (get {:key1 10 :key2 20} :key1) 10) (assert-eq (get {:key1 10 :key2 20} :key1 false) 10) @@ -592,7 +661,7 @@ (assert-not (pcall get-in)) (assert-not (pcall get-in {})))) -(deftest methods +(deftest test-methods (testing "methods" (defmulti f identity) (defmethod f :a [_] :a) @@ -642,7 +711,7 @@ (assert-not (pcall remove-all-methods [])) (assert-not (pcall remove-all-methods f f)))) -(deftest math-functions +(deftest test-math-functions (testing "add" (assert-eq (add) 0) (assert-eq (add 1) 1) @@ -679,7 +748,7 @@ (assert-eq (div 1 2 3 4) (/ 1 2 3 4)) (assert-eq (div 1 2 3 4 5) (/ 1 2 3 4 5)))) -(deftest comparison-functions +(deftest test-comparison-functions (testing "le" (assert-not (pcall le)) (assert-is (le 1)) @@ -724,14 +793,14 @@ (assert-not (gt 2 1 3)) (assert-not (gt 1 2 4 4)))) -(deftest vector +(deftest test-vector (testing "vector" (assert-eq (vector) []) (assert-eq (vector 1) [1]) (assert-eq (vector 1 2 3) [1 2 3]) (assert-eq (getmetatable (vector 1 2 3)) {:cljlib/type :seq}))) -(deftest hash-map +(deftest test-hash-map (testing "hash-map" (assert-not (pcall hash-map :a)) (assert-eq (hash-map) {}) @@ -740,7 +809,7 @@ (assert-eq (getmetatable (hash-map)) {:cljlib/type :table}) (assert-not (pcall hash-map nil 1)))) -(deftest sets +(deftest test-sets (testing "hash-set" (let [h1 (hash-set [1] [1] [2] [3] [:a]) h2 (hash-set [1] [2] [3] [:a])] @@ -810,7 +879,7 @@ (assert-eq (into [] (ordered-set :a :b :c)) [:a :b :c]) (assert-eq (into {} (ordered-set [:a 1] [:b 2])) {:a 1 :b 2}))) -(deftest memoization +(deftest test-memoization (testing "memoize" (macros {:time #`(let [clock# os.clock start# (clock#) diff --git a/tests/fn.fnl b/tests/fn.fnl index a4b342b..2cbe94b 100644 --- a/tests/fn.fnl +++ b/tests/fn.fnl @@ -1,7 +1,7 @@ -(require-macros :fennel-test.test) +(require-macros :fennel-test) (require-macros :init-macros) -(deftest fn* +(deftest test-fn* (testing "fn* meta" (fn* f "single arity" diff --git a/tests/macros.fnl b/tests/macros.fnl index 50961d6..b142d4e 100644 --- a/tests/macros.fnl +++ b/tests/macros.fnl @@ -1,7 +1,7 @@ -(require-macros :fennel-test.test) +(require-macros :fennel-test) (require-macros :init-macros) -(deftest into +(deftest test-into (testing "into" (assert-eq (into [] nil) []) (assert-eq (into nil nil) nil) @@ -59,7 +59,7 @@ (assert-eq (into [] "vaiv") ["v" "a" "i" "v"]) (when _G.utf8 (assert-eq (into [] "ваыв") ["в" "а" "ы" "в"])))) -(deftest let-variants +(deftest test-let-variants (testing "when-let" (assert-eq (when-let [a 4] a) 4) (assert-not (when-let [a false] a) "(not (when-let [a false] a))") @@ -80,7 +80,7 @@ (assert-eq (if-some [a false] a :nothing) false) (assert-eq (if-some [a nil] a :nothing) :nothing))) -(deftest multimethods +(deftest test-multimethods (testing "defmulti" (defmulti x (fn [x] x)) (assert-eq (defmulti x (fn [x] (+ x 1))) nil)) @@ -143,7 +143,7 @@ (assert-eq (f :4) :42) (assert-eq (f :4 :2) 42))) -(deftest def-macros +(deftest test-def-macros (testing "def" (def {:mutable true} a 10) (assert-eq a 10) @@ -168,7 +168,7 @@ (assert-eq b.a 10) (assert-eq a 10))) -(deftest meta +(deftest test-meta (testing "with-meta" (assert-eq (meta (with-meta :a {:k :v})) {:k :v})) @@ -186,7 +186,7 @@ (defonce {:doc "y" :mutable true} y 20) (assert-eq (meta y) {:fnl/docstring "y"}))) -(deftest empty +(deftest test-empty (testing "empty map" (assert-eq (empty {}) {}) (assert-eq (getmetatable (empty {})) {:cljlib/type :table}) @@ -204,7 +204,7 @@ (assert-eq (empty a) []) (assert-eq (getmetatable (empty a)) {:cljlib/type :seq})))) -(deftest try +(deftest test-try (testing "try" (assert-eq (try (+ 1 2 3)) 6) (assert-eq (try (+ 1 2 3) (catch _ 0) (finally 10)) 6) @@ -249,7 +249,7 @@ (assert-eq 6 (select :# (try (values 1 nil 3 nil nil nil)))) (assert-eq 6 (select :# (try (error 10) (catch _ (values 1 nil 3 nil nil nil))))))) -(deftest loop +(deftest test-loop (testing "loop macro" (assert-eq (loop [[first & rest] [1 2 3 4 5] -- cgit v1.2.3