On Jun 17, 2011, at 1:21 PM, Benjamin Esham wrote:
> 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).
I put the private functions in their own namespace that's :used by the API
namespace.
(ns midje.sweet
(:use midje.midje-forms.recognizing ...
-----------
(ns midje.t-sweet ;;; Corresponding file of tests.
(:use [midje.sweet])
(:use [midje.test-util]))
;;; Since Midje is a testing tool, I'm using it to test itself.
;;; Here I'm testing `tabular`, which is part of the public API
(tabular
(fact (+ ?a ?b) => ?result )
?a ?b ?result
1 2 3)
------------
(ns midje.midje-forms.recognizing .... ;;; Helper functions.
(defn loc-is-at-full-expect-form? [loc]
(and (zip/branch? loc)
(namespacey-match '(expect) (zip/down loc))))
-----------
(ns midje.midje-forms.t-recognizing ... ;;; and their tests
(tabular
(fact "an embedded expect form can be recognized"
(loc-is-at-full-expect-form? (zip/seq-zip ?form)) => ?expected)
?form ?expected
'(expect x => y) truthy
'(midje.semi-sweet/expect x => y) truthy
'(+ x y) falsey
'expect falsey)
-----
Brian Marick, Artisanal Labrador
Contract programming in Ruby and Clojure
Occasional consulting on Agile
www.exampler.com, 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 [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
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