Skip to content

Commit

Permalink
fix expected vs. actual ordering
Browse files Browse the repository at this point in the history
We write

  (+ 2 3) := 5

, but clojure.test users write

  (t/is (= 5 (+ 2 3)))

, i.e. the expected/actual ordering is the other way around. This commit
reorders the arguments to match clojure.test convention, which is
important for interop with the ecosystem. E.g. matcher-combinators
match? creates a diff like

  (mismatch (expected 2) (actual 1))

and if we don't order expected/actual correctly the error will be
confusing at best.
  • Loading branch information
xificurC committed Oct 7, 2022
1 parent 932cf6b commit 6ce363b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/hyperfiddle/rcf/impl.clj
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@
(loop [ss (:statements do-ast)
r []]
(if (>= (count ss) 3)
(let [[a b c] ss]
(if (sigil? b)
(recur (drop 3 ss) (conj r (rewrite-infix env a b c)))
(recur (rest ss) (conj r a))))
(let [[?actual ?op ?expected] ss]
(if (sigil? ?op)
(recur (drop 3 ss) (conj r (rewrite-infix env ?expected ?op ?actual)))
(recur (rest ss) (conj r ?actual))))
(into r ss))))))
ast))

Expand Down Expand Up @@ -382,7 +382,7 @@
;; (is (thrown? c expr))
;; Asserts that evaluating expr throws an exception of class c.
;; Returns the exception thrown.
(let [[body klass] (rest form)]
(let [[klass body] (rest form)]
`(try ~body
(do-report {:type :hyperfiddle.rcf/fail, :message ~msg,
:expected '~form, :actual nil})
Expand Down

0 comments on commit 6ce363b

Please # to comment.