Skip to content

Commit 1fef66d

Browse files
committed
add docstrings to matcher-combinators.test declarations
1 parent 3d88fc2 commit 1fef66d

4 files changed

Lines changed: 42 additions & 15 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ All notable changes to this project will be documented in this file. This
33
change log follows the conventions of
44
[keepachangelog.com](http://keepachangelog.com/).
55

6+
## 3.10.1 / 2026-04-13
7+
Add docstrings to matcher-combinators.test declarations, used with clojure.test
8+
69
## 3.10.0 / 2026-01-27
710
- Don't error on mismatches when `actual` value is a Datomic EntityMap.
811
- include reporting functions in standalone match result

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ This library addresses this issue by providing composable matcher combinators th
4141
Require the `matcher-combinators.test` namespace, which will extend `clojure.test`'s `is` macro to accept the `match?` and `thrown-match?` directives.
4242

4343
- `match?`: The first argument should be the matcher-combinator representing the expected value, and the second argument should be the expression being checked.
44-
- `thrown-match?`: The first argument should be a throwable subclass, the second a matcher-combinator, and the third the expression being checked.
44+
- `thrown-match?`: The first argument should be a throwable subclass, the second a matcher-combinator to be applied to the ex-data of the exception thrown, and the third the expression being checked. There is also a 2-arity version that takes just the matcher-combinator and expression.
4545

4646
For example:
4747

src/cljc/matcher_combinators/test.cljc

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,43 @@
1515
Commonly, a dev-only user namespace will require this namespace."
1616
(:require
1717
#?(:cljs [cljs.test :as t :refer-macros [is are deftest testing]]
18-
:clj [clojure.test :as t :refer [is are deftest testing]])
19-
#?(:cljs [matcher-combinators.cljs-test]
20-
:clj [matcher-combinators.clj-test])))
21-
22-
(declare ^{:arglists '([matcher actual])}
23-
match?)
24-
(declare ^{:arglists '([type->matcher matcher actual])}
25-
match-with?)
26-
(declare ^{:arglists '([matcher actual]
27-
[exception-class matcher actual])}
28-
thrown-match?)
29-
(declare ^{:arglists '([delta matcher actual])}
30-
match-roughly?)
18+
:clj [clojure.test :as t :refer [is are deftest testing]])
19+
#?(:cljs [matcher-combinators.cljs-test]
20+
:clj [matcher-combinators.clj-test])))
21+
22+
(defn match?
23+
"Asserts that the `actual` matches the `expected`, where the `expected` can be a value, a predicate function, or a matcher-combinator.
24+
25+
(is (match? [0 1 2] (range 3)))
26+
(is (match? (complement empty?) (range 3)))
27+
(is (match? (matcher-combinators.matchers/in-any-order [zero? odd? even?]) (range 3)))"
28+
[matcher actual]
29+
(throw (#?(:cljs js/Error. :clj AssertionError.)
30+
"Should only be invoked within a `clojure.test/is` form")))
31+
32+
(defn match-with?
33+
"DEPRECATED: Use (match? (matcher-combinators.matchers/match-with <type->matcher> <expected>) <actual>) instead."
34+
[type->matcher matcher actual]
35+
(throw (#?(:cljs js/Error. :clj AssertionError.)
36+
"Should only be invoked within a `clojure.test/is` form")))
37+
38+
(defn thrown-match?
39+
"Asserts that evaluating expr throws an exception where the excpetion's ex-data satisfies the provided matcher.
40+
41+
2-arity: (is (thrown-with-match? matcher expr))
42+
3-arity: (is (thrown-with-match? exception-class matcher expr))"
43+
([matcher actual]
44+
(throw (#?(:cljs js/Error. :clj AssertionError.)
45+
"Should only be invoked within a `clojure.test/is` form")))
46+
([exception-class matcher actual]
47+
(throw (#?(:cljs js/Error. :clj AssertionError.)
48+
"Should only be invoked within a `clojure.test/is` form"))))
49+
50+
(defn match-roughly?
51+
"DEPRECATED: Instead use (match? (matcher-combinators.matchers/match-with [number? (matcher-combinators.matchers/within-delta 0.01M)] <expected>) <actual>)"
52+
[delta matcher actual]
53+
(throw (#?(:cljs js/Error. :clj AssertionError.)
54+
"Should only be invoked within a `clojure.test/is` form")))
3155

3256
#?(:clj
3357
(def build-match-assert

version.edn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{:major 3
22
:minor 10
3-
:release 0
3+
:release 1
44
#_#_ :qualifier :alpha}

0 commit comments

Comments
 (0)