Skip to content

Commit

Permalink
Merge branch 'master' of github.com:cloojure/tupelo
Browse files Browse the repository at this point in the history
  • Loading branch information
cloojure committed Nov 11, 2019
2 parents 8d74b04 + 6719990 commit d28ce3f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/cljc/tupelo/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,31 @@
"Abbreviated name for `newline` "
[] (newline))

;-----------------------------------------------------------------------------
(s/defn int-pos? :- s/Bool
"Returns true iff x is an integer and is positive"
[arg] (and (int? arg) (pos? arg) ) )

(s/defn int-neg? :- s/Bool
"Returns true iff x is an integer and is negative"
[arg] (and (int? arg) (neg? arg) ) )

(s/defn int-nonneg? :- s/Bool
"Returns true iff x is an integer and is not negative"
[arg] (and (int? arg) (not (neg? arg))) )

(s/defn int-nonpos? :- s/Bool
"Returns true iff x is an integer and is not positive"
[arg] (and (int? arg) (not (pos? arg))) )

(s/defn nonneg? :- s/Bool
"Returns true iff x is not negative"
[arg] (not (neg? arg)) )

(s/defn nonpos? :- s/Bool
"Returns true iff x is not positive"
[arg] (not (pos? arg)) )

;-----------------------------------------------------------------------------
(s/defn not-nil? :- s/Bool
"Returns true if arg is not nil; false otherwise. Equivalent to (not (nil? arg)),
Expand Down
9 changes: 9 additions & 0 deletions test/cljc/tst/tupelo/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@
(isnt (t/quad? [:x :y :z]))
(isnt (t/quad? inf-rng-1))))

(dotest
(let [vals [-3.14 -2 0 2 3.14]]
(is= [false false false true false] (mapv t/int-pos? vals))
(is= [false true false false false] (mapv t/int-neg? vals))
(is= [false false true true false] (mapv t/int-nonneg? vals))
(is= [false true true false false] (mapv t/int-nonpos? vals))
(is= [false false true true true] (mapv t/nonneg? vals))
(is= [true true true false false] (mapv t/nonpos? vals))))

(dotest
(let [inf-rng-1 (map inc (range))
tst-map (t/glue (sorted-map) {:a 1 :b 2 :c 3 :d 4 :e 5 :f 6})]
Expand Down

0 comments on commit d28ce3f

Please sign in to comment.