Shameless Self-promotion Dept: Here's how I'd write your three tests in Midje.
https://github.com/marick/Midje

(fact "chains of locations are handled"
  (distances "Boston,MA" "Albany,NY" "LosAngeles,CA") => [2.0, 2.0]
  (provided (dist-in-miles anything anything) => 2.0))

(fact "can convert distances from origin to a map keyed by destination"
  (map-of-distances ...origin... "Newport", "LA") => { "Newport" 55, "LA" 3000 }
  (provided
    (dist-in-miles ...origin... "Newport") => 55
    (dist-in-miles ...origin... "LA") => 3000))

;; (fact "can also produce map of total distance (distance * number of visits)"
;;   (relative-distances ...origin..., "Newport" 1, "LA" 2) => { "NewPort" 
365.0, "LA" 730.0 }
;;   (provided
;;     (dist-in-miles ...origin... anything) => 365.0))

The last test is commented out because you have a three argument fmap, which 
isn't the one from generic.functor.

I didn't have the laziness problem. I don't know if that was by accident or 
because Midje applies an #'eagerly function before checking. (Note: I found 
that #'doall isn't always enough, because you can be bitten in the same way by 
laziness in nested expressions, so #'eagerly walks the whole tree, not just the 
top level.) 

-----
Brian Marick, Artisanal Labrador
Contract programming in Ruby and Clojure
Author of /Ring/ (forthcoming; sample: http://bit.ly/hfdf9T)
www.exampler.com, www.exampler.com/blog, www.twitter.com/marick

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to