Skip to content

Commit fdf73d8

Browse files
committed
prep for 2.0.157
1 parent bd8438e commit fdf73d8

File tree

7 files changed

+32
-11
lines changed

7 files changed

+32
-11
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
Only accretive/fixative changes will be made from now on.
88

9+
* 2.0.157 -- 2022-01-25
10+
* Fix a small regression in how classes are treated when used as predicates in `expect`.
11+
912
* 2.0.156 -- 2022-01-19
1013
* Address [#26](https://github.com/clojure-expectations/clojure-test/issues/26) by adding an example combining `more->` and `more-of` around destructuring `ex-info` data.
1114
* Fix [#24](https://github.com/clojure-expectations/clojure-test/issues/24) by using a local (gensym) for the actual value in `more` and `more->` so it is only evaluated once.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ A `clojure.test`-compatible version of the [classic Expectations testing library
44

55
## Where?
66

7-
[![Clojars Project](https://clojars.org/com.github.seancorfield/expectations/latest-version.svg)](https://clojars.org/com.github.seancorfield/expectations) [![cljdoc badge](https://cljdoc.org/badge/com.github.seancorfield/expectations?2.0.156)](https://cljdoc.org/d/com.github.seancorfield/expectations/CURRENT)
7+
[![Clojars Project](https://clojars.org/com.github.seancorfield/expectations/latest-version.svg)](https://clojars.org/com.github.seancorfield/expectations) [![cljdoc badge](https://cljdoc.org/badge/com.github.seancorfield/expectations?2.0.157)](https://cljdoc.org/d/com.github.seancorfield/expectations/CURRENT)
88

99
Try it out:
1010

doc/getting-started-cljs.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Your `deps.edn` should include this information:
2020

2121
```clojure
2222
{:aliases {:cljs-runner
23-
{:extra-deps {com.github.seancorfield/expectations {:mvn/version "2.0.156"},
23+
{:extra-deps {com.github.seancorfield/expectations {:mvn/version "2.0.157"},
2424
olical/cljs-test-runner {:mvn/version "3.7.0"},
2525
pjstadig/humane-test-output {:mvn/version "0.10.0"}},
2626
:extra-paths ["src" "test" "cljs-test-runner-out/gen"],

doc/getting-started.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ You can add `expectations.clojure.test` to your project with either:
88

99
```clojure
1010
;; add this to :extra-deps under a :test alias:
11-
com.github.seancorfield/expectations {:mvn/version "2.0.156"}
11+
com.github.seancorfield/expectations {:mvn/version "2.0.157"}
1212
```
1313
for `deps.edn` or:
1414

1515
```clojure
1616
;; add this to :dev-dependencies (Leiningen)
17-
[com.github.seancorfield/expectations "2.0.156"]
17+
[com.github.seancorfield/expectations "2.0.157"]
1818
;; or add this to :dependencies (Boot)
19-
[com.github.seancorfield/expectations "2.0.156" :scope "test"]
19+
[com.github.seancorfield/expectations "2.0.157" :scope "test"]
2020
```
2121
for `project.clj` or `build.boot`.
2222

@@ -186,7 +186,7 @@ Of course, you can also update the `:test` alias to add those new options into `
186186
{:test
187187
{:extra-paths ["test"]
188188
:extra-deps
189-
{com.github.seancorfield/expectations {:mvn/version "2.0.156"}
189+
{com.github.seancorfield/expectations {:mvn/version "2.0.157"}
190190
;; assumes Clojure CLI 1.10.3.933 or later:
191191
io.github.cognitect-labs/test-runner
192192
{:git/tag "v0.5.0" :git/sha "48c3c67"}}

src/expectations/clojure/test.cljc

+6
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,12 @@
178178
#?(:clj java.util.regex.Pattern
179179
:cljs (type #"regex")))
180180
(some? (re-find e# a#))
181+
#?(:clj (and (class? e#) (class? a#))
182+
:cljs false) ; maybe figure this out later
183+
(isa? a# e#) ; (expect parent child)
184+
#?(:clj (class? e#)
185+
:cljs false) ; maybe figure this out later
186+
(instance? e# a#) ; (expect klazz object)
181187
:else
182188
(= e# a#))
183189
humane?# (and humane-test-output? (not (fn? e#)) (not ~conform?))]

test/expectations/clojure/test_macros.cljc

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,5 @@
4747
(with-redefs [do-report (sut/all-report results#)]
4848
~expectation)
4949
(t/is (some (fn [pass#]
50-
(~success (:actual pass#)))
51-
(:pass @results#)))))
50+
(~success (:actual pass#)))
51+
(:pass @results#)))))

test/expectations/clojure/test_test.cljc

+15-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

1414
#?(:clj [clojure.test :refer [deftest is do-report testing]]
1515
:cljs [cljs.test :include-macros true
16-
:refer [do-report assert-expr]
16+
:refer [do-report assert-expr]
1717
:refer-macros [deftest is testing assert-expr
18-
use-fixtures]])
18+
use-fixtures]])
1919
#?(:cljs [cljs.spec.alpha :as s])
2020
#?(:cljs [expectations.clojure.test-spec])
2121
#?(:clj [expectations.clojure.test :refer
@@ -59,13 +59,25 @@
5959
;; TODO: fails because regexes never compare equal to themselves!
6060
#_(is-not' (sut/expect #"fool" "It's foobar!") (not (re-find #"fool" "It's foobar!"))))
6161

62+
#?(:clj (def get-ex-message (or (resolve 'clojure.core/ex-message)
63+
(fn [^Throwable t] (.getMessage t))))
64+
:cljs (def get-ex-message ex-message))
65+
6266
#?(:clj (deftest exception-test
6367
(passes (sut/expect ArithmeticException (/ 12 0))
6468
(fn [ex]
6569
(let [t (Throwable->map ex)]
6670
(and (= "Divide by zero" (-> t :cause))
6771
(or (= 'java.lang.ArithmeticException (-> t :via first :type))
68-
(= java.lang.ArithmeticException (-> t :via first :type))))))))
72+
(= java.lang.ArithmeticException (-> t :via first :type)))))))
73+
(passes (sut/expect Exception (/ 12 0))
74+
(fn [ex]
75+
(let [t (Throwable->map ex)]
76+
(and (= "Divide by zero" (-> t :cause))
77+
(or (= 'java.lang.ArithmeticException (-> t :via first :type))
78+
(= java.lang.ArithmeticException (-> t :via first :type)))))))
79+
(is (sut/expect (more-> ArithmeticException type #"Divide by zero" get-ex-message) (/ 12 0)))
80+
(is (sut/expect (more-> Exception type #"Divide by zero" get-ex-message) (/ 12 0))))
6981

7082
:cljs (deftest cljs-exception-test
7183
(passes (sut/expect js/Error (throw (ex-info "foo" {})))

0 commit comments

Comments
 (0)