ANN: libraries promoted from contrib to clojure

4 views
Skip to first unread message

Stuart Halloway

unread,
Jun 25, 2009, 10:40:41 PM6/25/09
to clo...@googlegroups.com
If you are following the github head of the Clojure and contrib
projects, you will see that several libraries have moved from contrib
into Clojure:

* clojure.contrib.test-is becomes clojure.test
* clojure.contrib.stacktrace becomes clojure.stacktrace
* clojure.contrib.template becomes clojure.template
* clojure.contrib.walk becomes clojure.walk

Thanks to Stuart Sierra for writing all these libraries. If you are
using one of them (and working with head), you will need to rename it
in your use/require/ns forms. Also, the signature and implementation
of test/are has changed, and is now more idiomatic. For example:

(deftest test-count
(are [x y] (= x y) ; instead of (are (= _1 _2))
(count nil) 0
(count ()) 0
(count '(1)) 1
(count '(1 2 3)) 3
; etc.

The purpose of this change (other than the general usefulness of the
libraries!) is to let Clojure host its own test suite. You can now run
Clojure's tests with "ant test".

Go ye now, sign the CA, and write some great tests for Clojure. You
know you want to.

Stu

samppi

unread,
Jun 28, 2009, 2:51:25 PM6/28/09
to Clojure
Great. So, this doesn't change Clojure 1.0.0, but rather the bleeding
edge build of Clojure, right? Is this going to be one of the changes
for Clojure 1.1 too, then?

John D. Hume

unread,
Jun 29, 2009, 11:14:59 AM6/29/09
to clo...@googlegroups.com
There may already have been a discussion about this in IRC, but I
would have loved to see the 'are' macro continue to support the old
syntax (maybe with deprecation warnings) as well as the new until
after 1.1 is released. This change makes it relatively expensive for
any library with a significant test suite that uses 'are' to keep
testing with both the current release and the current snapshot of
clojure and contrib.

On Thu, Jun 25, 2009 at 10:40 PM, Stuart
Halloway<stuart....@gmail.com> wrote:
> ... Also, the signature and implementation


> of test/are has changed, and is now more idiomatic. For example:
>
> (deftest test-count
>   (are [x y] (= x y)   ; instead of (are (= _1 _2))
>       (count nil) 0
>       (count ()) 0
>       (count '(1)) 1
>       (count '(1 2 3)) 3
> ; etc.


--
http://elhumidor.blogspot.com/

Chouser

unread,
Jun 29, 2009, 11:33:21 AM6/29/09
to clo...@googlegroups.com
On Mon, Jun 29, 2009 at 11:14 AM, John D. Hume<duelin....@gmail.com> wrote:
>
> There may already have been a discussion about this in IRC

The discussion took place here:

http://groups.google.com/group/clojure-dev/msg/2df101865a378156?hl=en

> This change makes it relatively expensive for
> any library with a significant test suite that uses 'are' to keep
> testing with both the current release and the current snapshot of
> clojure and contrib.

If you really want to maintain a single test suite for both
1.0.x and 'master', it shouldn't be difficult to write
a macro that expands to either the old or new 'are' syntax,
depending on the Clojure version runnin.

--Chouser

Jarkko Oranen

unread,
Jun 29, 2009, 11:41:49 AM6/29/09
to Clojure


On Jun 29, 6:14 pm, "John D. Hume" <duelin.mark...@gmail.com> wrote:
> There may already have been a discussion about this in IRC, but I
> would have loved to see the 'are' macro continue to support the old
> syntax (maybe with deprecation warnings) as well as the new until
> after 1.1 is released. This change makes it relatively expensive for
> any library with a significant test suite that uses 'are' to keep
> testing with both the current release and the current snapshot of
> clojure and contrib.

You can always checkout the contrib version prior to these breaking
changes for your tests.
(seems to be 3073f0dc0614cb8c95f2debd0b7e6a75c1736ece)
There has been talk on IRC about creating a 1.0-compatible branch, but
so far no-one has taken action. :/

You could also attempt to write a compatibility wrapper that has the
old are syntax, but transforms it into the new are.
If most of your tests are of the form (are (= _1 _2) ...) then it's
only a matter of transforming that to (new-are [_1 _2] (= _1 _2) ...).

--
Jarkko

Stuart Sierra

unread,
Jun 29, 2009, 6:09:45 PM6/29/09
to Clojure
On Jun 29, 11:14 am, "John D. Hume" <duelin.mark...@gmail.com> wrote:
> There may already have been a discussion about this in IRC, but I
> would have loved to see the 'are' macro continue to support the old
> syntax (maybe with deprecation warnings) as well as the new until
> after 1.1 is released.

There were some problems with the _1,_2 syntax, subtle edge cases that
are inconsistent with the way %1,%2 work in #(). And the old c.c.test-
is remains in older versions of contrib. Pretty soon now, Clojure
will will likely introduce more breaking changes, so you'll have to
pick one or the other.

-SS
Reply all
Reply to author
Forward
0 new messages