Re: Testing Clojure (was Re: Bug? Strange set equality (r1075))
Using this, test t-Symbols (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)) ) becomes: (deftest t-Symbols (check (:equal 'abc (symbol abc) '*+!-_? (symbol *+!-_?) 'abc:def:ghi (symbol abc:def:ghi) 'abc/def (symbol abc def) 'abc.def/ghi (symbol abc.def ghi) 'abc/def.ghi (symbol abc def.ghi) 'abc:def/ghi:jkl.mno (symbol abc:def ghi:jkl.mno) ) (instance? clojure.lang.Symbol 'alphabet))) which is in my opinion much more readable. Any comments to this syntactic enhancement? Thank you, Frantisek --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Testing Clojure (was Re: Bug? Strange set equality (r1075))
--- On Thu, 11/13/08, Frantisek Sodomka wrote: [...] becomes: (deftest t-Symbols (check (:equal 'abc (symbol abc) '*+!-_? (symbol *+!-_?) 'abc:def:ghi (symbol abc:def:ghi) 'abc/def (symbol abc def) 'abc.def/ghi (symbol abc.def ghi) 'abc/def.ghi (symbol abc def.ghi) 'abc:def/ghi:jkl.mno (symbol abc:def ghi:jkl.mno) ) (instance? clojure.lang.Symbol 'alphabet))) which is in my opinion much more readable. Any comments to this syntactic enhancement? My first impression when I read that is that it's expecting each arg to be equal to each other, not the reality of being a list of (expected to be) equal pairs. That's probably just me, I'm sure, but I find the original more readable and precise--something I think is key in tests, as tests are also documentation. Dave --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Testing Clojure (was Re: Bug? Strange set equality (r1075))
On Thu, 13 Nov 2008 16:35:52 +0100, Dave Newton [EMAIL PROTECTED] wrote: --- On Thu, 11/13/08, Frantisek Sodomka wrote: [...] becomes: (deftest t-Symbols (check (:equal 'abc (symbol abc) '*+!-_? (symbol *+!-_?) 'abc:def:ghi (symbol abc:def:ghi) 'abc/def (symbol abc def) 'abc.def/ghi (symbol abc.def ghi) 'abc/def.ghi (symbol abc def.ghi) 'abc:def/ghi:jkl.mno (symbol abc:def ghi:jkl.mno) ) (instance? clojure.lang.Symbol 'alphabet))) which is in my opinion much more readable. Any comments to this syntactic enhancement? My first impression when I read that is that it's expecting each arg to be equal to each other, not the reality of being a list of (expected to be) equal pairs. That's probably just me, I'm sure, but I find the original more readable and precise--something I think is key in tests, as tests are also documentation. Dave Yes, I am just trying to save on typing... ;-) :equal could be also :equal-pairs. It introduces new (and maybe strange) syntax... Anyway, accepting multiple expressions would be nice. Frantisek --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Testing Clojure (was Re: Bug? Strange set equality (r1075))
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 -~--~~~~--~~--~--~---
Re: Testing Clojure (was Re: Bug? Strange set equality (r1075))
Hello Stuart, On 21 Okt., 16:37, Stuart Halloway [EMAIL PROTECTED] wrote: Since there is now a movement afoot to write a comprehensive test suite, I want to re-post the spike I did earlier on ClojureCheck. It would be cool to use check-style tests for at least part of the Clojure suite. If there is interest in this, I hope to have time to work on this in late November, or would be delighted if someone else picks up the idea and runs with it. I am working on a TAP implementation[1] for Clojure. For this I would really like to have a ClojureCheck (as there is LectroTest for Perl). And as stated in the original ClojureCheck thread I will work on this. Unfortunately, (not= de.kotka.tap clojure/test clojure.contrib.test- is) but I think the basic machinery like arbitrary definition etc. can be reused. I will hopefully soon post a first draft of the implementation. Sincerely Meikel [1]: http://kotka.de/projects/clojure/tap.html (Not up-to-date, though) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Testing Clojure (was Re: Bug? Strange set equality (r1075))
On Oct 22, 2008, at 8:22 AM, J. McConnell wrote: Run tests with: (require 'clojure.contrib.test-clojure) I don't see clojure.contrib.test-clojure. Are you going to be committing that? It's up now. Once your CA is in to Rich, I'll be happy to accept patches to extend its nascent testing reach: user= (require 'clojure.contrib.test-clojure :reload-all) Testing #Namespace: clojure.contrib.test-clojure.Reader Ran 22 tests with 10 assertions. 0 failures, 0 exceptions. nil user= Thanks, --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 -~--~~~~--~~--~--~---
Re: Testing Clojure (was Re: Bug? Strange set equality (r1075))
I made a start on this today. I started with the Reader page at clojure.org and started making tests. Unless I hear that someone else has started, I guess I'll take a shot at the Evaluation page next time I get a chance. - J. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Testing Clojure (was Re: Bug? Strange set equality (r1075))
That's great, J. Thanks. I want to use the wiki to coordinate efforts. I'll be putting a page up in the next day or two. Sounds good. Was the example I posted enough to get you started? I think so, it made sense to me. If I'm stumped (I'm thinking of load-file here) I'll be sure to ask questions here or on IRC. Thanks, - J. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Testing Clojure (was Re: Bug? Strange set equality (r1075))
Since there is now a movement afoot to write a comprehensive test suite, I want to re-post the spike I did earlier on ClojureCheck. It would be cool to use check-style tests for at least part of the Clojure suite. If there is interest in this, I hope to have time to work on this in late November, or would be delighted if someone else picks up the idea and runs with it. Original message follows: --- At the JVM summit Clojure breakout someone suggested a Haskell QuickCheck/ScalaCheck library for Clojure. I am attaching a small spike in that direction below. A few questions: (1) Is anybody interested? (2) If the answer to (1) is yes, do you like the direction I am going in the public API, e.g. (for-all [x Integer y Integer] (some stuff that must be true)) (3) Any suggestions about implementation detail? (E.g. I like using a multimethod for arbitrary--is there a prettier syntax for ignoring the argument after using it for dispatch?) Cheers, Stuart ;;; clojure_check.clj: quick check framework for Clojure ;; Copyright (c) 2008 Stuart Halloway. All rights reserved. ;; Inspired by Scalacheck et al (http://code.google.com/p/scalacheck/) ;; Licensed under the same CPL as Clojure (http://clojure.org) ;; Uses clojure.contrib.test-is for assertions ;; ;; Example (passing) ;; (for-all [x Integer y Integer] (= (+ x y) (+ y x))) ;; ;; Example (failing) ;; (for-all [x Integer y Integer] (= (+ x y) (- y x))) (ns clojure-check (:import (java.util Random)) (:use clojure.contrib.test-is)) (defmulti arbitrary identity) (def random (Random.)) (defn collection-size [] (.nextInt random 100)) (def *check-count* 50) (defn choose [rng] (nth rng (.nextInt random (count rng (defmethod arbitrary Integer [_] (.nextInt random)) (defmethod arbitrary Character [_] (char (.nextInt random))) (defmethod arbitrary :ascii-character [_] (char (choose (range 32 128 (defmethod arbitrary String [_] (apply str (take (collection-size) (iterate (fn[_] (arbitrary Character)) nil (defmethod arbitrary :ascii-string [_] (apply str (take (collection-size) (iterate (fn[_] (arbitrary :ascii- character)) nil (defmacro binding-values [ vars] `(vector ~@(map (fn [v] `['~v ~v]) vars))) (defmacro for-all [args forms] (let [vars (take-nth 2 args) value-generators (map (fn [x] `(arbitrary ~x))(take-nth 2 (rest args)))] `(do ~@(map (fn [f] `(dotimes i# *check-count* (let ~(apply vector (interleave vars value-generators)) (is (true? ~f) (pr-str (binding-values [EMAIL PROTECTED])) forms --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Testing Clojure (was Re: Bug? Strange set equality (r1075))
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. Just put mine in the mail :) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Testing Clojure (was Re: Bug? Strange set equality (r1075))
I like this idea and I would be willing to contribute. On Oct 19, 6:43 pm, 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 -~--~~~~--~~--~--~---
Re: Testing Clojure (was Re: Bug? Strange set equality (r1075))
Ditto. I've been thinking about this for a few weeks and would be happy to help out where I can. On Sun, Oct 19, 2008 at 6:22 PM, Paul Barry [EMAIL PROTECTED] wrote: I like this idea and I would be willing to contribute. On Oct 19, 6:43 pm, 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 -~--~~~~--~~--~--~---