summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStuart Halloway <stu@thinkrelevance.com>2010-08-08 12:50:26 -0400
committerStuart Halloway <stu@thinkrelevance.com>2010-08-12 09:16:18 -0400
commit3500afa5f45de4170d965c109114543464a60de0 (patch)
treeca9fb421e3835b1279097064e6a23559f13e9e1f
parent9f9f44d151c5d02179b43f7186e55fb94a985fe1 (diff)
organize common helpers
Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>
-rw-r--r--test/clojure/test_clojure/control.clj2
-rw-r--r--test/clojure/test_clojure/helpers.clj23
-rw-r--r--test/clojure/test_clojure/logic.clj2
-rw-r--r--test/clojure/test_clojure/multimethods.clj21
-rw-r--r--test/clojure/test_clojure/test_utils.clj33
5 files changed, 26 insertions, 55 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/helpers.clj b/test/clojure/test_clojure/helpers.clj
index 89a075fc..42fba780 100644
--- a/test/clojure/test_clojure/helpers.clj
+++ b/test/clojure/test_clojure/helpers.clj
@@ -60,4 +60,27 @@
(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/logic.clj b/test/clojure/test_clojure/logic.clj
index b097468e..2bdb8159 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/multimethods.clj b/test/clojure/test_clojure/multimethods.clj
index 258562dc..77c5ea7e 100644
--- a/test/clojure/test_clojure/multimethods.clj
+++ b/test/clojure/test_clojure/multimethods.clj
@@ -9,7 +9,7 @@
; 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
@@ -21,25 +21,6 @@
; methods
; prefers
-(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)))
-
(defmacro for-all
[& args]
`(dorun (for ~@args)))
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)))))