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
5 changes: 5 additions & 0 deletions src/mb/hawk/assert_exprs/approximately_equal.clj
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@
(when-not (pred actual)
(list 'not (list pred actual))))

(methodical/defmethod =?-diff [clojure.lang.AFunction nil]
[pred actual]
(when-not (pred actual)
(list 'not (list pred actual))))

(methodical/defmethod =?-diff [clojure.lang.Sequential clojure.lang.Sequential]
[expected actual]
(let [same-size? (= (count expected)
Expand Down
12 changes: 8 additions & 4 deletions test/mb/hawk/assert_exprs/approximately_equal_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
(is (=? 100 100)))
(testing "predicate function"
(is (=? int? 100)))
(testing "predicate function with nil"
(is (=? empty? nil)))
(testing "regexes"
(is (=? #"cans$" "cans")))
(testing "classes"
Expand All @@ -36,15 +38,17 @@
[]))
(is (=? [nil]
[nil]))
(is (=? [nil?]
[nil]))
(is (=? [1 nil 2]
[1 nil 2]))
(is (=? [:a int?]
[:a 100]))
(testing "Should enforce that sequences are of the same length"
(is (= [nil nil (list 'not= nil? nil)]
(=?/=?-diff [int? string? nil?]
(testing "Should handle different lengths appropriately"
(is (= [nil nil (list 'not (list some? nil))]
(=?/=?-diff [int? string? some?]
[1 "two"])))
(is (= [nil nil (list 'not= nil? nil) (list 'not= nil "cans")]
(is (= [nil nil nil (list 'not= nil "cans")]
(=?/=?-diff [int? string? nil?]
[1 "two" nil "cans"])))
(testing "Differentiate between [1 2 nil] and [1 2]"
Expand Down
Loading