Hi all, I am writing a library [1] which has only one function that should be exposed to users. I'd like to be able to test all of the other functions, which are marked private with "defn-". Of course, these functions are inaccessible from the testing namespace (I'm using the testing boilerplate that Leiningen generates).
[1]: https://github.com/bdesham/clj-schulze I searched the mailing list archives for an answer to this problem, and I found one thread [2] which defined a macro "defn*" which would expand to defn or defn-, depending on whether testing was going on. I also found a thread [3] in which Stuart Sierra proposed (defn refer-private [ns] (doseq [[symbol var] (ns-interns ns)] (when (:private (meta var)) (intern *ns* symbol var)))) As he says, "this is slightly evil, and I would never recommend it for any purpose except unit testing, but there it is." This works, and the macro approach also makes sense to me. But these threads are respectively three and two years old. Have there been any changes in Clojure since then which solve this problem or provide a recommended workaround? [2]: http://groups.google.com/group/clojure/browse_thread/thread/2b00d48f009d4837/631c3edf625bc88b [3]: http://groups.google.com/group/clojure/browse_thread/thread/3835e5405ab930f6/66f15396411e49e9 (You might tell me that I should only test the user-facing parts of the library, since everything else is implementation details and these shouldn't be reflected in tests. I agree in principle, but this library implements an election method: it takes a bunch of ballots and returns only the name of the winning candidate. Given how little information comes out of this function, and the possibility that something could be going horribly wrong behind the scenes without this being reflected in the final result, I'd rather be safe than sorry and test all of the library's intermediate steps.) Thanks for the information! -- Benjamin D. Esham | bdes...@gmail.com | www.bdesham.info L’APOSTROPHE: Let our battle’s begin! BOB THE ANGRY FLOWER: God, you even _say_ it wrong! — http://www.angryflower.com/plural.gif -- 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