summaryrefslogtreecommitdiff
path: root/core_test.fnl
diff options
context:
space:
mode:
authorAndrey Orst <andreyorst@gmail.com>2020-10-25 20:45:42 +0300
committerAndrey Orst <andreyorst@gmail.com>2020-10-25 20:45:42 +0300
commitf696a71b13d6867bf7168e6314eeaa8663b30e92 (patch)
tree3a3793653babbab24a413a374366c84bcf3bc0e3 /core_test.fnl
parent7f6c6a600ec8652bf64d4b343c8d920d71d464c2 (diff)
feature: refactoring
Diffstat (limited to 'core_test.fnl')
-rw-r--r--core_test.fnl121
1 files changed, 87 insertions, 34 deletions
diff --git a/core_test.fnl b/core_test.fnl
index e5fbc22..c75e800 100644
--- a/core_test.fnl
+++ b/core_test.fnl
@@ -2,40 +2,44 @@
(import-macros {: into} :macros.core)
(import-macros {: assert-eq : assert-ne : assert* : test} :test)
-(local {: apply
- : seq
- : first
- : rest
- : conj
- : cons
- : concat
- : reduce
- : reduce-kv
- : mapv
- : filter
- : map?
- : seq?
- : nil?
- : zero?
- : pos?
- : neg?
- : even?
- : odd?
- : int?
- : pos-int?
- : neg-int?
- : double?
- : string?
- : eq?
- : identity
- : comp
- : every?
- : some
- : complement
- : constantly
- : range
- : reverse}
- (require :core))
+(local
+ {: apply ;; not tested
+ : seq ;; tested
+ : first ;; not tested
+ : rest ;; not tested
+ : conj ;; not tested
+ : cons ;; not tested
+ : concat ;; tested
+ : reduce ;; tested
+ : reduce-kv ;; tested
+ : mapv ;; tested
+ : filter ;; tested
+ : map? ;; tested
+ : seq? ;; tested
+ : nil? ;; tested
+ : zero? ;; tested
+ : pos? ;; tested
+ : neg? ;; tested
+ : even? ;; tested
+ : odd? ;; tested
+ : int? ;; tested
+ : pos-int? ;; tested
+ : neg-int? ;; tested
+ : double? ;; tested
+ : string? ;; tested
+ : empty? ;; tested
+ : not-empty ;; tested
+ : eq? ;; tested
+ : identity ;; tested
+ : comp ;; not tested
+ : every? ;; tested
+ : some ;; tested
+ : complement ;; tested
+ : constantly ;; tested
+ : range ;; tested
+ : reverse ;; tested
+ }
+ (require :core))
(test equality
;; comparing basetypes
@@ -174,3 +178,52 @@
(assert-eq (concat [1 2 3] [4 5 6]) [1 2 3 4 5 6])
(assert-eq (concat [1 2] [3 4] [5 6]) [1 2 3 4 5 6])
(assert-eq (concat {:a 1} {:b 2}) [[:a 1] [:b 2]]))
+
+(test reverse
+ (assert-eq (reverse [1 2 3]) [3 2 1])
+ (assert-eq (reverse {:a 1}) [[:a 1]]))
+
+(test constantly
+ (let [always-nil (constantly nil)]
+ (assert-eq (always-nil) nil)
+ (assert-eq (always-nil 1) nil)
+ (assert-eq (always-nil 1 2 3 4 "5") nil))
+
+ (let [always-true (constantly true)]
+ (assert* (always-true))
+ (assert* (always-true false))))
+
+(test complement
+ (assert* ((complement nil?) 10)))
+
+(test some
+ (assert* (some pos-int? [-1 1.1 2.3 -5.5 42 10 -27]))
+ (assert* (not (some pos-int? {:a 1})))
+ (assert* (some pos-int? [{:a 1} "1" -1 1])))
+
+(test every?
+ (assert* (not (every? pos-int? [-1 1.1 2.3 -5.5 42 10 -27])))
+ (assert* (not (every? pos-int? {:a 1})))
+ (assert* (every? pos-int? [1 2 3 4 5])))
+
+(test identity
+ (assert-eq (identity 1) 1)
+ (assert-eq (identity {:a 1 :b 2}) {:a 1 :b 2})
+ (assert-eq (identity [1 2 3]) [1 2 3])
+ (assert-eq (identity "abc") "abc"))
+
+(test empty?
+ (assert* (empty? []))
+ (assert* (empty? {}))
+ (assert* (empty? ""))
+ (assert* (not (empty? "1")))
+ (assert* (not (empty? [1])))
+ (assert* (not (empty? {:a 1}))))
+
+(test not-empty
+ (assert-eq (not-empty []) nil)
+ (assert-eq (not-empty {}) nil)
+ (assert-eq (not-empty "") nil)
+ (assert-eq (not-empty "1") "1")
+ (assert-eq (not-empty [1]) [1])
+ (assert-eq (not-empty {:a 1}) {:a 1}))