Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

format code #1155

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion src/malli/registry.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
(def ^:private registry* (atom (simple-registry {})))

(defn set-default-registry! [?registry]
(if-not #?(:cljs (identical? mode "strict")
(if-not #?(:cljs (identical? mode "strict")
:default (= mode "strict"))
(reset! registry* (registry ?registry))
(throw (ex-info "can't set default registry, invalid mode" {:mode mode, :type type}))))
Expand Down
8 changes: 4 additions & 4 deletions test/malli/assert_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

(deftest assert-throws-test
(is (thrown? #?(:clj Exception, :cljs js/Error)
(assert :int "42" )))
(assert :int "42")))
(is (thrown? #?(:clj Exception, :cljs js/Error)
(assert int? "42" )))
(assert int? "42")))
(is (thrown? #?(:clj Exception, :cljs js/Error)
(assert string? 42)))
(is (thrown? #?(:clj Exception, :cljs js/Error)
Expand All @@ -22,8 +22,8 @@
(assert ::invalid-schema 42))))

(deftest assert-checked-and-does-not-throw
(is (= 42 (assert :int 42 )))
(is (= 42 (assert int? 42 )))
(is (= 42 (assert :int 42)))
(is (= 42 (assert int? 42)))
(is (= "42" (assert string? "42")))
(is (= nil (assert any? nil)))
(is (= {:a 42} (assert [:map [:a int?]] {:a 42}))))
12 changes: 6 additions & 6 deletions test/malli/clj_kondo_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,21 @@

(defn clj-kondo-issue-1922-1 [_x])
(m/=> clj-kondo-issue-1922-1
[:=> [:cat [:map [:keys [:+ :keyword]]]] :nil])
[:=> [:cat [:map [:keys [:+ :keyword]]]] :nil])

(defn clj-kondo-issue-1922-2 [_x])
(m/=> clj-kondo-issue-1922-2
[:=> [:cat [:map [:keys [:* :int]]]] :nil])
[:=> [:cat [:map [:keys [:* :int]]]] :nil])

(defn clj-kondo-issue-1922-3 [_x])
(m/=> clj-kondo-issue-1922-3
[:=> [:cat [:map [:keys [:? :string]]]] :nil])
[:=> [:cat [:map [:keys [:? :string]]]] :nil])

(defn clj-kondo-issue-1922-4 [_x])
(m/=> clj-kondo-issue-1922-4
[:function
[:=> [:cat :int :int] :nil]
[:=> [:cat :int :int [:repeat :int]] :nil]])
[:function
[:=> [:cat :int :int] :nil]
[:=> [:cat :int :int [:repeat :int]] :nil]])

(defn clj-kondo-issue-836-1
"Predicate `:fn` schema's should be type-checked as expecting to be passed `:any`, not a fn."
Expand Down
8 changes: 4 additions & 4 deletions test/malli/core_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -3509,10 +3509,10 @@

(deftest catch-infinitely-expanding-schema
(is (thrown-with-msg?
#?(:clj Exception, :cljs js/Error)
#?(:clj #":malli\.core/infinitely-expanding-schema"
:cljs #":malli\.core/invalid-schema")
(m/schema [(m/schema :any)]))))
#?(:clj Exception, :cljs js/Error)
#?(:clj #":malli\.core/infinitely-expanding-schema"
:cljs #":malli\.core/invalid-schema")
(m/schema [(m/schema :any)]))))

(deftest eduction-test
(is (m/validate [:sequential {:min 0} :int] (eduction identity (range 10))))
Expand Down
166 changes: 83 additions & 83 deletions test/malli/distributive_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -16,73 +16,73 @@

(deftest distributive-multi-test
(is (= (dist
[:merge
[:map [:x :int]]
[:multi {:dispatch :y}
[1 [:map [:y [:= 1]]]]
[2 [:map [:y [:= 2]]]]]])
[:merge
[:map [:x :int]]
[:multi {:dispatch :y}
[1 [:map [:y [:= 1]]]]
[2 [:map [:y [:= 2]]]]]])
[:multi {:dispatch :y}
[1 [:map [:x :int] [:y [:= 1]]]]
[2 [:map [:x :int] [:y [:= 2]]]]]))
(is (= (dist
[:merge
[:map [:x :int]]
[:schema
[:multi {:dispatch :y}
[1 [:map [:y [:= 1]]]]
[2 [:map [:y [:= 2]]]]]]])
[:merge
[:map [:x :int]]
[:schema
[:multi {:dispatch :y}
[1 [:map [:y [:= 1]]]]
[2 [:map [:y [:= 2]]]]]]])
[:multi {:dispatch :y}
[1 [:map [:x :int] [:y [:= 1]]]]
[2 [:map [:x :int] [:y [:= 2]]]]]))
(is (= (dist
[:merge
[:multi {:dispatch :y}
[1 [:map [:y [:= 1]]]]
[2 [:map [:y [:= 2]]]]]
[:map [:x :int]]])
[:merge
[:multi {:dispatch :y}
[1 [:map [:y [:= 1]]]]
[2 [:map [:y [:= 2]]]]]
[:map [:x :int]]])
[:multi {:dispatch :y}
[1 [:map [:y [:= 1]] [:x :int]]]
[2 [:map [:y [:= 2]] [:x :int]]]]))
(is (= (dist
[:merge
[:multi {:dispatch :y}
[1 [:map [:y [:= 1]]]]
[2 [:map [:y [:= 2]]]]]
[:map [:x :int]]
[:map [:z :int]]])
(dist
[:merge
[:merge
[:multi {:dispatch :y}
[1 [:map [:y [:= 1]]]]
[2 [:map [:y [:= 2]]]]]
[:map [:x :int]]
[:map [:z :int]]])
(dist
[:merge
[:merge
[:multi {:dispatch :y}
[1 [:map [:y [:= 1]]]]
[2 [:map [:y [:= 2]]]]]
[:map [:x :int]]]
[:map [:z :int]]])
[:map [:x :int]]]
[:map [:z :int]]])
[:multi {:dispatch :y}
[1 [:map [:y [:= 1]] [:x :int] [:z :int]]]
[2 [:map [:y [:= 2]] [:x :int] [:z :int]]]]))
(is (= (dist
[:merge
[:multi {:dispatch :y}
[1 [:map [:y [:= 1]]]]
[2 [:map [:y [:= 2]]]]]
[:map [:x :int]]
[:map [:z :int]]
[:multi {:dispatch :y}
[3 [:map [:y [:= 3]]]]
[4 [:map [:y [:= 4]]]]]])
[:merge
[:multi {:dispatch :y}
[1 [:map [:y [:= 1]]]]
[2 [:map [:y [:= 2]]]]]
[:map [:x :int]]
[:map [:z :int]]
[:multi {:dispatch :y}
[3 [:map [:y [:= 3]]]]
[4 [:map [:y [:= 4]]]]]])
(dist
[:merge
[:merge
[:merge
[:merge
[:multi {:dispatch :y}
[1 [:map [:y [:= 1]]]]
[2 [:map [:y [:= 2]]]]]
[:map [:x :int]]]
[:map [:z :int]]]
[:multi {:dispatch :y}
[3 [:map [:y [:= 3]]]]
[4 [:map [:y [:= 4]]]]]])
[1 [:map [:y [:= 1]]]]
[2 [:map [:y [:= 2]]]]]
[:map [:x :int]]]
[:map [:z :int]]]
[:multi {:dispatch :y}
[3 [:map [:y [:= 3]]]]
[4 [:map [:y [:= 4]]]]]])
[:multi {:dispatch :y}
[1 [:multi {:dispatch :y}
[3 [:map [:y [:= 3]] [:x :int] [:z :int]]]
Expand All @@ -91,15 +91,15 @@
[3 [:map [:y [:= 3]] [:x :int] [:z :int]]]
[4 [:map [:y [:= 4]] [:x :int] [:z :int]]]]]]))
(is (= (dist
[:merge
[:multi {:dispatch :y}
[1 [:map [:y [:= 1]]]]
[2 [:map [:y [:= 2]]]]]
[:map [:x :int]]
[:map [:z :int]]
[:multi {:dispatch :a}
[3 [:map [:a [:= 3]]]]
[4 [:map [:a [:= 4]]]]]])
[:merge
[:multi {:dispatch :y}
[1 [:map [:y [:= 1]]]]
[2 [:map [:y [:= 2]]]]]
[:map [:x :int]]
[:map [:z :int]]
[:multi {:dispatch :a}
[3 [:map [:a [:= 3]]]]
[4 [:map [:a [:= 4]]]]]])
[:multi {:dispatch :y}
[1 [:multi {:dispatch :a}
[3 [:map [:y [:= 1]] [:x :int] [:z :int] [:a [:= 3]]]]
Expand All @@ -108,13 +108,13 @@
[3 [:map [:y [:= 2]] [:x :int] [:z :int] [:a [:= 3]]]]
[4 [:map [:y [:= 2]] [:x :int] [:z :int] [:a [:= 4]]]]]]]))
(is (= (dist
[:merge
[:multi {:dispatch :y}
[1 [:map [:y [:= 1]]]]
[2 [:map [:y [:= 2]]]]]
[:multi {:dispatch :y}
[3 [:map [:y [:= 3]]]]
[4 [:map [:y [:= 4]]]]]])
[:merge
[:multi {:dispatch :y}
[1 [:map [:y [:= 1]]]]
[2 [:map [:y [:= 2]]]]]
[:multi {:dispatch :y}
[3 [:map [:y [:= 3]]]]
[4 [:map [:y [:= 4]]]]]])
[:multi {:dispatch :y}
[1 [:multi {:dispatch :y}
[3 [:map [:y [:= 3]]]]
Expand All @@ -123,13 +123,13 @@
[3 [:map [:y [:= 3]]]]
[4 [:map [:y [:= 4]]]]]]]))
(is (= (dist
[:merge
[:multi {:dispatch :y}
[1 [:map [:y [:= 1]]]]
[2 [:map [:y [:= 2]]]]]
[:multi {:dispatch :z}
[3 [:map [:z [:= 3]]]]
[4 [:map [:z [:= 4]]]]]])
[:merge
[:multi {:dispatch :y}
[1 [:map [:y [:= 1]]]]
[2 [:map [:y [:= 2]]]]]
[:multi {:dispatch :z}
[3 [:map [:z [:= 3]]]]
[4 [:map [:z [:= 4]]]]]])
[:multi {:dispatch :y}
[1 [:multi {:dispatch :z}
[3 [:map [:y [:= 1]] [:z [:= 3]]]]
Expand All @@ -141,25 +141,25 @@
(deftest parse-distributive-multi-test
(is (= [1 [3 {:y 1, :z 3}]]
(m/parse
[:merge
[:multi {:dispatch :y}
[1 [:map [:y [:= 1]]]]
[2 [:map [:y [:= 2]]]]]
[:multi {:dispatch :z}
[3 [:map [:z [:= 3]]]]
[4 [:map [:z [:= 4]]]]]]
{:y 1 :z 3}
options))))
[:merge
[:multi {:dispatch :y}
[1 [:map [:y [:= 1]]]]
[2 [:map [:y [:= 2]]]]]
[:multi {:dispatch :z}
[3 [:map [:z [:= 3]]]]
[4 [:map [:z [:= 4]]]]]]
{:y 1 :z 3}
options))))

(deftest gen-distributive-multi-test
(is (= [{:y 1, :z 3} {:y 2, :z 4} {:y 2, :z 3} {:y 2, :z 3} {:y 1, :z 4}
{:y 1, :z 3} {:y 1, :z 3} {:y 1, :z 3} {:y 1, :z 3} {:y 2, :z 4}]
(mg/sample
[:merge
[:multi {:dispatch :y}
[1 [:map [:y [:= 1]]]]
[2 [:map [:y [:= 2]]]]]
[:multi {:dispatch :z}
[3 [:map [:z [:= 3]]]]
[4 [:map [:z [:= 4]]]]]]
(assoc options :seed 0)))))
[:merge
[:multi {:dispatch :y}
[1 [:map [:y [:= 1]]]]
[2 [:map [:y [:= 2]]]]]
[:multi {:dispatch :z}
[3 [:map [:z [:= 3]]]]
[4 [:map [:z [:= 4]]]]]]
(assoc options :seed 0)))))
Loading
Loading