Hello, I would like to contribute to testing Clojure. (Rich has my CA  
already.)
I have been thinking about it and going through some unit tests for  
different language. I am proposing this syntax change to macro 'is':

Instead of writing:

(deftest test-+
   (is (= (+) 0))
   (is (= (+ 1) 1))
   (is (= (+ 1 2) 3))
   (is (= (+ 1 2 3) 6))
   (is (number? (+ 1 2)))
   (is (integer? (+ 1 2)))
   (throws ClassCastException (+ "abc" 2)))

1) Take multiple expressions instead of just one

(deftest test-+
   (is
     (= (+) 0)
     (= (+ 1) 1)
     (= (+ 1 2) 3)
     (= (+ 1 2 3) 6)
     (number? (+ 1 2))
     (integer? (+ 1 2)))
   (throws ClassCastException (+ "abc" 2)))

2) Abstract equality tests (the most common tests):

(deftest test-+
   (is
     (:equal
       (+) 0
       (+ 1) 1
       (+ 1 2) 3
       (+ 1 2 3) 6 )
     (number? (+ 1 2))
     (integer? (+ 1 2)))
   (throws ClassCastException (+ "abc" 2)))

I believe that this syntax change would make writing tests easier and less  
tedious. Also, personally, I would prefer the name 'check' instead of  
'is', but that's just me :-)

Greetings, Frantisek



On Mon, 20 Oct 2008 00:43:44 +0200, Stephen C. Gilardi <[EMAIL PROTECTED]>  
wrote:
>
>
> On Oct 19, 2008, at 5:11 PM, J. McConnell wrote:
>
>> I've been thinking the same thing for awhile now and I'd love to help
>> contribute to an effort like this. Thanks for getting the idea out
>> there.
>
> You're welcome. It seems like clojure.contrib could be a more
> convenient place to keep this than the wiki.
>
> Direct or indirect contributions to clojure.contrib require that the
> contributed code be written by the contributor and that the
> contributor have a contributor agreement on file with Rich. Would that
> be acceptable to people interested in participating? I appreciate the
> care Rich showed and long view he took in coming up with the
> Contributor Agreement process. I think it would be a good idea to
> leverage that process for this effort as well.
>
> Discussion of alternative proposals for a good way to do this and
> place to keep it are welcome.
>
> I made a start on this today. I started with the Reader page at
> clojure.org and started making tests. I'm thinking of a structure like
> this:
>
> Run tests with:
>
>       (require 'clojure.contrib.test-clojure)
>
> The definition of clojure.contrib.test-clojure requires subordinate
> test namespaces like
>
>       'clojure.contrib.test-clojure.Reader
>       'clojure.contrib.test-clojure.Evaluation
>       'clojure.contrib.test-clojure.Special-Forms
>       ...
>
> with names that correspond to pages on the Clojure web site. After
> requiring the individual test namespaces, test-clojure runs
> "clojure.contrib.test-is/run-tests" on each one.
>
> Here's a sample from clojure.contrib.test-clojure.
>
>       (ns clojure.contrib.test-clojure.Reader
>         (:use clojure.contrib.test-is))
>
>       (deftest t-Symbols
>         (is (= 'abc (symbol "abc")))
>         (is (= '*+!-_? (symbol "*+!-_?")))
>         (is (= 'abc:def:ghi (symbol "abc:def:ghi")))
>         (is (= 'abc/def (symbol "abc" "def")))
>         (is (= 'abc.def/ghi (symbol "abc.def" "ghi")))
>         (is (= 'abc/def.ghi (symbol "abc" "def.ghi")))
>         (is (= 'abc:def/ghi:jkl.mno (symbol "abc:def" "ghi:jkl.mno")))
>         (is (instance? clojure.lang.Symbol 'alphabet))
>         )
>
>       ; additional tests to flesh out
>       (deftest t-Numbers)
>       (deftest t-Characters)
>       (deftest t-nil)
>       (deftest t-Booleans)
>       (deftest t-Keywords)
>       (deftest t-Lists)
>       (deftest t-Vectors)
>       (deftest t-Maps)
>       (deftest t-Sets)
>       (deftest t-Quote)
>       (deftest t-Character)
>       (deftest t-Comment)
>       (deftest t-Meta)
>       (deftest t-Deref)
>       (deftest t-Regex)
>       (deftest t-Metadata)
>       (deftest t-read)
>
> and a run:
>
>       user=> (require 'clojure.contrib.test-clojure)
>       Testing #<Namespace: clojure.contrib.test-clojure.Reader>
>
>       Ran 18 tests with 10 assertions.
>       0 failures, 0 exceptions.
>       nil
>       user=>
>
> (Currently the number of tests exceeds the number of assertions by so
> much because of the placeholders.)
>
> Tesing Clojure is a big project and will take a lot of work over time.
> There many pieces and many interactions among them to test. The hope
> is that having it available will allow Rich to make changes with an
> even higher degree of confidence that they didn't have unintended
> consequences and to support efforts like Chouser's ClojureScript to
> bring Clojure to new platforms
>
> Discussion and suggestions are welcome.
>
> --Steve
>
>
> >



--~--~---------~--~----~------------~-------~--~----~
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
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to