Skip to content

Instantly share code, notes, and snippets.

@wilkes
Created January 28, 2011 20:52
Show Gist options
  • Save wilkes/800925 to your computer and use it in GitHub Desktop.
Save wilkes/800925 to your computer and use it in GitHub Desktop.
testing higher order functions with midje 1.0.1
(ns higer-order
(:use midje.sweet))
(defn sum-with [f vs]
(apply + (map f vs)))
(defn double [x]
(* x 2))
(defn sum-double [xs]
(sum-with double xs))
;.;. FAIL at (NO_SOURCE_FILE:1)
;.;. You never said sum-with would be needed with these arguments:
;.;. (#<higer_order$double higer_order$double@6cd0a64a> ...list...)
;.;.
;.;. FAIL at (NO_SOURCE_FILE:1)
;.;. You claimed the following was needed, but it was never used:
;.;. (sum-with double ...list...)
;.;.
;.;. FAIL at (NO_SOURCE_FILE:1)
;.;. Expected: ...sum...
;.;. Actual: (nil nil nil)
(fact ""
(sum-double ...list...) => ...sum...
(provided
(sum-with double ...list...) => ...sum...))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment