Skip to content

Commit d04a7fc

Browse files
committed
Rename to nested-equals
1 parent 6f8cef9 commit d04a7fc

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ 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.9.0 / 2024-01-26
7-
- Add `strictly-equals` matcher, which always uses `equals` matcher at every level of nesting.
6+
## 3.9.0 / 2024-02-01
7+
- Add `nested-equals` matcher, which always uses `equals` matcher at every level of nesting.
88

99
## 3.8.8 / 2023-09-04
1010
- refine abbreviation logic to not descend into fully mismatched data, because

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ for a specific value, e.g.
163163
- Note: Given that the default matcher for maps is `embeds`, nested maps continue being matched with embeds (instead of also being matched with `equals`). Check out 'Overriding default matchers' below for instructions on how to match nested maps with equals too.
164164
- sequence: matches when the `expected` sequences's matchers match the given sequence. Similar to midje's `(just expected)`
165165
- set: matches when all the elements in the given set can be matched with a matcher in `expected` set and each matcher is used exactly once.
166-
- `strictly equals`: overrides map's default matchers to `equals`, using it for nested structures (see Overriding default matchers, below)
166+
- `nested-equals`: overrides map's default matchers to `equals`, using it for nested structures (see Overriding default matchers, below)
167167
- `embeds` operates over maps, sequences, and sets
168168
- map: matches when the map contains some of the same key/values as the `expected` map.
169169
- sequence: order-agnostic matcher that will match when provided a subset of the `expected` sequence. Similar to midje's `(contains expected :in-any-order :gaps-ok)`
@@ -265,11 +265,11 @@ For example, if you want to do exact map matching you need to use a log of `m/eq
265265
{:a {:b {:c 1 :extra-c 0} :extra-b 0} :extra-a 0})))
266266
```
267267

268-
For convenience we've also added the built-in matcher `strictly-equals` to reduce this verbosity:
268+
For convenience we've also added the built-in matcher `nested-equals` to reduce this verbosity:
269269

270270
``` clojure
271271
(deftest exact-map-matching-with-match-with
272-
(is (match? (m/strictly-equals {:a {:b {:c odd?}}}))
272+
(is (match? (m/nested-equals {:a {:b {:c odd?}}}))
273273
{:a {:b {:c 1}}}))
274274
```
275275

src/cljc/matcher_combinators/matchers.cljc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
(declare match-with)
3535

36-
(defn strictly-equals
36+
(defn nested-equals
3737
"A matcher that always uses the `equals` matcher at every level of nesting.
3838
3939
Useful given that matchers usually only change the first level of the data

test/clj/matcher_combinators/matchers_test.clj

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -361,16 +361,16 @@
361361
:d (m/embeds {:e {:inner-e {:x 1 :y 2}}})}})
362362
actual)))))
363363

364-
(deftest strictly-equals-matcher
364+
(deftest nested-equals-matcher
365365
(testing "nested maps"
366366
(testing "passing case"
367-
(is (match? (m/strictly-equals {:user1 {:id 5 :name "hennix"}
367+
(is (match? (m/nested-equals {:user1 {:id 5 :name "hennix"}
368368
:user2 {:id 3 :name "flynt"}})
369369
{:user1 {:id 5 :name "hennix"}
370370
:user2 {:id 3 :name "flynt"}})))
371371

372-
(testing "`strictly-equals` fails when nested maps have extra keys"
373-
(is (no-match? (m/strictly-equals {:user1 {:id 5}
372+
(testing "`nested-equals` fails when nested maps have extra keys"
373+
(is (no-match? (m/nested-equals {:user1 {:id 5}
374374
:user2 {:id 3}})
375375
{:user1 {:id 5 :name "hennix"}
376376
:user2 {:id 3 :name "flynt"}})))
@@ -381,24 +381,24 @@
381381
{:user1 {:id 5 :name "hennix"}
382382
:user2 {:id 3 :name "flynt"}})))
383383

384-
(testing "`strictly-equals` is similar to using `equals` in each map"
384+
(testing "`nested-equals` is similar to using `equals` in each map"
385385
(is (no-match? (m/equals {:user1 (m/equals {:id 5})
386386
:user2 (m/equals {:id 3})})
387387
{:user1 {:id 5 :name "hennix"}
388388
:user2 {:id 3 :name "flynt"}}))))
389389

390390
(testing "functions"
391-
(testing "`strictly-equals` does not apply `equals` to functions"
392-
(is (match? (m/strictly-equals {:x odd?})
391+
(testing "`nested-equals` does not apply `equals` to functions"
392+
(is (match? (m/nested-equals {:x odd?})
393393
{:x 1})))
394394

395395
(testing "`equals` should be aplied directly to the function to fail"
396396
(is (no-match? (m/equals {:x (m/equals odd?)})
397397
{:x 1}))))
398398

399399
(testing "regex"
400-
(testing "`strictly-equals` does not apply `equals` to regex"
401-
(is (match? (m/strictly-equals {:x (m/regex #"\w+")})
400+
(testing "`nested-equals` does not apply `equals` to regex"
401+
(is (match? (m/nested-equals {:x (m/regex #"\w+")})
402402
{:x "abc"})))
403403

404404
(testing "`equals` should be aplied directly to the regex to fail"

0 commit comments

Comments
 (0)