|
300 | 300 | ([e a] `(expect ~e ~a nil true ~e))
|
301 | 301 | ([e a msg] `(expect ~e ~a ~msg true ~e))
|
302 | 302 | ([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')))) |
304 | 306 | `(pr-str '~e')
|
305 | 307 | `(pr-str (list '~'expect '~e' '~a)))
|
306 | 308 | msg' `(str/join
|
|
313 | 315 | :else
|
314 | 316 | (conj (str (pr-str '~a) "\n"))))]
|
315 | 317 | (cond
|
316 |
| - (and (sequential? a) (= 'from-each (first a))) |
| 318 | + (and (sequential? a) |
| 319 | + (symbol? (first a)) |
| 320 | + (= "from-each" (name (first a)))) |
317 | 321 | (let [[_ bindings & body] a]
|
318 | 322 | (if (= 1 (count body))
|
319 | 323 | `(doseq ~bindings
|
320 | 324 | (expect ~e ~(first body) ~msg ~ex? ~e))
|
321 | 325 | `(doseq ~bindings
|
322 | 326 | (expect ~e (do ~@body) ~msg ~ex? ~e))))
|
323 | 327 |
|
324 |
| - (and (sequential? a) (= 'in (first a))) |
| 328 | + (and (sequential? a) |
| 329 | + (symbol? (first a)) |
| 330 | + (= "in" (name (first a)))) |
325 | 331 | (let [form `(~'expect ~e ~a)]
|
326 | 332 | `(let [e# ~e
|
327 | 333 | a# ~(second a)
|
|
370 | 376 | :else
|
371 | 377 | (throw (illegal-argument "'in' requires map or sequence")))))
|
372 | 378 |
|
373 |
| - (and (sequential? e) (= 'more (first e))) |
| 379 | + (and (sequential? e) |
| 380 | + (symbol? (first e)) |
| 381 | + (= "more" (name (first e)))) |
374 | 382 | (let [sa (gensym)
|
375 | 383 | es (mapv (fn [e] `(expect ~e ~sa ~msg ~ex? ~e')) (rest e))]
|
376 | 384 | `(let [~sa (? ~a)] ~@es))
|
377 | 385 |
|
378 |
| - (and (sequential? e) (= 'more-> (first e))) |
| 386 | + (and (sequential? e) |
| 387 | + (symbol? (first e)) |
| 388 | + (= "more->" (name (first e)))) |
379 | 389 | (let [sa (gensym)
|
380 | 390 | es (mapv (fn [[e a->]]
|
381 | 391 | (if (and (sequential? a->)
|
|
388 | 398 | (partition 2 (rest e)))]
|
389 | 399 | `(let [~sa (? ~a)] ~@es))
|
390 | 400 |
|
391 |
| - (and (sequential? e) (= 'more-of (first e))) |
| 401 | + (and (sequential? e) |
| 402 | + (symbol? (first e)) |
| 403 | + (= "more-of" (name (first e)))) |
392 | 404 | (let [es (mapv (fn [[e a]] `(expect ~e ~a ~msg ~ex? ~e'))
|
393 | 405 | (partition 2 (rest (rest e))))]
|
394 | 406 | `(let [~(second e) ~a] ~@es))
|
|
0 commit comments