-
Notifications
You must be signed in to change notification settings - Fork 128
Tabular tests
marick edited this page Jan 13, 2011
·
1 revision
I hope Midje's syntax is concise enough that there's no need for a tabular notation like clojure.test's are
. For example, here's the use of are
from the clojure.test API:
(are [x y] (= x y)
2 (+ 1 1)
4 (* 2 2))
Here's the same sort of thing in Midje:
(facts "about arithmetic identities"
(let [n 33] ; represents an arbitrary integer
(+ 0 0) => 0
(+ n 0) => n
(* 1 1) => 1
(* n 1) => n))
Here's another example:
(facts "about my fast prime finder"
(let [n 29] ; represents an arbitrarily chosen prime (other than 2)
(nth (primes) 0) => 2
(nth (primes) 1) => 3
(nth (primes) n) => odd?
(nth (primes) n) => prime?))
Only time will tell if my hope is realistic.