Skip to content

Commit b90ed5b

Browse files
committed
fixes #39 by ignoring qualifiers when checking nested calls
Signed-off-by: Sean Corfield <[email protected]>
1 parent 9fea734 commit b90ed5b

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
Only accretive/fixative changes will be made from now on.
88

99
* 2.1.next in progress
10+
* Address [#39](https://github.com/clojure-expectations/clojure-test/issues/39) by ignoring qualifier on Expectations' macros. This is potentially breaking but is required for migration (to LazyTest, for example).
1011
* Address [#36](https://github.com/clojure-expectations/clojure-test/issues/36) by expanding `side-effects` documentation, and mentioning `with-redefs`.
1112
* Expose `run-test` and `run-test-var` from `clojure.test` (Clojure 1.11).
1213
* Update dev/test dependencies.

src/expectations/clojure/test.cljc

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,9 @@
300300
([e a] `(expect ~e ~a nil true ~e))
301301
([e a msg] `(expect ~e ~a ~msg true ~e))
302302
([e a msg ex? e']
303-
(let [within (if (and (sequential? e') (= 'expect (first e')))
303+
(let [within (if (and (sequential? e')
304+
(symbol? (first e'))
305+
(= "expect" (name (first e'))))
304306
`(pr-str '~e')
305307
`(pr-str (list '~'expect '~e' '~a)))
306308
msg' `(str/join
@@ -313,15 +315,19 @@
313315
:else
314316
(conj (str (pr-str '~a) "\n"))))]
315317
(cond
316-
(and (sequential? a) (= 'from-each (first a)))
318+
(and (sequential? a)
319+
(symbol? (first a))
320+
(= "from-each" (name (first a))))
317321
(let [[_ bindings & body] a]
318322
(if (= 1 (count body))
319323
`(doseq ~bindings
320324
(expect ~e ~(first body) ~msg ~ex? ~e))
321325
`(doseq ~bindings
322326
(expect ~e (do ~@body) ~msg ~ex? ~e))))
323327

324-
(and (sequential? a) (= 'in (first a)))
328+
(and (sequential? a)
329+
(symbol? (first a))
330+
(= "in" (name (first a))))
325331
(let [form `(~'expect ~e ~a)]
326332
`(let [e# ~e
327333
a# ~(second a)
@@ -370,12 +376,16 @@
370376
:else
371377
(throw (illegal-argument "'in' requires map or sequence")))))
372378

373-
(and (sequential? e) (= 'more (first e)))
379+
(and (sequential? e)
380+
(symbol? (first e))
381+
(= "more" (name (first e))))
374382
(let [sa (gensym)
375383
es (mapv (fn [e] `(expect ~e ~sa ~msg ~ex? ~e')) (rest e))]
376384
`(let [~sa (? ~a)] ~@es))
377385

378-
(and (sequential? e) (= 'more-> (first e)))
386+
(and (sequential? e)
387+
(symbol? (first e))
388+
(= "more->" (name (first e))))
379389
(let [sa (gensym)
380390
es (mapv (fn [[e a->]]
381391
(if (and (sequential? a->)
@@ -388,7 +398,9 @@
388398
(partition 2 (rest e)))]
389399
`(let [~sa (? ~a)] ~@es))
390400

391-
(and (sequential? e) (= 'more-of (first e)))
401+
(and (sequential? e)
402+
(symbol? (first e))
403+
(= "more-of" (name (first e))))
392404
(let [es (mapv (fn [[e a]] `(expect ~e ~a ~msg ~ex? ~e'))
393405
(partition 2 (rest (rest e))))]
394406
`(let [~(second e) ~a] ~@es))

0 commit comments

Comments
 (0)