Skip to content

Commit

Permalink
fix: (-some-pred []) should return false
Browse files Browse the repository at this point in the history
Previously, it was returning false in cljs but true in clj. Now it
returns false in both.

This is in line with (or) returning nil and (and) returning true in
clojure.

fixes #751
  • Loading branch information
opqdonut committed Aug 28, 2024
1 parent 50da02b commit 7704849
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/malli/impl/util.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
(fn [x#] (~c (p# x#) (q# x#))))]
`(fn ~f [~preds]
(case (count ~preds)
0 (constantly true)
0 (constantly (boolean (~c)))
1 (first ~preds)
~@cases
~else)))))
Expand Down
5 changes: 4 additions & 1 deletion test/malli/util_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,10 @@
(is (true? ((miu/-some-pred tf) nil)))
(is (true? ((miu/-some-pred ft) nil)))
(is (false? ((miu/-some-pred ff) nil)))
(is (true? ((miu/-some-pred tt) nil)))))))
(is (true? ((miu/-some-pred tt) nil))))
(testing "empty inputs"
(is (true? ((miu/-every-pred []) :anything)))
(is (false? ((miu/-some-pred []) :anything)))))))

(deftest explain-data-test
(let [schema (m/schema [:map [:a [:vector [:maybe :string]]]])
Expand Down

0 comments on commit 7704849

Please sign in to comment.