midje

hrtmt brng 2025-03-22T20:38:25.854039Z

If someone wants the Midje arrow syntax without Midje, I have a small macro that seams doing it.

(defn test-and-expect [[expr arrow & args]]
  (cond (= arrow '=>) [`(clojure.test/is (= ~expr ~(first args)))
                       (rest args)]))

(defmacro protocol [& args]
  (loop [lines []
         more-args args]
    (if (empty? more-args) lines
        (let [[test still-more-args] (test-and-expect more-args)]
          (recur (conj lines test)
                 still-more-args)))))

(protocol (inc 4) => 5
          (dec 4) => 5
          (+ 2 3) => 5)
; => [true false true]
I know, it is not popular, and it has downsides. I don't want to advertise it. But I still like it. I imagine it as something like a test protocol.

2025-03-22T20:44:33.870779Z

oh hell yeah

👍 1
2025-03-22T20:45:02.960369Z

i thought about adding something liek this to #lazytest for the experimental midje syntax support, so this would be very nice