Skip to content

Instantly share code, notes, and snippets.

@pepijndevos
Created September 15, 2010 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pepijndevos/580719 to your computer and use it in GitHub Desktop.
Save pepijndevos/580719 to your computer and use it in GitHub Desktop.
(defn test [function]
(doseq [tests (:tests (meta function))]
(assert (= (apply function (key tests)) (val tests)))))
;define a macro like deftestedfn for this
(def tested+ (with-meta + {:tests {[1 2 3] 6, [5 5] 10}}))
(test tested+)
;true
(def tested+ (with-meta + {:tests {[1 2] 4}}))
(test tested+)
; java.lang.AssertionError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment