On Sun, Dec 7, 2008 at 10:51 AM, Stuart Sierra
<[email protected]> wrote:
>
> As of clojure-contrib SVN 283, there's a new clojure.contrib.test-is.
> This is a pretty major rewrite of the library. I've tried to
> streamline the code and make it easier to plug in custom reporting and
> assertion functions. Unfortunately, this introduces several breaking
> changes:
>
> I realize this breaks a lot of the tests in clojure.contrib.test-
> clojure. Sorry about that; if I have time I'll go through and fix
> those.
Attached is a patch that updates test-clojure to run with the new
test-is. All tests pass. For the test-clojure.evaluation tests, I just
had to replace (throws ...) with (is (thrown? ...)). For the
test-clojure.numbers tests, I replaced (all-true ...) with (are
all-true? ...) with all-true? defined as:
(defn all-true? [& args]
(apply = (cons true (map #(true? (boolean %)) args))))
That may not be great for accurately and specifically reporting
failures, but I figured it would work for now, until (are ...) is
modified as you say it probably will be. It's better than tests that
won't compile at least :)
I also took out the binding form in test-clojure.clj, since *test-out*
is gone and we weren't using it for anything other than directing to
*out*.
Let me know if you have any questions or see any issues with the patch.
Regards,
- J.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---
Index: src/clojure/contrib/test_clojure/numbers.clj
===================================================================
--- src/clojure/contrib/test_clojure/numbers.clj (revision 292)
+++ src/clojure/contrib/test_clojure/numbers.clj (working copy)
@@ -14,9 +14,12 @@
(ns clojure.contrib.test-clojure.numbers
(:use clojure.contrib.test-is))
+(defn all-true? [& args]
+ (apply = (cons true (map #(true? (boolean %)) args))))
+
(deftest Coerced-Byte
(let [v (byte 3)]
- (all-true
+ (are all-true?
(instance? Byte v)
(number? v)
(integer? v)
@@ -24,7 +27,7 @@
(deftest Coerced-Short
(let [v (short 3)]
- (all-true
+ (are all-true?
(instance? Short v)
(number? v)
(integer? v)
@@ -32,7 +35,7 @@
(deftest Coerced-Integer
(let [v (int 3)]
- (all-true
+ (are all-true?
(instance? Integer v)
(number? v)
(integer? v)
@@ -40,7 +43,7 @@
(deftest Coerced-Long
(let [v (long 3)]
- (all-true
+ (are all-true?
(instance? Long v)
(number? v)
(integer? v)
@@ -48,7 +51,7 @@
(deftest Coerced-BigInteger
(let [v (bigint 3)]
- (all-true
+ (are all-true?
(instance? BigInteger v)
(number? v)
(integer? v)
@@ -56,21 +59,21 @@
(deftest Coerced-Float
(let [v (float 3)]
- (all-true
+ (are all-true?
(instance? Float v)
(number? v)
(float? v))))
(deftest Coerced-Double
(let [v (double 3)]
- (all-true
+ (are all-true?
(instance? Double v)
(number? v)
(float? v))))
(deftest Coerced-BigDecimal
(let [v (bigdec 3)]
- (all-true
+ (are all-true?
(instance? BigDecimal v)
(number? v)
(decimal? v)
Index: src/clojure/contrib/test_clojure/evaluation.clj
===================================================================
--- src/clojure/contrib/test_clojure/evaluation.clj (revision 292)
+++ src/clojure/contrib/test_clojure/evaluation.clj (working copy)
@@ -136,7 +136,7 @@
(test-that
"If a symbol is package-qualified, it is an error if there is no Class named
by the symbol"
- (throws Compiler$CompilerException (eval 'java.lang.FooBar)))
+ (is (thrown? Compiler$CompilerException (eval 'java.lang.FooBar))))
(test-that
"If a symbol is not qualified, the following applies, in this order:
@@ -161,9 +161,9 @@
; First
(doall (for [form '(def if do let quote var fn loop recur throw try
monitor-enter monitor-exit)]
- (throws Compiler$CompilerException (eval form))))
+ (is (thrown? Compiler$CompilerException (eval form)))))
(let [if "foo"]
- (throws Compiler$CompilerException (eval 'if)))
+ (is (thrown? Compiler$CompilerException (eval 'if))))
; Second
(is (= (eval 'Boolean) (class-for-name "java.lang.Boolean")))
@@ -175,10 +175,10 @@
; Fourth
(in-test-ns (is (= (eval 'foo) "abc")))
- (throws Compiler$CompilerException (eval 'bar)) ; not in this namespace
+ (is (thrown? Compiler$CompilerException (eval 'bar))) ; not in this namespace
; Fifth
- (throws Compiler$CompilerException (eval 'foobar))))
+ (is (thrown? Compiler$CompilerException (eval 'foobar)))))
;;; Metadata tests ;;;
Index: src/clojure/contrib/test_clojure.clj
===================================================================
--- src/clojure/contrib/test_clojure.clj (revision 292)
+++ src/clojure/contrib/test_clojure.clj (working copy)
@@ -25,7 +25,6 @@
(doseq [test tests]
(require (test-name test)))
-(binding [*test-out* (java.io.PrintWriter. *out*)]
- (doseq [test tests]
- (println "\n\n=====>" test)
- (run-tests (test-name test))))
+(doseq [test tests]
+ (println "\n\n=====>" test)
+ (run-tests (test-name test)))