summaryrefslogtreecommitdiff
path: root/test/clojure/test_clojure
diff options
context:
space:
mode:
Diffstat (limited to 'test/clojure/test_clojure')
-rw-r--r--test/clojure/test_clojure/control.clj2
-rw-r--r--test/clojure/test_clojure/genclass.clj17
-rw-r--r--test/clojure/test_clojure/helpers.clj35
-rw-r--r--test/clojure/test_clojure/java/io.clj22
-rw-r--r--test/clojure/test_clojure/java/shell.clj22
-rw-r--r--test/clojure/test_clojure/logic.clj2
-rw-r--r--test/clojure/test_clojure/main.clj2
-rw-r--r--test/clojure/test_clojure/multimethods.clj145
-rw-r--r--test/clojure/test_clojure/pprint/test_pretty.clj27
-rw-r--r--test/clojure/test_clojure/protocols.clj25
-rw-r--r--test/clojure/test_clojure/rt.clj20
-rw-r--r--test/clojure/test_clojure/test_utils.clj33
12 files changed, 264 insertions, 88 deletions
diff --git a/test/clojure/test_clojure/control.clj b/test/clojure/test_clojure/control.clj
index 26641b3d..746da981 100644
--- a/test/clojure/test_clojure/control.clj
+++ b/test/clojure/test_clojure/control.clj
@@ -14,7 +14,7 @@
(ns clojure.test-clojure.control
(:use clojure.test
- [clojure.test-clojure.test-utils :only (exception)]))
+ [clojure.test-clojure.helpers :only (exception)]))
;; *** Helper functions ***
diff --git a/test/clojure/test_clojure/genclass.clj b/test/clojure/test_clojure/genclass.clj
index 039b0539..20f4a692 100644
--- a/test/clojure/test_clojure/genclass.clj
+++ b/test/clojure/test_clojure/genclass.clj
@@ -9,7 +9,7 @@
(ns ^{:doc "Tests for clojure.core/gen-class"
:author "Stuart Halloway, Daniel Solano Gómez"}
clojure.test-clojure.genclass
- (:use clojure.test)
+ (:use clojure.test clojure.test-clojure.helpers)
(:import [clojure.test_clojure.genclass.examples ExampleClass
ExampleAnnotationClass]
[java.lang.annotation ElementType
@@ -17,17 +17,6 @@
RetentionPolicy
Target]))
-;; pull this up to a suite-wide helper if you find other tests need it!
-(defn get-field
- "Access to private or protected field. field-name is a symbol or
- keyword."
- ([klass field-name]
- (get-field klass field-name nil))
- ([klass field-name inst]
- (-> klass (.getDeclaredField (name field-name))
- (doto (.setAccessible true))
- (.get inst))))
-
(deftest arg-support
(let [example (ExampleClass.)
o (Object.)]
@@ -71,3 +60,7 @@
(let [target (aget first-param-annots 1)]
(is (instance? Target target))
(is (= [ElementType/TYPE ElementType/PARAMETER] (seq (.value target)))))))))))
+
+(deftest genclass-option-validation
+ (is (fails-with-cause? IllegalArgumentException #"Not a valid method name: has-hyphen"
+ (@#'clojure.core/validate-generate-class-options {:methods '[[fine [] void] [has-hyphen [] void]]}))))
diff --git a/test/clojure/test_clojure/helpers.clj b/test/clojure/test_clojure/helpers.clj
index 777b5f64..42fba780 100644
--- a/test/clojure/test_clojure/helpers.clj
+++ b/test/clojure/test_clojure/helpers.clj
@@ -49,3 +49,38 @@
(report {:type :fail, :message ~msg,
:expected '~form, :actual t#})))))
+
+(defn get-field
+ "Access to private or protected field. field-name is a symbol or
+ keyword."
+ ([klass field-name]
+ (get-field klass field-name nil))
+ ([klass field-name inst]
+ (-> klass (.getDeclaredField (name field-name))
+ (doto (.setAccessible true))
+ (.get inst))))
+
+(defn set-var-roots
+ [maplike]
+ (doseq [[var val] maplike]
+ (alter-var-root var (fn [_] val))))
+
+(defn with-var-roots*
+ "Temporarily set var roots, run block, then put original roots back."
+ [root-map f & args]
+ (let [originals (doall (map (fn [[var _]] [var @var]) root-map))]
+ (set-var-roots root-map)
+ (try
+ (apply f args)
+ (finally
+ (set-var-roots originals)))))
+
+(defmacro with-var-roots
+ [root-map & body]
+ `(with-var-roots* ~root-map (fn [] ~@body)))
+
+(defn exception
+ "Use this function to ensure that execution of a program doesn't
+ reach certain point."
+ []
+ (throw (new Exception "Exception which should never occur")))
diff --git a/test/clojure/test_clojure/java/io.clj b/test/clojure/test_clojure/java/io.clj
index 2b831b72..eaaf7891 100644
--- a/test/clojure/test_clojure/java/io.clj
+++ b/test/clojure/test_clojure/java/io.clj
@@ -8,10 +8,11 @@
(ns clojure.test-clojure.java.io
(:use clojure.test clojure.java.io)
- (:import (java.io File FileInputStream BufferedInputStream
- FileOutputStream OutputStreamWriter InputStreamReader
+ (:import (java.io File BufferedInputStream
+ FileInputStream InputStreamReader InputStream
+ FileOutputStream OutputStreamWriter OutputStream
ByteArrayInputStream ByteArrayOutputStream)
- (java.net URL URI)))
+ (java.net URL URI Socket ServerSocket)))
(defn temp-file
[prefix suffix]
@@ -124,7 +125,6 @@
(deftest test-as-url
(are [file-part input] (= (URL. (str "file:" file-part)) (as-url input))
"foo" "file:foo"
- "/foo" (File. "/foo")
"baz" (URL. "file:baz")
"quux" (URI. "file:quux"))
(is (nil? (as-url nil))))
@@ -141,11 +141,11 @@
(testing "strings"
(is (= "foo" (as-relative-path "foo"))))
(testing "absolute path strings are forbidden"
- (is (thrown? IllegalArgumentException (as-relative-path (str File/separator "baz")))))
+ (is (thrown? IllegalArgumentException (as-relative-path (.getAbsolutePath (File. "baz"))))))
(testing "relative File paths"
(is (= "bar" (as-relative-path (File. "bar")))))
(testing "absolute File paths are forbidden"
- (is (thrown? IllegalArgumentException (as-relative-path (File. (str File/separator "quux")))))))
+ (is (thrown? IllegalArgumentException (as-relative-path (File. (.getAbsolutePath (File. "quux"))))))))
(defn stream-should-have [stream expected-bytes msg]
(let [actual-bytes (byte-array (alength expected-bytes))]
@@ -194,3 +194,13 @@
(is (not (.isDirectory (file tmp "test-make-parents" "child" "grandchild"))))
(delete-file (file tmp "test-make-parents" "child"))
(delete-file (file tmp "test-make-parents"))))
+
+(deftest test-socket-iofactory
+ (let [port 65321
+ server-socket (ServerSocket. port)
+ client-socket (Socket. "localhost" port)]
+ (try
+ (is (instance? InputStream (input-stream client-socket)))
+ (is (instance? OutputStream (output-stream client-socket)))
+ (finally (.close server-socket)
+ (.close client-socket)))))
diff --git a/test/clojure/test_clojure/java/shell.clj b/test/clojure/test_clojure/java/shell.clj
index 777698e2..56e3ff04 100644
--- a/test/clojure/test_clojure/java/shell.clj
+++ b/test/clojure/test_clojure/java/shell.clj
@@ -11,12 +11,16 @@
[clojure.java.shell :as sh])
(:import (java.io File)))
+(def platform-enc (.name (java.nio.charset.Charset/defaultCharset)))
+(def default-enc "UTF-8")
+
(deftest test-parse-args
(are [x y] (= x y)
- [[] {:out "UTF-8" :dir nil :env nil}] (#'sh/parse-args [])
- [["ls"] {:out "UTF-8" :dir nil :env nil}] (#'sh/parse-args ["ls"])
- [["ls" "-l"] {:out "UTF-8" :dir nil :env nil}] (#'sh/parse-args ["ls" "-l"])
- [["ls"] {:out "ISO-8859-1" :dir nil :env nil}] (#'sh/parse-args ["ls" :out "ISO-8859-1"])))
+ [[] {:in-enc default-enc :out-enc default-enc :dir nil :env nil}] (#'sh/parse-args [])
+ [["ls"] {:in-enc default-enc :out-enc default-enc :dir nil :env nil}] (#'sh/parse-args ["ls"])
+ [["ls" "-l"] {:in-enc default-enc :out-enc default-enc :dir nil :env nil}] (#'sh/parse-args ["ls" "-l"])
+ [["ls"] {:in-enc default-enc :out-enc "ISO-8859-1" :dir nil :env nil}] (#'sh/parse-args ["ls" :out-enc "ISO-8859-1"])
+ [[] {:in-enc platform-enc :out-enc platform-enc :dir nil :env nil}] (#'sh/parse-args [:in-enc platform-enc :out-enc platform-enc])))
(deftest test-with-sh-dir
(are [x y] (= x y)
@@ -28,10 +32,10 @@
nil *sh-env*
{:KEY "VAL"} (with-sh-env {:KEY "VAL"} *sh-env*)))
-(deftest test-as-env-string
+(deftest test-as-env-strings
(are [x y] (= x y)
- nil (#'sh/as-env-string nil)
- ["FOO=BAR"] (seq (#'sh/as-env-string {"FOO" "BAR"}))
- ["FOO_SYMBOL=BAR"] (seq (#'sh/as-env-string {'FOO_SYMBOL "BAR"}))
- ["FOO_KEYWORD=BAR"] (seq (#'sh/as-env-string {:FOO_KEYWORD "BAR"}))))
+ nil (#'sh/as-env-strings nil)
+ ["FOO=BAR"] (seq (#'sh/as-env-strings {"FOO" "BAR"}))
+ ["FOO_SYMBOL=BAR"] (seq (#'sh/as-env-strings {'FOO_SYMBOL "BAR"}))
+ ["FOO_KEYWORD=BAR"] (seq (#'sh/as-env-strings {:FOO_KEYWORD "BAR"}))))
diff --git a/test/clojure/test_clojure/logic.clj b/test/clojure/test_clojure/logic.clj
index 8c7763a6..98f2447a 100644
--- a/test/clojure/test_clojure/logic.clj
+++ b/test/clojure/test_clojure/logic.clj
@@ -13,7 +13,7 @@
(ns clojure.test-clojure.logic
(:use clojure.test
- [clojure.test-clojure.test-utils :only (exception)]))
+ [clojure.test-clojure.helpers :only (exception)]))
;; *** Tests ***
diff --git a/test/clojure/test_clojure/main.clj b/test/clojure/test_clojure/main.clj
index 8c5f098c..0f6ca1d7 100644
--- a/test/clojure/test_clojure/main.clj
+++ b/test/clojure/test_clojure/main.clj
@@ -45,6 +45,6 @@
(deftest repl-exception-safety
(testing "catches and prints exception on bad equals"
- (is (= "java.lang.NullPointerException\n"
+ (is (re-matches #"java\.lang\.NullPointerException\r?\n"
(run-repl-and-return-err
"(proxy [Object] [] (equals [o] (.toString nil)))")))))
diff --git a/test/clojure/test_clojure/multimethods.clj b/test/clojure/test_clojure/multimethods.clj
index 8c27034a..77c5ea7e 100644
--- a/test/clojure/test_clojure/multimethods.clj
+++ b/test/clojure/test_clojure/multimethods.clj
@@ -6,10 +6,11 @@
; the terms of this license.
; You must not remove this notice, or any other, from this software.
-; Author: Frantisek Sodomka
+; Author: Frantisek Sodomka, Robert Lachlan
(ns clojure.test-clojure.multimethods
- (:use clojure.test))
+ (:use clojure.test [clojure.test-clojure.helpers :only (with-var-roots)])
+ (:require [clojure.set :as set]))
; http://clojure.org/multimethods
@@ -20,8 +21,140 @@
; methods
; prefers
-; derive, [underive]
-; isa?
-; parents, ancestors, descendants
-; make-hierarchy
+(defmacro for-all
+ [& args]
+ `(dorun (for ~@args)))
+
+(defn hierarchy-tags
+ "Return all tags in a derivation hierarchy"
+ [h]
+ (set/select
+ #(instance? clojure.lang.Named %)
+ (reduce into #{} (map keys (vals h)))))
+
+(defn transitive-closure
+ "Return all objects reachable by calling f starting with o,
+ not including o itself. f should return a collection."
+ [o f]
+ (loop [results #{}
+ more #{o}]
+ (let [new-objects (set/difference more results)]
+ (if (seq new-objects)
+ (recur (set/union results more) (reduce into #{} (map f new-objects)))
+ (disj results o)))))
+
+(defn tag-descendants
+ "Set of descedants which are tags (i.e. Named)."
+ [& args]
+ (set/select
+ #(instance? clojure.lang.Named %)
+ (or (apply descendants args) #{})))
+
+(defn assert-valid-hierarchy
+ [h]
+ (let [tags (hierarchy-tags h)]
+ (testing "ancestors are the transitive closure of parents"
+ (for-all [tag tags]
+ (is (= (transitive-closure tag #(parents h %))
+ (or (ancestors h tag) #{})))))
+ (testing "ancestors are transitive"
+ (for-all [tag tags]
+ (is (= (transitive-closure tag #(ancestors h %))
+ (or (ancestors h tag) #{})))))
+ (testing "tag descendants are transitive"
+ (for-all [tag tags]
+ (is (= (transitive-closure tag #(tag-descendants h %))
+ (or (tag-descendants h tag) #{})))))
+ (testing "a tag isa? all of its parents"
+ (for-all [tag tags
+ :let [parents (parents h tag)]
+ parent parents]
+ (is (isa? h tag parent))))
+ (testing "a tag isa? all of its ancestors"
+ (for-all [tag tags
+ :let [ancestors (ancestors h tag)]
+ ancestor ancestors]
+ (is (isa? h tag ancestor))))
+ (testing "all my descendants have me as an ancestor"
+ (for-all [tag tags
+ :let [descendants (descendants h tag)]
+ descendant descendants]
+ (is (isa? h descendant tag))))
+ (testing "there are no cycles in parents"
+ (for-all [tag tags]
+ (is (not (contains? (transitive-closure tag #(parents h %)) tag)))))
+ (testing "there are no cycles in descendants"
+ (for-all [tag tags]
+ (is (not (contains? (descendants h tag) tag)))))))
+
+(def family
+ (reduce #(apply derive (cons %1 %2)) (make-hierarchy)
+ [[::parent-1 ::ancestor-1]
+ [::parent-1 ::ancestor-2]
+ [::parent-2 ::ancestor-2]
+ [::child ::parent-2]
+ [::child ::parent-1]]))
+
+(deftest cycles-are-forbidden
+ (testing "a tag cannot be its own parent"
+ (is (thrown-with-msg? Throwable #"\(not= tag parent\)"
+ (derive family ::child ::child))))
+ (testing "a tag cannot be its own ancestor"
+ (is (thrown-with-msg? Throwable #"Cyclic derivation: :clojure.test-clojure.multimethods/child has :clojure.test-clojure.multimethods/ancestor-1 as ancestor"
+ (derive family ::ancestor-1 ::child)))))
+
+(deftest using-diamond-inheritance
+ (let [diamond (reduce #(apply derive (cons %1 %2)) (make-hierarchy)
+ [[::mammal ::animal]
+ [::bird ::animal]
+ [::griffin ::mammal]
+ [::griffin ::bird]])
+ bird-no-more (underive diamond ::griffin ::bird)]
+ (assert-valid-hierarchy diamond)
+ (assert-valid-hierarchy bird-no-more)
+ (testing "a griffin is a mammal, indirectly through mammal and bird"
+ (is (isa? diamond ::griffin ::animal)))
+ (testing "a griffin is a bird"
+ (is (isa? diamond ::griffin ::bird)))
+ (testing "after underive, griffin is no longer a bird"
+ (is (not (isa? bird-no-more ::griffin ::bird))))
+ (testing "but it is still an animal, via mammal"
+ (is (isa? bird-no-more ::griffin ::animal)))))
+
+(deftest derivation-world-bridges-to-java-inheritance
+ (let [h (derive (make-hierarchy) java.util.Map ::map)]
+ (testing "a Java class can be isa? a tag"
+ (is (isa? h java.util.Map ::map)))
+ (testing "if a Java class isa? a tag, so are its subclasses..."
+ (is (isa? h java.util.HashMap ::map)))
+ (testing "...but not its superclasses!"
+ (is (not (isa? h java.util.Collection ::map))))))
+
+(deftest global-hierarchy-test
+ (with-var-roots {#'clojure.core/global-hierarchy (make-hierarchy)}
+ (assert-valid-hierarchy @#'clojure.core/global-hierarchy)
+ (testing "when you add some derivations..."
+ (derive ::lion ::cat)
+ (derive ::manx ::cat)
+ (assert-valid-hierarchy @#'clojure.core/global-hierarchy))
+ (testing "...isa? sees the derivations"
+ (is (isa? ::lion ::cat))
+ (is (not (isa? ::cat ::lion))))
+ (testing "... you can traverse the derivations"
+ (is (= #{::manx ::lion} (descendants ::cat)))
+ (is (= #{::cat} (parents ::manx)))
+ (is (= #{::cat} (ancestors ::manx))))
+ (testing "then, remove a derivation..."
+ (underive ::manx ::cat))
+ (testing "... traversals update accordingly"
+ (is (= #{::lion} (descendants ::cat)))
+ (is (nil? (parents ::manx)))
+ (is (nil? (ancestors ::manx))))))
+
+#_(defmacro for-all
+ "Better than the actual for-all, if only it worked."
+ [& args]
+ `(reduce
+ #(and %1 %2)
+ (map true? (for ~@args))))
diff --git a/test/clojure/test_clojure/pprint/test_pretty.clj b/test/clojure/test_clojure/pprint/test_pretty.clj
index ee328fbc..a012b1d4 100644
--- a/test/clojure/test_clojure/pprint/test_pretty.clj
+++ b/test/clojure/test_clojure/pprint/test_pretty.clj
@@ -245,6 +245,31 @@ Usage: *hello*
)
-
+;;; Some simple tests of dispatch
+
+(defmulti
+ test-dispatch
+ "A test dispatch method"
+ {:added "1.2" :arglists '[[object]]}
+ #(and (seq %) (not (string? %))))
+
+(defmethod test-dispatch true [avec]
+ (pprint-logical-block :prefix "[" :suffix "]"
+ (loop [aseq (seq avec)]
+ (when aseq
+ (write-out (first aseq))
+ (when (next aseq)
+ (.write ^java.io.Writer *out* " ")
+ (pprint-newline :linear)
+ (recur (next aseq)))))))
+
+(defmethod test-dispatch false [aval] (pr aval))
+
+(simple-tests dispatch-tests
+ (with-pprint-dispatch test-dispatch
+ (with-out-str
+ (pprint '("hello" "there"))))
+ "[\"hello\" \"there\"]\n"
+)
diff --git a/test/clojure/test_clojure/protocols.clj b/test/clojure/test_clojure/protocols.clj
index b2f03dd7..44969756 100644
--- a/test/clojure/test_clojure/protocols.clj
+++ b/test/clojure/test_clojure/protocols.clj
@@ -11,6 +11,7 @@
(ns clojure.test-clojure.protocols
(:use clojure.test clojure.test-clojure.protocols.examples)
(:require [clojure.test-clojure.protocols.more-examples :as other]
+ [clojure.set :as set]
clojure.test-clojure.helpers)
(:import [clojure.test_clojure.protocols.examples ExampleInterface]))
@@ -174,21 +175,21 @@
(defrecord DefrecordObjectMethodsWidgetA [a])
(defrecord DefrecordObjectMethodsWidgetB [a])
(deftest defrecord-object-methods-test
- (testing ".equals depends on fields and type"
- (is (true? (.equals (DefrecordObjectMethodsWidgetA. 1) (DefrecordObjectMethodsWidgetA. 1))))
- (is (false? (.equals (DefrecordObjectMethodsWidgetA. 1) (DefrecordObjectMethodsWidgetA. 2))))
- (is (false? (.equals (DefrecordObjectMethodsWidgetA. 1) (DefrecordObjectMethodsWidgetB. 1)))))
- (testing ".hashCode depends on fields and type"
- (is (= (.hashCode (DefrecordObjectMethodsWidgetA. 1)) (.hashCode (DefrecordObjectMethodsWidgetA. 1))))
- (is (= (.hashCode (DefrecordObjectMethodsWidgetA. 2)) (.hashCode (DefrecordObjectMethodsWidgetA. 2))))
- (is (not= (.hashCode (DefrecordObjectMethodsWidgetA. 1)) (.hashCode (DefrecordObjectMethodsWidgetA. 2))))
- (is (= (.hashCode (DefrecordObjectMethodsWidgetB. 1)) (.hashCode (DefrecordObjectMethodsWidgetB. 1))))
- (is (not= (.hashCode (DefrecordObjectMethodsWidgetA. 1)) (.hashCode (DefrecordObjectMethodsWidgetB. 1))))))
+ (testing "= depends on fields and type"
+ (is (true? (= (DefrecordObjectMethodsWidgetA. 1) (DefrecordObjectMethodsWidgetA. 1))))
+ (is (false? (= (DefrecordObjectMethodsWidgetA. 1) (DefrecordObjectMethodsWidgetA. 2))))
+ (is (false? (= (DefrecordObjectMethodsWidgetA. 1) (DefrecordObjectMethodsWidgetB. 1))))))
(deftest defrecord-acts-like-a-map
(let [rec (r 1 2)]
- (is (= (r 1 3 {} {:c 4}) (merge rec {:b 3 :c 4})))
- #_(is (= {:a 11 :b 2 :c 10} (merge-with + rec {:a 10 :c 10})))))
+ (is (.equals (r 1 3 {} {:c 4}) (merge rec {:b 3 :c 4})))
+ (is (.equals {:foo 1 :b 2} (set/rename-keys rec {:a :foo})))
+ (is (.equals {:a 11 :b 2 :c 10} (merge-with + rec {:a 10 :c 10})))))
+
+(deftest degenerate-defrecord-test
+ (let [empty (EmptyRecord.)]
+ (is (nil? (seq empty)))
+ (is (not (.containsValue empty :a)))))
(deftest defrecord-interfaces-test
(testing "java.util.Map"
diff --git a/test/clojure/test_clojure/rt.clj b/test/clojure/test_clojure/rt.clj
index 5b7f2493..f3a9b08b 100644
--- a/test/clojure/test_clojure/rt.clj
+++ b/test/clojure/test_clojure/rt.clj
@@ -55,23 +55,23 @@
(deftest error-messages
(testing "binding a core var that already refers to something"
(should-print-err-message
- #"WARNING: prefers already refers to: #'clojure.core/prefers in namespace: .*\n"
+ #"WARNING: prefers already refers to: #'clojure.core/prefers in namespace: .*\r?\n"
(defn prefers [] (throw (RuntimeException. "rebound!")))))
(testing "reflection cannot resolve field"
(should-print-err-message
- #"Reflection warning, NO_SOURCE_PATH:\d+ - reference to field blah can't be resolved.\n"
+ #"Reflection warning, NO_SOURCE_PATH:\d+ - reference to field blah can't be resolved\.\r?\n"
(defn foo [x] (.blah x))))
(testing "reflection cannot resolve instance method"
(should-print-err-message
- #"Reflection warning, NO_SOURCE_PATH:\d+ - call to zap can't be resolved.\n"
+ #"Reflection warning, NO_SOURCE_PATH:\d+ - call to zap can't be resolved\.\r?\n"
(defn foo [x] (.zap x 1))))
(testing "reflection cannot resolve static method"
(should-print-err-message
- #"Reflection warning, NO_SOURCE_PATH:\d+ - call to valueOf can't be resolved.\n"
+ #"Reflection warning, NO_SOURCE_PATH:\d+ - call to valueOf can't be resolved\.\r?\n"
(defn foo [] (Integer/valueOf #"boom"))))
(testing "reflection cannot resolve constructor"
(should-print-err-message
- #"Reflection warning, NO_SOURCE_PATH:\d+ - call to java.lang.String ctor can't be resolved.\n"
+ #"Reflection warning, NO_SOURCE_PATH:\d+ - call to java.lang.String ctor can't be resolved\.\r?\n"
(defn foo [] (String. 1 2 3)))))
(def example-var)
@@ -83,10 +83,18 @@
(deftest last-var-wins-for-core
(testing "you can replace a core name, with warning"
- (let [ns (temp-ns 'clojure.set)
+ (let [ns (temp-ns)
replacement (gensym)]
(with-err-string-writer (intern ns 'prefers replacement))
(is (= replacement @('prefers (ns-publics ns))))))
+ (testing "you can replace a name you defined before"
+ (let [ns (temp-ns)
+ s (gensym)
+ v1 (intern ns 'foo s)
+ v2 (intern ns 'bar s)]
+ (with-err-string-writer (.refer ns 'flatten v1))
+ (.refer ns 'flatten v2)
+ (is (= v2 (ns-resolve ns 'flatten)))))
(testing "you cannot intern over an existing non-core name"
(let [ns (temp-ns 'clojure.set)
replacement (gensym)]
diff --git a/test/clojure/test_clojure/test_utils.clj b/test/clojure/test_clojure/test_utils.clj
deleted file mode 100644
index d1905100..00000000
--- a/test/clojure/test_clojure/test_utils.clj
+++ /dev/null
@@ -1,33 +0,0 @@
-; Copyright (c) Rich Hickey. All rights reserved.
-; The use and distribution terms for this software are covered by the
-; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
-; which can be found in the file epl-v10.html at the root of this distribution.
-; By using this software in any fashion, you are agreeing to be bound by
-; the terms of this license.
-; You must not remove this notice, or any other, from this software.
-
-; Author: Frantisek Sodomka
-
-
-(ns clojure.test-clojure.test-utils)
-
- (defn exception
- "Use this function to ensure that execution of a program doesn't
- reach certain point."
- []
- (throw (new Exception "Exception which should never occur")))
-
-
-;; (defmacro all-are
-;; "Test all-with-all.
-;; (all-are (= _1 _2)
-;; a b c)
-;; =>
-;; (do
-;; (is (= a b))
-;; (is (= a c))
-;; (is (= b c)))"
-;; [expr & args]
-;; (concat
-;; (list 'clojure.contrib.template/do-template (list 'clojure.test/is expr))
-;; (apply concat (combinations args 2)))))