From 14c2cd9185a61b8d4c066d20462a96ae22813648 Mon Sep 17 00:00:00 2001 From: Tassilo Horn Date: Fri, 17 Feb 2012 11:02:32 +0100 Subject: [PATCH] Fix CLJ-931: Syntactically broken clojure.test/are tests succeed. Fixed a test case in test/clojure/test_clojure/java_interop.clj only because of the bug in clojure.test/are CLJ-931 is about. No test case added that causes clojure.test/are to fail, because could not determine how to write one that didn't also cause the Clojure build tests to fail. --- src/clj/clojure/test.clj | 10 +++++++++- test/clojure/test_clojure/java_interop.clj | 16 ++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/clj/clojure/test.clj b/src/clj/clojure/test.clj index 2725e20..a393b4f 100644 --- a/src/clj/clojure/test.clj +++ b/src/clj/clojure/test.clj @@ -568,7 +568,15 @@ Note: This breaks some reporting features, such as line numbers." {:added "1.1"} [argv expr & args] - `(temp/do-template ~argv (is ~expr) ~@args)) + (if (or + ;; (are [] true) is meaningless but ok + (and (empty? argv) (empty? args)) + ;; Catch wrong number of args + (and (pos? (count argv)) + (pos? (count args)) + (zero? (mod (count args) (count argv))))) + `(temp/do-template ~argv (is ~expr) ~@args) + (throw (IllegalArgumentException. "The number of args doesn't match are's argv.")))) (defmacro testing "Adds a new string to the list of testing contexts. May be nested, diff --git a/test/clojure/test_clojure/java_interop.clj b/test/clojure/test_clojure/java_interop.clj index 08c3db2..55ab50f 100644 --- a/test/clojure/test_clojure/java_interop.clj +++ b/test/clojure/test_clojure/java_interop.clj @@ -41,14 +41,14 @@ (. Math (abs -7)) ) ; (. target -prop) - (are [x y] (= x y) - (let [p (java.awt.Point. 1 2)] - 1 (.-x p) - 2 (.-y p) - 1 (. p -x) - 2 (. p -y) - 1 (. (java.awt.Point. 1 2) -x) - 2 (. (java.awt.Point. 1 2) -y))) + (let [p (java.awt.Point. 1 2)] + (are [x y] (= x y) + 1 (.-x p) + 2 (.-y p) + 1 (. p -x) + 2 (. p -y) + 1 (. (java.awt.Point. 1 2) -x) + 2 (. (java.awt.Point. 1 2) -y))) ; Classname/staticField (are [x] (= x 2147483647) -- 1.7.9.2