|
407 | 407 | (macroexpand '(expect (more-of {:keys [a b c]} 1 a 2 b 3 c) {:a 1 :b 2 :c 3})))
|
408 | 408 |
|
409 | 409 | (defn- contains-expect?
|
410 |
| - "Given a form, return `true` if it contains any calls to the 'expect' macro." |
| 410 | + "Given a form, return `true` if it contains any calls to the 'expect' macro. |
| 411 | +
|
| 412 | + As of #28, we also recognize qualified 'expect' calls." |
411 | 413 | [e]
|
412 | 414 | (when (and (coll? e) (not (vector? e)))
|
413 |
| - (or (= 'expect (first e)) |
| 415 | + (or (and (symbol? (first e)) |
| 416 | + (= "expect" (name (first e)))) |
414 | 417 | (some contains-expect? e))))
|
415 | 418 |
|
416 | 419 | (defmacro defexpect
|
|
419 | 422 |
|
420 | 423 | `(defexpect name expected actual)` is a special case shorthand for
|
421 | 424 | `(defexpect name (expect expected actual))` provided as an easy way to migrate
|
422 |
| - legacy Expectation tests to the 'clojure.test' compatibility version. |
423 |
| -
|
424 |
| - `(defexpect name actual)` is a special case shorthand for |
425 |
| - `(defexpect name (expect actual))` which is equivalent to |
426 |
| - `(deftest name (is actual))`" |
| 425 | + legacy Expectation tests to the 'clojure.test' compatibility version." |
427 | 426 | [n & body]
|
428 |
| - (if (and (<= (count body) 2) |
| 427 | + (if (and (= (count body) 2) |
429 | 428 | (not (some contains-expect? body)))
|
430 |
| - (if (<= (count body) 1) |
431 |
| - ;; #13 match deftest behavior starting in 2.0.0 |
432 |
| - `(t/deftest ~n ~@body) |
433 |
| - ;; but still treat (defexpect my-name pred (expr)) as a special case |
434 |
| - `(t/deftest ~n (expect ~@body))) |
| 429 | + ;; treat (defexpect my-name pred (expr)) as a special case |
| 430 | + `(t/deftest ~n (expect ~@body)) |
| 431 | + ;; #13 match deftest behavior starting in 2.0.0 |
435 | 432 | `(t/deftest ~n ~@body)))
|
436 | 433 |
|
437 | 434 | (defmacro expecting
|
|
0 commit comments