Skip to content

Commit 623c843

Browse files
committed
more tests
1 parent 608533f commit 623c843

File tree

1 file changed

+76
-10
lines changed

1 file changed

+76
-10
lines changed

test/malli/core_test.cljc

+76-10
Original file line numberDiff line numberDiff line change
@@ -3549,13 +3549,79 @@
35493549
(is (nil? (m/explain [:sequential {:min 9} :int] (eduction identity (range 10))))))
35503550

35513551
(deftest non-flowing-and-test
3552-
(is (= (m/tags {"a" 3, "b" :x})
3553-
(m/parse [:and [:catn ["a" :int] ["b" :keyword]] [:fn any?]] [3 :x])))
3554-
(is (= ::m/invalid
3555-
(m/parse [:and [:catn ["a" :int] ["b" :keyword]]
3556-
[:fn vector?]]
3557-
[3 :x])))
3558-
(is (= (m/tags {"a" 3, "b" :x})
3559-
(m/parse [:and {:parse :non-flowing} [:catn ["a" :int] ["b" :keyword]]
3560-
[:fn vector?]]
3561-
[3 :x]))))
3552+
(testing "flowing"
3553+
(is (= (m/tags {"a" 3, "b" :x})
3554+
(m/parse [:and [:catn ["a" :int] ["b" :keyword]] [:fn any?]] [3 :x])))
3555+
(testing "m/tags is not a vector, so fails second child"
3556+
(is (= ::m/invalid
3557+
(m/parse [:and
3558+
[:catn ["a" :int] ["b" :keyword]]
3559+
[:fn vector?]]
3560+
[3 :x]))))
3561+
(testing "m/tags is map, so succeeds second child"
3562+
(is (= (m/tags {"a" 3, "b" :x})
3563+
(m/parse [:and
3564+
[:catn ["a" :int] ["b" :keyword]]
3565+
[:fn map?]]
3566+
[3 :x])))))
3567+
(testing "non-flowing"
3568+
(testing "one child"
3569+
(testing "parses successfully"
3570+
(is (= (m/tags {"a" 3, "b" :x})
3571+
(m/parse [:and {:parse :non-flowing}
3572+
[:catn ["a" :int] ["b" :keyword]]]
3573+
[3 :x]))))
3574+
(testing "first child fails"
3575+
(is (= ::m/invalid
3576+
(m/parse [:and {:parse :non-flowing}
3577+
[:catn ["a" :boolean] ["b" :keyword]]]
3578+
[3 :x])))))
3579+
(testing "two children"
3580+
(testing "parses successfully"
3581+
(is (= (m/tags {"a" 3, "b" :x})
3582+
(m/parse [:and {:parse :non-flowing}
3583+
[:catn ["a" :int] ["b" :keyword]]
3584+
[:fn vector?]]
3585+
[3 :x]))))
3586+
(testing "first child fails"
3587+
(is (= ::m/invalid
3588+
(m/parse [:and {:parse :non-flowing}
3589+
[:catn ["a" :boolean] ["b" :keyword]]
3590+
[:fn map?]]
3591+
[3 :x]))))
3592+
(testing "second child fails"
3593+
(is (= ::m/invalid
3594+
(m/parse [:and {:parse :non-flowing}
3595+
[:catn ["a" :int] ["b" :keyword]]
3596+
[:fn map?]]
3597+
[3 :x])))))
3598+
(testing "three children"
3599+
(testing "parses successfully"
3600+
(is (= (m/tags {"a" 3, "b" :x})
3601+
(m/parse [:and {:parse :non-flowing}
3602+
[:catn ["a" :int] ["b" :keyword]]
3603+
[:fn vector?]
3604+
[:fn seq]]
3605+
[3 :x]))))
3606+
(testing "first child fails"
3607+
(is (= ::m/invalid
3608+
(m/parse [:and {:parse :non-flowing}
3609+
[:catn ["a" :boolean] ["b" :keyword]]
3610+
[:fn vector?]
3611+
[:fn seq]]
3612+
[3 :x]))))
3613+
(testing "second child fails"
3614+
(is (= ::m/invalid
3615+
(m/parse [:and {:parse :non-flowing}
3616+
[:catn ["a" :int] ["b" :keyword]]
3617+
[:fn map?]
3618+
[:fn seq]]
3619+
[3 :x]))))
3620+
(testing "third child fails"
3621+
(is (= ::m/invalid
3622+
(m/parse [:and {:parse :non-flowing}
3623+
[:catn ["a" :int] ["b" :keyword]]
3624+
[:fn vector?]
3625+
[:fn map?]]
3626+
[3 :x]))))))
3627+
)

0 commit comments

Comments
 (0)