Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 45 additions & 52 deletions test/clojure/core_test/gt.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,40 @@
(when-var-exists >
(deftest test->
(testing "arity 1"
;; Doesn't matter what the argument is, `>` return `true` for
;; one argument.
(is (> 1))
(is (> 0))
(is (> -1))
;; Doesn't check whether arg is a number
(is (> "abc"))
(is (> :foo))
(is (> nil)))
(are [x] (= true (> x))
;; Doesn't matter what the argument is, `>` returns `true` for
;; one argument.
1
0
-1
;; Doesn't check whether the argument is a number
"abc"
:foo
nil))

(testing "arity 2"
(are [expected x y] (= expected (> x y))
true 1 0
true 0 -1
true 1N 0N
true 0N -1N
true 1.0 0.0
true 0.0 -1.0
true 1.0M 0.0M
true 0.0M -1.0M
true -1 ##-Inf
true ##Inf 1
true 0 -1
true 1N 0N
true 0N -1N
true 1.0 0.0
true 0.0 -1.0
true 1.0M 0.0M
true 0.0M -1.0M
true -1 ##-Inf
true ##Inf 1

false 0 1
false -1 0
false 0N 1N
false -1N 0N
false 0.0 1.0
false -1.0 0.0
false 0.0M 1.0M
false -1.0M 0.0M
false ##-Inf -1
false 1 ##Inf
false -1 0
false 0N 1N
false -1N 0N
false 0.0 1.0
false -1.0 0.0
false 0.0M 1.0M
false -1.0M 0.0M
false ##-Inf -1
false 1 ##Inf

false 1 ##NaN ; Anything compared with ##NaN is false
false ##NaN 1
Expand All @@ -60,15 +61,18 @@
:default
(testing "Rationals"
(are [expected x y] (= expected (> x y))
true 1/2 1/16
true 0.5 1/16
true -1/16 -1/2
true -1/16 -0.5

false 1/16 1/2
false -1/2 -1/16
false 1/16 0.5
false -0.5 -1/16))))
false -1/2 -1/16
false 1/16 0.5
false -0.5 -1/16
true 1/2 1/16
true 0.5 1/16
true -1/16 -1/2
true -1/16 -0.5
false 1/2 1/2
false 1/3 1/3
false -1/2 -1/2
false -1/3 -1/3))))

(testing "arity 3 and more"
(are [expected x y z] (= expected (> x y z))
Expand All @@ -80,7 +84,8 @@
false -1 -2 0
false -1 0 -2)
(is (= true (apply > (reverse (range 10)))))
(is (= false (apply > -1 (reverse (range 10))))))
(is (= false (apply > -1 (reverse (range 10)))))
(is (= false (apply > (repeat 5 1)))))

(testing "negative tests"
;; `>` only compares numbers, except in ClojureScript (really
Expand All @@ -91,31 +96,19 @@
[(is (= true (> 1 nil)))
(is (= false (> nil 1)))
(is (= true (> 2 1 nil)))
(is (= false (> 1 2 nil)))
(is (= true (> "2" "1")))
(is (= false (> "bar" "foo")))
(is (= false (> :bar :foo)))]
(is (= false (> 1 2 nil)))]
:cljr
[(is (p/thrown? (> 1 nil)))
(is (p/thrown? (> nil 1)))
(is (p/thrown? (> 1 nil 2)))
(is (p/thrown? (> 2 1 nil)))
(is (= true (> "2" "1")))
(is (p/thrown? (> "bar" "foo")))
(is (p/thrown? (> :bar :foo)))]
(is (p/thrown? (> 2 1 nil)))]
:lpy
[(is (p/thrown? (> 1 nil)))
(is (p/thrown? (> nil 1)))
(is (p/thrown? (> 1 nil 2)))
(is (p/thrown? (> 2 1 nil)))
(is (= true (> "2" "1")))
(is (= false (> "bar" "foo")))
(is (= false (> :bar :foo)))]
(is (p/thrown? (> 2 1 nil)))]
:default
[(is (p/thrown? (> 1 nil)))
(is (p/thrown? (> nil 1)))
(is (p/thrown? (> 1 nil 2)))
(is (p/thrown? (> 2 1 nil)))
(is (p/thrown? (> "2" "1")))
(is (p/thrown? (> "bar" "foo")))
(is (p/thrown? (> :bar :foo)))]))))
(is (p/thrown? (> 2 1 nil)))]))))
48 changes: 21 additions & 27 deletions test/clojure/core_test/lt.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
(when-var-exists <
(deftest test-<
(testing "arity 1"
;; Doesn't matter what the argument is, `<` return `true` for
;; one argument.
(is (< 1))
(is (< 0))
(is (< -1))
;; Doesn't check whether arg is a number
(is (< "abc"))
(is (< :foo))
(is (< nil)))
(are [x] (= true (< x))
;; Doesn't matter what the argument is, `<` returns `true` for
;; one argument.
1
0
-1
;; Doesn't check whether the argument is a number
"abc"
:foo
nil))

(testing "arity 2"
(are [expected x y] (= expected (< x y))
Expand Down Expand Up @@ -66,7 +67,11 @@
false 1/2 1/16
false 0.5 1/16
false -1/16 -1/2
false -1/16 -0.5))))
false -1/16 -0.5
false 1/2 1/2
false 1/3 1/3
false -1/2 -1/2
false -1/3 -1/3))))

(testing "arity 3 and more"
(are [expected x y z] (= expected (< x y z))
Expand All @@ -78,7 +83,8 @@
false 0 -2 -1
false -2 0 -1)
(is (= true (apply < (range 10))))
(is (= false (apply < 100 (range 10)))))
(is (= false (apply < 100 (range 10))))
(is (= false (apply < (repeat 5 1)))))

(testing "negative tests"
;; `<` only compares numbers, except in ClojureScript (really
Expand All @@ -88,31 +94,19 @@
[(is (= true (< nil 1)))
(is (= false (< 1 nil)))
(is (= true (< nil 1 2)))
(is (= false (< 1 2 nil)))
(is (= true (< "1" "2")))
(is (= false (< "foo" "bar")))
(is (= false (< :foo :bar)))]
(is (= false (< 1 2 nil)))]
:cljr
[(is (p/thrown? (< nil 1)))
(is (p/thrown? (< 1 nil)))
(is (p/thrown? (< nil 1 2)))
(is (p/thrown? (< 1 2 nil)))
(is (= true (< "1" "2")))
(is (p/thrown? (< "foo" "bar")))
(is (p/thrown? (< :foo :bar)))]
(is (p/thrown? (< 1 2 nil)))]
:lpy
[(is (p/thrown? (< nil 1)))
(is (p/thrown? (< 1 nil)))
(is (p/thrown? (< nil 1 2)))
(is (p/thrown? (< 1 2 nil)))
(is (= true (< "1" "2")))
(is (= false (< "foo" "bar")))
(is (= false (< :foo :bar)))]
(is (p/thrown? (< 1 2 nil)))]
:default
[(is (p/thrown? (< nil 1)))
(is (p/thrown? (< 1 nil)))
(is (p/thrown? (< nil 1 2)))
(is (p/thrown? (< 1 2 nil)))
(is (p/thrown? (< "1" "2")))
(is (p/thrown? (< "foo" "bar")))
(is (p/thrown? (< :foo :bar)))]))))
(is (p/thrown? (< 1 2 nil)))]))))
42 changes: 16 additions & 26 deletions test/clojure/core_test/lt_eq.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
(when-var-exists <=
(deftest test-<=
(testing "arity 1"
;; Doesn't matter what the argument is, `<=` return `true` for
;; one argument.
(is (<= 1))
(is (<= 0))
(is (<= -1))
;; Doesn't check whether arg is a number
(is (<= "abc"))
(is (<= :foo))
(is (<= nil)))
(are [x] (= true (<= x))
;; Doesn't matter what the argument is, `<=` returns `true` for
;; one argument.
1
0
-1
;; Doesn't check whether the argument is a number
"abc"
:foo
nil))

(testing "arity 2"
(are [expected x y] (= expected (<= x y))
Expand Down Expand Up @@ -88,7 +89,8 @@
false ##Inf 0 ##-Inf)
(is (= true (apply <= (range 10))))
(is (= true (apply <= 0 (range 10))))
(is (= false (apply <= 100 (range 10)))))
(is (= false (apply <= 100 (range 10))))
(is (= true (apply <= (repeat 5 1)))))

(testing "negative tests"
;; `<=` only compares numbers, except in ClojureScript (really
Expand All @@ -98,31 +100,19 @@
[(is (= true (<= nil 1)))
(is (= false (<= 1 nil)))
(is (= true (<= nil 1 2)))
(is (= false (<= 1 2 nil)))
(is (= true (<= "1" "2")))
(is (= false (<= "foo" "bar")))
(is (= false (<= :foo :bar)))]
(is (= false (<= 1 2 nil)))]
:cljr
[(is (p/thrown? (<= nil 1)))
(is (p/thrown? (<= 1 nil)))
(is (p/thrown? (<= nil 1 2)))
(is (p/thrown? (<= 1 2 nil)))
(is (= true (<= "1" "2")))
(is (p/thrown? (<= "foo" "bar")))
(is (p/thrown? (<= :foo :bar)))]
(is (p/thrown? (<= 1 2 nil)))]
:lpy
[(is (p/thrown? (<= nil 1)))
(is (p/thrown? (<= 1 nil)))
(is (p/thrown? (<= nil 1 2)))
(is (p/thrown? (<= 1 2 nil)))
(is (= true (<= "1" "2")))
(is (= false (<= "foo" "bar")))
(is (= false (<= :foo :bar)))]
(is (p/thrown? (<= 1 2 nil)))]
:default
[(is (p/thrown? (<= nil 1)))
(is (p/thrown? (<= 1 nil)))
(is (p/thrown? (<= nil 1 2)))
(is (p/thrown? (<= 1 2 nil)))
(is (p/thrown? (<= "1" "2")))
(is (p/thrown? (<= "foo" "bar")))
(is (p/thrown? (<= :foo :bar)))]))))
(is (p/thrown? (<= 1 2 nil)))]))))
Loading