Re: How to unit test (defn-) functions?
Always test private functions through public ones. They have to use them. Private stuff should appear during refactoring phase. On Thursday, June 12, 2014 10:44:21 AM UTC+2, Hussein B. wrote: Hi, I like to use (defn-) when it comes to internal implementation functions. But since they aren't exposed, how to unit test them? Of course, I'm using Lein and clojure.test Thanks. -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
How to unit test (defn-) functions?
Hi, I like to use (defn-) when it comes to internal implementation functions. But since they aren't exposed, how to unit test them? Of course, I'm using Lein and clojure.test Thanks. -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: How to unit test (defn-) functions?
On 12 June 2014 09:44, Hussein B. hubaghd...@gmail.com wrote: Hi, I like to use (defn-) when it comes to internal implementation functions. But since they aren't exposed, how to unit test them? Of course, I'm using Lein and clojure.test It feels like a bit of a hack, but: (#'other-ns/private-fn ...) should get you by. -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: How to unit test (defn-) functions?
On 12 June 2014 09:44, Hussein B. hubaghd...@gmail.com wrote: I like to use (defn-) when it comes to internal implementation functions. But since they aren't exposed, how to unit test them? Generally speaking it's a bad idea to unit-test private functions (in any language), as they're implementation details. - James -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: How to unit test (defn-) functions?
You can use a macro. Look how on http://nakkaya.com/2009/11/18/unit-testing-in-clojure/ On Thursday, June 12, 2014 5:44:21 AM UTC-3, Hussein B. wrote: Hi, I like to use (defn-) when it comes to internal implementation functions. But since they aren't exposed, how to unit test them? Of course, I'm using Lein and clojure.test Thanks. -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: How to unit test (defn-) functions?
I say this too many times on this list, but I'll say it again. The best way to test defn- functions is to never use defn- in the first place. Instead move implementation functions into an internal namespace that way they can be accessed if needed, but are out of the way of the public api. It also makes it easier for your users to tap into the core of your library/application if needed. Trust your users to make good decisions, make everything public, separate via namespaces. For an example of this see: http://github.com/clojure/core.async Timothy On Thu, Jun 12, 2014 at 7:53 AM, mynomoto mynom...@gmail.com wrote: You can use a macro. Look how on http://nakkaya.com/2009/11/18/unit-testing-in-clojure/ On Thursday, June 12, 2014 5:44:21 AM UTC-3, Hussein B. wrote: Hi, I like to use (defn-) when it comes to internal implementation functions. But since they aren't exposed, how to unit test them? Of course, I'm using Lein and clojure.test Thanks. -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- “One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.” (Robert Firth) -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: How to unit test (defn-) functions?
Hey Timothy So I honestly don't mean to be a smart ass, but there are 6 defn- functions in clojure.core.async - how do you test those? Or are they just considered internals to other public functions? cheers, J On Thu, Jun 12, 2014 at 10:33 AM, Timothy Baldridge tbaldri...@gmail.com wrote: I say this too many times on this list, but I'll say it again. The best way to test defn- functions is to never use defn- in the first place. Instead move implementation functions into an internal namespace that way they can be accessed if needed, but are out of the way of the public api. It also makes it easier for your users to tap into the core of your library/application if needed. Trust your users to make good decisions, make everything public, separate via namespaces. For an example of this see: http://github.com/clojure/core.async Timothy On Thu, Jun 12, 2014 at 7:53 AM, mynomoto mynom...@gmail.com wrote: You can use a macro. Look how on http://nakkaya.com/2009/11/18/unit-testing-in-clojure/ On Thursday, June 12, 2014 5:44:21 AM UTC-3, Hussein B. wrote: Hi, I like to use (defn-) when it comes to internal implementation functions. But since they aren't exposed, how to unit test them? Of course, I'm using Lein and clojure.test Thanks. -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- “One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.” (Robert Firth) -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: How to unit test (defn-) functions?
There are 6 defn-'s in there? Rich must have wrote that code :-P . But yes, defn- is mostly used in clojure.core and other such libraries for functions that are created to simplify other functions. And I would probably never test those. Even then I would caution about using defn- too much as some have pointed out functions like clojure.core/assert-args is kindof handy, but it's private, so you can't touch it. Also, core.async tends to take a in the large view of testing. For example, the guts of the go macro are never tested. Instead the macro is tested in about 50 different ways. The idea being that if a single one of those tests fail it's easy to figure out what's wrong based on what passes and fails. Timothy On Thu, Jun 12, 2014 at 8:44 AM, J Irving j...@lollyshouse.ca wrote: Hey Timothy So I honestly don't mean to be a smart ass, but there are 6 defn- functions in clojure.core.async - how do you test those? Or are they just considered internals to other public functions? cheers, J On Thu, Jun 12, 2014 at 10:33 AM, Timothy Baldridge tbaldri...@gmail.com wrote: I say this too many times on this list, but I'll say it again. The best way to test defn- functions is to never use defn- in the first place. Instead move implementation functions into an internal namespace that way they can be accessed if needed, but are out of the way of the public api. It also makes it easier for your users to tap into the core of your library/application if needed. Trust your users to make good decisions, make everything public, separate via namespaces. For an example of this see: http://github.com/clojure/core.async Timothy On Thu, Jun 12, 2014 at 7:53 AM, mynomoto mynom...@gmail.com wrote: You can use a macro. Look how on http://nakkaya.com/2009/11/18/unit-testing-in-clojure/ On Thursday, June 12, 2014 5:44:21 AM UTC-3, Hussein B. wrote: Hi, I like to use (defn-) when it comes to internal implementation functions. But since they aren't exposed, how to unit test them? Of course, I'm using Lein and clojure.test Thanks. -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- “One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.” (Robert Firth) -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- “One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.” (Robert Firth) -- 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 --- You received this message because you are
Re: How to unit test (defn-) functions?
On Thu, Jun 12, 2014 at 7:33 AM, Timothy Baldridge tbaldri...@gmail.com wrote: I say this too many times on this list, but I'll say it again. The best way to test defn- functions is to never use defn- in the first place. Instead move implementation functions into an internal namespace that way they can be accessed if needed, but are out of the way of the public api. Just a note that I got essentially the opposite feedback from Clojure/core about java.jdbc some time back. It had an implementation namespace and an API namespace, and when I asked for feedback and what needed to be addressed before considering a 1.0.0 release (yes, I was planning well ahead), they said not to have a separate implementation namespace. So java.jdbc is one namespace, with implementation details as private functions now. -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ Perfection is the enemy of the good. -- Gustave Flaubert, French realist novelist (1821-1880) -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.