Hi Tim, There's a simple unit testing library in clojure.contrib.test-is. Look at the source code comments there for examples of how you can define tests.
-Stuart Sierra On Oct 21, 7:57 am, Timothy Pratley <[EMAIL PROTECTED]> wrote: > I've noticed around the place a few hints at testing capabilities such > as > (test v) > and contrib having a run tests, but I'm at a bit of a loss as to how > it fits together. If there is a good example I can take a look at > please point me toward it. > > Generally what I've been doing is writting a test case at the bottom > of my function and commenting it out when I see the correct output. > But if there is a more formal definition I'd prefer to use that. > > (defn poly-expand [points] > (loop [aa (first points) remaining (rest points) built (empty > points)] > (if (empty? remaining) > (concat built [aa (first points)]) > (recur (first remaining) (rest remaining) (concat built [aa > (first remaining)]))))) > ;(pr (poly-expand '(a b c d))) > ; -> (a b b c c d d a) ie: lines of polygon connected > > I imagine what I should be doing is somehow attaching a :test metadata > which checks that a given input equates to a given output, I just need > an example to follow. Coming from an imperitive background, I have to > say that unit testing seems to be one of the stand out advantages to > the functional approach. I can't even begin to imagine how to > represent test cases for the C/C++ projects I've worked on hahahahaha, > but it just feels like a natural part of the development cycle in > clojure which is really great. > > Regards, > Tim. --~--~---------~--~----~------------~-------~--~----~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---