Skip to content

Commit

Permalink
CLJ-2649: Fix 3-arg some-fn and every-pred (#320)
Browse files Browse the repository at this point in the history
  • Loading branch information
frenchy64 authored Sep 11, 2024
1 parent 008b271 commit 9e368a7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 4 additions & 4 deletions clj/src/cljd/core.cljd
Original file line number Diff line number Diff line change
Expand Up @@ -5509,8 +5509,8 @@
(fn ep3
([] true)
([x] (boolean (and (p1 x) (p2 x) (p3 x))))
([x y] (boolean (and (p1 x) (p2 x) (p3 x) (p1 y) (p2 y) (p3 y))))
([x y z] (boolean (and (p1 x) (p2 x) (p3 x) (p1 y) (p2 y) (p3 y) (p1 z) (p2 z) (p3 z))))
([x y] (boolean (and (p1 x) (p1 y) (p2 x) (p2 y) (p3 x) (p3 y))))
([x y z] (boolean (and (p1 x) (p1 y) (p1 z) (p2 x) (p2 y) (p2 z) (p3 x) (p3 y) (p3 z))))
([x y z & args] (boolean (and (ep3 x y z)
(every? #(and (p1 %) (p2 %) (p3 %)) args))))))
([p1 p2 p3 & ps]
Expand Down Expand Up @@ -5608,8 +5608,8 @@
(fn sp3
([] nil)
([x] (or (p1 x) (p2 x) (p3 x)))
([x y] (or (p1 x) (p2 x) (p3 x) (p1 y) (p2 y) (p3 y)))
([x y z] (or (p1 x) (p2 x) (p3 x) (p1 y) (p2 y) (p3 y) (p1 z) (p2 z) (p3 z)))
([x y] (or (p1 x) (p1 y) (p2 x) (p2 y) (p3 x) (p3 y)))
([x y z] (or (p1 x) (p1 y) (p1 z) (p2 x) (p2 y) (p2 z) (p3 x) (p3 y) (p3 z)))
([x y z & args] (or (sp3 x y z)
(some #(or (p1 %) (p2 %) (p3 %)) args)))))
([p1 p2 p3 & ps]
Expand Down
10 changes: 9 additions & 1 deletion clj/test/cljd/test_clojure/core_test_cljd.cljd
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,11 @@
(is (= true (apply distinct? (range 20)))))

(deftest testing-every-pred
(is (= true ((every-pred #(< % 10) number?) 1 2 3 4))))
(is (= true ((every-pred #(< % 10) number?) 1 2 3 4)))
(is (= false ((every-pred some? #(throw (ex-info (str %) {})) some?) 1 nil)))
(is (= false ((every-pred some? some? #(throw (ex-info (str %) {}))) 1 nil)))
(is (= false ((every-pred some? #(throw (ex-info (str %) {})) some?) 1 1 nil)))
(is (= false ((every-pred some? some? #(throw (ex-info (str %) {}))) 1 1 nil))))

(deftest testing-filterv
(is (= [1 3 5 7 9] (filterv odd? (range 10)))))
Expand All @@ -230,6 +234,10 @@
(deftest testing-select-keys
(is (= {1 1 5 5} (select-keys (into {} (map #(vector % %)) (range 10)) [1 5]))))

(deftest testing-some-fn
(is (= true ((some-fn number? odd? #(> % 0)) :a 1)))
(is (= true ((some-fn number? odd? #(> % 0)) :a 1 3))))

(deftype Base [x]
Object
(toString [_] (str "Base of " x)))
Expand Down

0 comments on commit 9e368a7

Please sign in to comment.