Skip to content

Commit 4196a90

Browse files
committed
updated all tests to use t/ and created is-spec-check and is-spec-check-with-gen
1 parent 26b1e67 commit 4196a90

File tree

2 files changed

+35
-14
lines changed

2 files changed

+35
-14
lines changed

src/provisdom/test/core.cljc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,3 +486,24 @@
486486
([name sym-or-syms] `(defspec-test ~name ~sym-or-syms nil))
487487
([name sym-or-syms opts]
488488
`(t/deftest ~name (do-spec-check-report ~sym-or-syms ~opts))))
489+
490+
#?(:clj (defmacro is-spec-check
491+
"Runs generative tests for spec conformance and reports results.
492+
Equivalent to (is (spec-check ...)) but more direct.
493+
494+
See `spec-check` for available options."
495+
([sym-or-syms] `(is-spec-check ~sym-or-syms {}))
496+
([sym-or-syms opts]
497+
`(do-spec-check-report ~sym-or-syms ~opts))))
498+
499+
#?(:clj (defmacro is-spec-check-with-gen
500+
"Runs generative tests with custom generators and reports results.
501+
Takes gen-map as first argument for convenience when custom generators
502+
are always needed.
503+
504+
gen-map is a map from spec names to generator functions.
505+
See `spec-check` for other available options."
506+
([gen-map sym-or-syms] `(is-spec-check-with-gen ~gen-map ~sym-or-syms {}))
507+
([gen-map sym-or-syms opts]
508+
(let [merged-opts (merge {:gen gen-map} opts)]
509+
`(do-spec-check-report ~sym-or-syms ~merged-opts)))))

test/provisdom/test/core_test.cljc

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -171,17 +171,17 @@
171171
(t/is-valid int? 1))
172172

173173
(deftest data-approx=-test
174-
(is (t/data-approx=
175-
{:a 1.0
176-
:b #{1.0}}
177-
{:a 1.0000001
178-
:b #{1.0}}))
179-
(is (t/data-approx=
180-
{:a 1.0}
181-
{:a 1.001}
182-
{:tolerance 1e-2}))
183-
(is (t/data-approx= [[1.0000001]] [[1.0]]))
184-
(is (not (t/data-approx= {:a 1} {:b 1})))
185-
(is (not (t/data-approx=
186-
{:a 1.0}
187-
{:a 1.01}))))
174+
(t/is-data-approx=
175+
{:a 1.0
176+
:b #{1.0}}
177+
{:a 1.0000001
178+
:b #{1.0}})
179+
(t/is-data-approx=
180+
{:a 1.0}
181+
{:a 1.001}
182+
:tolerance 1e-2)
183+
(t/is-data-approx= [[1.0000001]] [[1.0]])
184+
(t/is-not (#'t/data-approx= {:a 1} {:b 1}))
185+
(t/is-not (#'t/data-approx=
186+
{:a 1.0}
187+
{:a 1.01})))

0 commit comments

Comments
 (0)