A good pattern to follow would be to have your exposed functions in
one clj file and any dependent functions (your private ones in this
case) in a separate ns (i.e. separate clj file). This hides the
implementation to the caller as well as gives them a good idea of the
functions they're able to us
Brian Marick wrote:
> 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
On Mon, Jun 27, 2011 at 2:13 AM, Stephen C. Gilardi wrote:
> As Rich noted
> here: http://groups.google.com/group/clojure/msg/513367afb934d41b , when the
> var names a function and it's used in an expression emitted from a
> macro, prefer invoking the var:
> (#'some-ns/some-private-var some args)
On Jun 18, 2011, at 7:16 AM, Stuart Halloway wrote:
> To access a private var, simply deref through the var:
>
> @#'some-ns/some-private-var
As Rich noted here: http://groups.google.com/group/clojure/msg/513367afb934d41b
, when the var names a function and it's used in an expression emitted fr
On Sat, Jun 18, 2011 at 7:16 AM, Stuart Halloway
wrote:
> To access a private var, simply deref through the var:
> @#'some-ns/some-private-var
> This is in the coding standards doc
> (http://dev.clojure.org/display/design/Library+Coding+Standards). The doc is
> pretty short and worth reading if yo
>>(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 wor
The best way to test private methods is to have very few of them. Test the
ones you do have via the public API, and if you have too many then IMHO they
should be public methods in a separate namespace. Separate the two
namespaces by responsibility. I do this all the time on OOP languages, and
th
If you're in a repl*, why not simply use (in-ns ) ?
Of course, this wont work in all cases (e.g. testing private functions from
two different namespaces).
In that case, I find it simpler to remove the '-' temporary. When you're
finished, it really doesn't take that much effort to add them again.
J
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 tes
Benjamin Esham writes:
Hi Benjamin,
> (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
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
t
11 matches
Mail list logo