aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStuart Sierra <mail@stuartsierra.com>2010-08-10 21:40:47 -0400
committerStuart Sierra <mail@stuartsierra.com>2010-08-10 21:40:47 -0400
commit38743f83bdd60d6687dabcea3864b04bbd554a6c (patch)
tree44b31d4900c2d5720679abe911694d64fc516d0a
parenta6a92b9b3d2bfd9a56e1e5e9cfba706d1aeeaae5 (diff)
Add test sources to their respective modules
-rw-r--r--modules/complex-numbers/src/test/clojure/clojure/contrib/test_complex_numbers.clj313
-rw-r--r--modules/core/src/test/clojure/clojure/contrib/test_core.clj42
-rw-r--r--modules/dataflow/src/test/clojure/clojure/contrib/test_dataflow.clj90
-rw-r--r--modules/datalog/pom.xml20
-rw-r--r--modules/datalog/src/test/clojure/clojure/contrib/datalog/tests/test.clj45
-rw-r--r--modules/datalog/src/test/clojure/clojure/contrib/datalog/tests/test_database.clj153
-rw-r--r--modules/datalog/src/test/clojure/clojure/contrib/datalog/tests/test_literals.clj187
-rw-r--r--modules/datalog/src/test/clojure/clojure/contrib/datalog/tests/test_magic.clj72
-rw-r--r--modules/datalog/src/test/clojure/clojure/contrib/datalog/tests/test_rules.clj130
-rw-r--r--modules/datalog/src/test/clojure/clojure/contrib/datalog/tests/test_softstrat.clj233
-rw-r--r--modules/datalog/src/test/clojure/clojure/contrib/datalog/tests/test_util.clj69
-rw-r--r--modules/def/src/test/clojure/clojure/contrib/test_def.clj27
-rw-r--r--modules/fnmap/src/test/clojure/clojure/contrib/test_fnmap.clj39
-rw-r--r--modules/graph/src/test/clojure/clojure/contrib/test_graph.clj187
-rw-r--r--modules/greatest-least/src/test/clojure/clojure/contrib/test_greatest_least.clj65
-rw-r--r--modules/io/src/test/clojure/clojure/contrib/test_io.clj96
-rw-r--r--modules/jmx/src/test/clojure/clojure/contrib/test_jmx.clj178
-rw-r--r--modules/json/src/test/clojure/clojure/contrib/test_json.clj186
-rw-r--r--modules/lazy-seqs/src/test/clojure/clojure/contrib/test_lazy_seqs.clj21
-rw-r--r--modules/load-all/src/test/clojure/clojure/contrib/test_load_all.clj53
-rw-r--r--modules/macro-utils/src/test/clojure/clojure/contrib/test_macro_utils.clj67
-rw-r--r--modules/math/src/test/clojure/clojure/contrib/test_math.clj118
-rw-r--r--modules/miglayout/src/test/clojure/clojure/contrib/test_miglayout.clj145
-rw-r--r--modules/mock-test-adapter/pom.xml26
-rw-r--r--modules/mock-test-adapter/src/main/clojure/clojure/contrib/mock/test_adapter.clj38
-rw-r--r--modules/mock/src/test/clojure/clojure/contrib/mock/test_adapter.clj18
-rw-r--r--modules/mock/src/test/clojure/clojure/contrib/test_mock.clj131
-rw-r--r--modules/monads/src/test/clojure/clojure/contrib/test_monads.clj78
-rw-r--r--modules/parent/pom.xml4
-rw-r--r--modules/pprint/src/test/clojure/clojure/contrib/pprint/test_cl_format.clj691
-rw-r--r--modules/pprint/src/test/clojure/clojure/contrib/pprint/test_helper.clj21
-rw-r--r--modules/pprint/src/test/clojure/clojure/contrib/pprint/test_pretty.clj127
-rw-r--r--modules/profile/src/test/clojure/clojure/contrib/test_profile.clj8
-rw-r--r--modules/properties/src/test/clojure/clojure/contrib/test_properties.clj63
-rw-r--r--modules/prxml/src/test/clojure/clojure/contrib/test_prxml.clj10
-rw-r--r--modules/repl-utils/src/test/clojure/clojure/contrib/test_repl_utils.clj20
-rw-r--r--modules/seq/src/test/clojure/clojure/contrib/test_seq.clj128
-rw-r--r--modules/shell/src/test/clojure/clojure/contrib/test_shell.clj41
-rw-r--r--modules/sql/src/test/clojure/clojure/contrib/test_sql.clj207
-rw-r--r--modules/string/src/test/clojure/clojure/contrib/test_string.clj124
-rw-r--r--modules/strint/src/test/clojure/clojure/contrib/test_strint.clj41
-rw-r--r--modules/trace/src/test/clojure/clojure/contrib/test_trace.clj16
-rw-r--r--modules/with-ns/src/test/clojure/clojure/contrib/test_with_ns.clj18
-rw-r--r--pom.xml1
44 files changed, 4280 insertions, 67 deletions
diff --git a/modules/complex-numbers/src/test/clojure/clojure/contrib/test_complex_numbers.clj b/modules/complex-numbers/src/test/clojure/clojure/contrib/test_complex_numbers.clj
new file mode 100644
index 00000000..008e6ec7
--- /dev/null
+++ b/modules/complex-numbers/src/test/clojure/clojure/contrib/test_complex_numbers.clj
@@ -0,0 +1,313 @@
+;; Test routines for complex-numbers.clj
+
+;; by Konrad Hinsen
+;; last updated April 2, 2009
+
+;; Copyright (c) Konrad Hinsen, 2008. 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.
+
+(ns clojure.contrib.test-complex-numbers
+ (:refer-clojure :exclude [+ - * / = < > <= >=])
+ (:use [clojure.test
+ :only (deftest is are run-tests)]
+ [clojure.contrib.generic.arithmetic
+ :only (+ - * /)]
+ [clojure.contrib.generic.comparison
+ :only (= < > <= >=)]
+ [clojure.contrib.generic.math-functions
+ :only (abs approx= conjugate exp sqr sqrt)]
+ [clojure.contrib.complex-numbers
+ :only (complex imaginary real imag)]))
+
+(deftest complex-addition
+ (is (= (+ (complex 1 2) (complex 1 2)) (complex 2 4)))
+ (is (= (+ (complex 1 2) (complex -3 -7)) (complex -2 -5)))
+ (is (= (+ (complex -3 -7) (complex 1 2)) (complex -2 -5)))
+ (is (= (+ (complex 1 2) 3) (complex 4 2)))
+ (is (= (+ 3 (complex 1 2)) (complex 4 2)))
+ (is (= (+ (complex 1 2) -1) (imaginary 2)))
+ (is (= (+ -1 (complex 1 2)) (imaginary 2)))
+ (is (= (+ (complex 1 2) (imaginary -2)) 1))
+ (is (= (+ (imaginary -2) (complex 1 2)) 1))
+ (is (= (+ (complex 1 2) (imaginary 5)) (complex 1 7)))
+ (is (= (+ (imaginary 5) (complex 1 2)) (complex 1 7)))
+ (is (= (+ (complex -3 -7) (complex 1 2)) (complex -2 -5)))
+ (is (= (+ (complex 1 2) (complex -3 -7)) (complex -2 -5)))
+ (is (= (+ (complex -3 -7) (complex -3 -7)) (complex -6 -14)))
+ (is (= (+ (complex -3 -7) 3) (imaginary -7)))
+ (is (= (+ 3 (complex -3 -7)) (imaginary -7)))
+ (is (= (+ (complex -3 -7) -1) (complex -4 -7)))
+ (is (= (+ -1 (complex -3 -7)) (complex -4 -7)))
+ (is (= (+ (complex -3 -7) (imaginary -2)) (complex -3 -9)))
+ (is (= (+ (imaginary -2) (complex -3 -7)) (complex -3 -9)))
+ (is (= (+ (complex -3 -7) (imaginary 5)) (complex -3 -2)))
+ (is (= (+ (imaginary 5) (complex -3 -7)) (complex -3 -2)))
+ (is (= (+ 3 (complex 1 2)) (complex 4 2)))
+ (is (= (+ (complex 1 2) 3) (complex 4 2)))
+ (is (= (+ 3 (complex -3 -7)) (imaginary -7)))
+ (is (= (+ (complex -3 -7) 3) (imaginary -7)))
+ (is (= (+ 3 (imaginary -2)) (complex 3 -2)))
+ (is (= (+ (imaginary -2) 3) (complex 3 -2)))
+ (is (= (+ 3 (imaginary 5)) (complex 3 5)))
+ (is (= (+ (imaginary 5) 3) (complex 3 5)))
+ (is (= (+ -1 (complex 1 2)) (imaginary 2)))
+ (is (= (+ (complex 1 2) -1) (imaginary 2)))
+ (is (= (+ -1 (complex -3 -7)) (complex -4 -7)))
+ (is (= (+ (complex -3 -7) -1) (complex -4 -7)))
+ (is (= (+ -1 (imaginary -2)) (complex -1 -2)))
+ (is (= (+ (imaginary -2) -1) (complex -1 -2)))
+ (is (= (+ -1 (imaginary 5)) (complex -1 5)))
+ (is (= (+ (imaginary 5) -1) (complex -1 5)))
+ (is (= (+ (imaginary -2) (complex 1 2)) 1))
+ (is (= (+ (complex 1 2) (imaginary -2)) 1))
+ (is (= (+ (imaginary -2) (complex -3 -7)) (complex -3 -9)))
+ (is (= (+ (complex -3 -7) (imaginary -2)) (complex -3 -9)))
+ (is (= (+ (imaginary -2) 3) (complex 3 -2)))
+ (is (= (+ 3 (imaginary -2)) (complex 3 -2)))
+ (is (= (+ (imaginary -2) -1) (complex -1 -2)))
+ (is (= (+ -1 (imaginary -2)) (complex -1 -2)))
+ (is (= (+ (imaginary -2) (imaginary -2)) (imaginary -4)))
+ (is (= (+ (imaginary -2) (imaginary 5)) (imaginary 3)))
+ (is (= (+ (imaginary 5) (imaginary -2)) (imaginary 3)))
+ (is (= (+ (imaginary 5) (complex 1 2)) (complex 1 7)))
+ (is (= (+ (complex 1 2) (imaginary 5)) (complex 1 7)))
+ (is (= (+ (imaginary 5) (complex -3 -7)) (complex -3 -2)))
+ (is (= (+ (complex -3 -7) (imaginary 5)) (complex -3 -2)))
+ (is (= (+ (imaginary 5) 3) (complex 3 5)))
+ (is (= (+ 3 (imaginary 5)) (complex 3 5)))
+ (is (= (+ (imaginary 5) -1) (complex -1 5)))
+ (is (= (+ -1 (imaginary 5)) (complex -1 5)))
+ (is (= (+ (imaginary 5) (imaginary -2)) (imaginary 3)))
+ (is (= (+ (imaginary -2) (imaginary 5)) (imaginary 3)))
+ (is (= (+ (imaginary 5) (imaginary 5)) (imaginary 10))))
+
+(deftest complex-subtraction
+ (is (= (- (complex 1 2) (complex 1 2)) 0))
+ (is (= (- (complex 1 2) (complex -3 -7)) (complex 4 9)))
+ (is (= (- (complex -3 -7) (complex 1 2)) (complex -4 -9)))
+ (is (= (- (complex 1 2) 3) (complex -2 2)))
+ (is (= (- 3 (complex 1 2)) (complex 2 -2)))
+ (is (= (- (complex 1 2) -1) (complex 2 2)))
+ (is (= (- -1 (complex 1 2)) (complex -2 -2)))
+ (is (= (- (complex 1 2) (imaginary -2)) (complex 1 4)))
+ (is (= (- (imaginary -2) (complex 1 2)) (complex -1 -4)))
+ (is (= (- (complex 1 2) (imaginary 5)) (complex 1 -3)))
+ (is (= (- (imaginary 5) (complex 1 2)) (complex -1 3)))
+ (is (= (- (complex -3 -7) (complex 1 2)) (complex -4 -9)))
+ (is (= (- (complex 1 2) (complex -3 -7)) (complex 4 9)))
+ (is (= (- (complex -3 -7) (complex -3 -7)) 0))
+ (is (= (- (complex -3 -7) 3) (complex -6 -7)))
+ (is (= (- 3 (complex -3 -7)) (complex 6 7)))
+ (is (= (- (complex -3 -7) -1) (complex -2 -7)))
+ (is (= (- -1 (complex -3 -7)) (complex 2 7)))
+ (is (= (- (complex -3 -7) (imaginary -2)) (complex -3 -5)))
+ (is (= (- (imaginary -2) (complex -3 -7)) (complex 3 5)))
+ (is (= (- (complex -3 -7) (imaginary 5)) (complex -3 -12)))
+ (is (= (- (imaginary 5) (complex -3 -7)) (complex 3 12)))
+ (is (= (- 3 (complex 1 2)) (complex 2 -2)))
+ (is (= (- (complex 1 2) 3) (complex -2 2)))
+ (is (= (- 3 (complex -3 -7)) (complex 6 7)))
+ (is (= (- (complex -3 -7) 3) (complex -6 -7)))
+ (is (= (- 3 (imaginary -2)) (complex 3 2)))
+ (is (= (- (imaginary -2) 3) (complex -3 -2)))
+ (is (= (- 3 (imaginary 5)) (complex 3 -5)))
+ (is (= (- (imaginary 5) 3) (complex -3 5)))
+ (is (= (- -1 (complex 1 2)) (complex -2 -2)))
+ (is (= (- (complex 1 2) -1) (complex 2 2)))
+ (is (= (- -1 (complex -3 -7)) (complex 2 7)))
+ (is (= (- (complex -3 -7) -1) (complex -2 -7)))
+ (is (= (- -1 (imaginary -2)) (complex -1 2)))
+ (is (= (- (imaginary -2) -1) (complex 1 -2)))
+ (is (= (- -1 (imaginary 5)) (complex -1 -5)))
+ (is (= (- (imaginary 5) -1) (complex 1 5)))
+ (is (= (- (imaginary -2) (complex 1 2)) (complex -1 -4)))
+ (is (= (- (complex 1 2) (imaginary -2)) (complex 1 4)))
+ (is (= (- (imaginary -2) (complex -3 -7)) (complex 3 5)))
+ (is (= (- (complex -3 -7) (imaginary -2)) (complex -3 -5)))
+ (is (= (- (imaginary -2) 3) (complex -3 -2)))
+ (is (= (- 3 (imaginary -2)) (complex 3 2)))
+ (is (= (- (imaginary -2) -1) (complex 1 -2)))
+ (is (= (- -1 (imaginary -2)) (complex -1 2)))
+ (is (= (- (imaginary -2) (imaginary -2)) 0))
+ (is (= (- (imaginary -2) (imaginary 5)) (imaginary -7)))
+ (is (= (- (imaginary 5) (imaginary -2)) (imaginary 7)))
+ (is (= (- (imaginary 5) (complex 1 2)) (complex -1 3)))
+ (is (= (- (complex 1 2) (imaginary 5)) (complex 1 -3)))
+ (is (= (- (imaginary 5) (complex -3 -7)) (complex 3 12)))
+ (is (= (- (complex -3 -7) (imaginary 5)) (complex -3 -12)))
+ (is (= (- (imaginary 5) 3) (complex -3 5)))
+ (is (= (- 3 (imaginary 5)) (complex 3 -5)))
+ (is (= (- (imaginary 5) -1) (complex 1 5)))
+ (is (= (- -1 (imaginary 5)) (complex -1 -5)))
+ (is (= (- (imaginary 5) (imaginary -2)) (imaginary 7)))
+ (is (= (- (imaginary -2) (imaginary 5)) (imaginary -7)))
+ (is (= (- (imaginary 5) (imaginary 5)) 0)))
+
+(deftest complex-multiplication
+ (is (= (* (complex 1 2) (complex 1 2)) (complex -3 4)))
+ (is (= (* (complex 1 2) (complex -3 -7)) (complex 11 -13)))
+ (is (= (* (complex -3 -7) (complex 1 2)) (complex 11 -13)))
+ (is (= (* (complex 1 2) 3) (complex 3 6)))
+ (is (= (* 3 (complex 1 2)) (complex 3 6)))
+ (is (= (* (complex 1 2) -1) (complex -1 -2)))
+ (is (= (* -1 (complex 1 2)) (complex -1 -2)))
+ (is (= (* (complex 1 2) (imaginary -2)) (complex 4 -2)))
+ (is (= (* (imaginary -2) (complex 1 2)) (complex 4 -2)))
+ (is (= (* (complex 1 2) (imaginary 5)) (complex -10 5)))
+ (is (= (* (imaginary 5) (complex 1 2)) (complex -10 5)))
+ (is (= (* (complex -3 -7) (complex 1 2)) (complex 11 -13)))
+ (is (= (* (complex 1 2) (complex -3 -7)) (complex 11 -13)))
+ (is (= (* (complex -3 -7) (complex -3 -7)) (complex -40 42)))
+ (is (= (* (complex -3 -7) 3) (complex -9 -21)))
+ (is (= (* 3 (complex -3 -7)) (complex -9 -21)))
+ (is (= (* (complex -3 -7) -1) (complex 3 7)))
+ (is (= (* -1 (complex -3 -7)) (complex 3 7)))
+ (is (= (* (complex -3 -7) (imaginary -2)) (complex -14 6)))
+ (is (= (* (imaginary -2) (complex -3 -7)) (complex -14 6)))
+ (is (= (* (complex -3 -7) (imaginary 5)) (complex 35 -15)))
+ (is (= (* (imaginary 5) (complex -3 -7)) (complex 35 -15)))
+ (is (= (* 3 (complex 1 2)) (complex 3 6)))
+ (is (= (* (complex 1 2) 3) (complex 3 6)))
+ (is (= (* 3 (complex -3 -7)) (complex -9 -21)))
+ (is (= (* (complex -3 -7) 3) (complex -9 -21)))
+ (is (= (* 3 (imaginary -2)) (imaginary -6)))
+ (is (= (* (imaginary -2) 3) (imaginary -6)))
+ (is (= (* 3 (imaginary 5)) (imaginary 15)))
+ (is (= (* (imaginary 5) 3) (imaginary 15)))
+ (is (= (* -1 (complex 1 2)) (complex -1 -2)))
+ (is (= (* (complex 1 2) -1) (complex -1 -2)))
+ (is (= (* -1 (complex -3 -7)) (complex 3 7)))
+ (is (= (* (complex -3 -7) -1) (complex 3 7)))
+ (is (= (* -1 (imaginary -2)) (imaginary 2)))
+ (is (= (* (imaginary -2) -1) (imaginary 2)))
+ (is (= (* -1 (imaginary 5)) (imaginary -5)))
+ (is (= (* (imaginary 5) -1) (imaginary -5)))
+ (is (= (* (imaginary -2) (complex 1 2)) (complex 4 -2)))
+ (is (= (* (complex 1 2) (imaginary -2)) (complex 4 -2)))
+ (is (= (* (imaginary -2) (complex -3 -7)) (complex -14 6)))
+ (is (= (* (complex -3 -7) (imaginary -2)) (complex -14 6)))
+ (is (= (* (imaginary -2) 3) (imaginary -6)))
+ (is (= (* 3 (imaginary -2)) (imaginary -6)))
+ (is (= (* (imaginary -2) -1) (imaginary 2)))
+ (is (= (* -1 (imaginary -2)) (imaginary 2)))
+ (is (= (* (imaginary -2) (imaginary -2)) -4))
+ (is (= (* (imaginary -2) (imaginary 5)) 10))
+ (is (= (* (imaginary 5) (imaginary -2)) 10))
+ (is (= (* (imaginary 5) (complex 1 2)) (complex -10 5)))
+ (is (= (* (complex 1 2) (imaginary 5)) (complex -10 5)))
+ (is (= (* (imaginary 5) (complex -3 -7)) (complex 35 -15)))
+ (is (= (* (complex -3 -7) (imaginary 5)) (complex 35 -15)))
+ (is (= (* (imaginary 5) 3) (imaginary 15)))
+ (is (= (* 3 (imaginary 5)) (imaginary 15)))
+ (is (= (* (imaginary 5) -1) (imaginary -5)))
+ (is (= (* -1 (imaginary 5)) (imaginary -5)))
+ (is (= (* (imaginary 5) (imaginary -2)) 10))
+ (is (= (* (imaginary -2) (imaginary 5)) 10))
+ (is (= (* (imaginary 5) (imaginary 5)) -25)))
+
+(deftest complex-division
+ (is (= (/ (complex 1 2) (complex 1 2)) 1))
+ (is (= (/ (complex 1 2) (complex -3 -7)) (complex -17/58 1/58)))
+ (is (= (/ (complex -3 -7) (complex 1 2)) (complex -17/5 -1/5)))
+ (is (= (/ (complex 1 2) 3) (complex 1/3 2/3)))
+ (is (= (/ 3 (complex 1 2)) (complex 3/5 -6/5)))
+ (is (= (/ (complex 1 2) -1) (complex -1 -2)))
+ (is (= (/ -1 (complex 1 2)) (complex -1/5 2/5)))
+ (is (= (/ (complex 1 2) (imaginary -2)) (complex -1 1/2)))
+ (is (= (/ (imaginary -2) (complex 1 2)) (complex -4/5 -2/5)))
+ (is (= (/ (complex 1 2) (imaginary 5)) (complex 2/5 -1/5)))
+ (is (= (/ (imaginary 5) (complex 1 2)) (complex 2 1)))
+ (is (= (/ (complex -3 -7) (complex 1 2)) (complex -17/5 -1/5)))
+ (is (= (/ (complex 1 2) (complex -3 -7)) (complex -17/58 1/58)))
+ (is (= (/ (complex -3 -7) (complex -3 -7)) 1))
+ (is (= (/ (complex -3 -7) 3) (complex -1 -7/3)))
+ (is (= (/ 3 (complex -3 -7)) (complex -9/58 21/58)))
+ (is (= (/ (complex -3 -7) -1) (complex 3 7)))
+ (is (= (/ -1 (complex -3 -7)) (complex 3/58 -7/58)))
+ (is (= (/ (complex -3 -7) (imaginary -2)) (complex 7/2 -3/2)))
+ (is (= (/ (imaginary -2) (complex -3 -7)) (complex 7/29 3/29)))
+ (is (= (/ (complex -3 -7) (imaginary 5)) (complex -7/5 3/5)))
+ (is (= (/ (imaginary 5) (complex -3 -7)) (complex -35/58 -15/58)))
+ (is (= (/ 3 (complex 1 2)) (complex 3/5 -6/5)))
+ (is (= (/ (complex 1 2) 3) (complex 1/3 2/3)))
+ (is (= (/ 3 (complex -3 -7)) (complex -9/58 21/58)))
+ (is (= (/ (complex -3 -7) 3) (complex -1 -7/3)))
+ #_(is (= (/ 3 (imaginary -2)) (imaginary 1.5)))
+ (is (= (/ (imaginary -2) 3) (imaginary -2/3)))
+ (is (= (/ 3 (imaginary 5)) (imaginary -3/5)))
+ (is (= (/ (imaginary 5) 3) (imaginary 5/3)))
+ (is (= (/ -1 (complex 1 2)) (complex -1/5 2/5)))
+ (is (= (/ (complex 1 2) -1) (complex -1 -2)))
+ (is (= (/ -1 (complex -3 -7)) (complex 3/58 -7/58)))
+ (is (= (/ (complex -3 -7) -1) (complex 3 7)))
+ (is (= (/ -1 (imaginary -2)) (imaginary -1/2)))
+ (is (= (/ (imaginary -2) -1) (imaginary 2)))
+ (is (= (/ -1 (imaginary 5)) (imaginary 1/5)))
+ (is (= (/ (imaginary 5) -1) (imaginary -5)))
+ (is (= (/ (imaginary -2) (complex 1 2)) (complex -4/5 -2/5)))
+ (is (= (/ (complex 1 2) (imaginary -2)) (complex -1 1/2)))
+ (is (= (/ (imaginary -2) (complex -3 -7)) (complex 7/29 3/29)))
+ (is (= (/ (complex -3 -7) (imaginary -2)) (complex 7/2 -3/2)))
+ (is (= (/ (imaginary -2) 3) (imaginary -2/3)))
+ (is (= (/ 3 (imaginary -2)) (imaginary 3/2)))
+ (is (= (/ (imaginary -2) -1) (imaginary 2)))
+ (is (= (/ -1 (imaginary -2)) (imaginary -1/2)))
+ (is (= (/ (imaginary -2) (imaginary -2)) 1))
+ (is (= (/ (imaginary -2) (imaginary 5)) -2/5))
+ (is (= (/ (imaginary 5) (imaginary -2)) -5/2))
+ (is (= (/ (imaginary 5) (complex 1 2)) (complex 2 1)))
+ (is (= (/ (complex 1 2) (imaginary 5)) (complex 2/5 -1/5)))
+ (is (= (/ (imaginary 5) (complex -3 -7)) (complex -35/58 -15/58)))
+ (is (= (/ (complex -3 -7) (imaginary 5)) (complex -7/5 3/5)))
+ (is (= (/ (imaginary 5) 3) (imaginary 5/3)))
+ (is (= (/ 3 (imaginary 5)) (imaginary -3/5)))
+ (is (= (/ (imaginary 5) -1) (imaginary -5)))
+ (is (= (/ -1 (imaginary 5)) (imaginary 1/5)))
+ (is (= (/ (imaginary 5) (imaginary -2)) -5/2))
+ (is (= (/ (imaginary -2) (imaginary 5)) -2/5))
+ (is (= (/ (imaginary 5) (imaginary 5)) 1)))
+
+(deftest complex-conjugate
+ (is (= (conjugate (complex 1 2)) (complex 1 -2)))
+ (is (= (conjugate (complex -3 -7)) (complex -3 7)))
+ (is (= (conjugate (imaginary -2)) (imaginary 2)))
+ (is (= (conjugate (imaginary 5)) (imaginary -5))))
+
+(deftest complex-abs
+ (doseq [c [(complex 1 2) (complex -2 3) (complex 4 -2)
+ (complex -3 -7) (imaginary -2) (imaginary 5)]]
+ (is (approx= (* c (conjugate c))
+ (sqr (abs c))
+ 1e-14))))
+
+(deftest complex-sqrt
+ (doseq [c [(complex 1 2) (complex -2 3) (complex 4 -2)
+ (complex -3 -7) (imaginary -2) (imaginary 5)]]
+ (let [r (sqrt c)]
+ (is (approx= c (sqr r) 1e-14))
+ (is (>= (real r) 0)))))
+
+(deftest complex-exp
+ (is (approx= (exp (complex 1 2))
+ (complex -1.1312043837568135 2.4717266720048188)
+ 1e-14))
+ (is (approx= (exp (complex 2 3))
+ (complex -7.3151100949011028 1.0427436562359045)
+ 1e-14))
+ (is (approx= (exp (complex 4 -2))
+ (complex -22.720847417619233 -49.645957334580565)
+ 1e-14))
+ (is (approx= (exp (complex 3 -7))
+ (complex 15.142531566086868 -13.195928586605717)
+ 1e-14))
+ (is (approx= (exp (imaginary -2))
+ (complex -0.41614683654714241 -0.90929742682568171)
+ 1e-14))
+ (is (approx= (exp (imaginary 5))
+ (complex 0.2836621854632263 -0.95892427466313845)
+ 1e-14)))
diff --git a/modules/core/src/test/clojure/clojure/contrib/test_core.clj b/modules/core/src/test/clojure/clojure/contrib/test_core.clj
new file mode 100644
index 00000000..3048778c
--- /dev/null
+++ b/modules/core/src/test/clojure/clojure/contrib/test_core.clj
@@ -0,0 +1,42 @@
+; Copyright (c) Laurent Petit, March 2009. 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.
+
+;; test namespace for clojure.contrib.core
+
+;; note to other contrib members: feel free to add to this lib
+
+(ns clojure.contrib.test-core
+ (:use clojure.test)
+ (:use clojure.contrib.core))
+
+(deftest test-classic-versions
+ (testing "Classic -> throws NPE if passed nil"
+ (is (thrown? NullPointerException (-> nil .toString)))
+ (is (thrown? NullPointerException (-> "foo" seq next next next .toString))))
+ (testing "Classic .. throws NPE if one of the intermediate threaded values is nil"
+ (is (thrown? NullPointerException (.. nil toString)))
+ (is (thrown? NullPointerException (.. [nil] (get 0) toString)))))
+
+(deftest test-new-versions
+ (testing "Version -?>> falls out on nil"
+ (is (nil? (-?>> nil .toString)))
+ (is (nil? (-?>> [] seq (map inc))))
+ (is (= [] (->> [] seq (map inc)))))
+ (testing "Version -?>> completes for non-nil"
+ (is (= [3 4] (-?>> [1 2] (map inc) (map inc)))))
+ (testing "Version -?> falls out on nil"
+ (is (nil? (-?> nil .toString)))
+ (is (nil? (-?> "foo" seq next next next .toString))))
+ (testing "Version -?> completes for non-nil"
+ (is (= [\O \O] (-?> "foo" .toUpperCase rest))))
+ (testing "Version .?. returns nil if one of the intermediate threaded values is nil"
+ (is (nil? (.?. nil toString)))
+ (is (nil? (.?. [nil] (get 0) toString)))))
+
diff --git a/modules/dataflow/src/test/clojure/clojure/contrib/test_dataflow.clj b/modules/dataflow/src/test/clojure/clojure/contrib/test_dataflow.clj
new file mode 100644
index 00000000..55e9592b
--- /dev/null
+++ b/modules/dataflow/src/test/clojure/clojure/contrib/test_dataflow.clj
@@ -0,0 +1,90 @@
+;; Copyright (c) Jeffrey Straszheim. 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.
+;;
+;; test-dataflow
+;;
+;; A Library to Support a Dataflow Model of State - Tests
+;;
+;; straszheimjeffrey (gmail)
+;; Created 11 March 2009
+
+
+(ns clojure.contrib.test-dataflow
+ (:use clojure.test)
+ (:use clojure.contrib.dataflow))
+
+(def df-1
+ (build-dataflow
+ [(cell :source base 0)
+ (cell :source items ())
+ (cell product (* ?base (apply + ?items)))
+ (cell :validator (when (number? ?-product)
+ (assert (>= ?product ?-product))))]))
+
+(deftest test-df-1
+ (is (= (get-value df-1 'product) 0))
+ (is (do (update-values df-1 {'items [4 5]})
+ (= (get-value df-1 'product) 0)))
+ (is (do (update-values df-1 {'base 2})
+ (= (get-value df-1 'product) 18)))
+ (is (thrown? AssertionError (update-values df-1 {'base 0})))
+ (is (= (get-value df-1 'product) 18)))
+
+(def df-2
+ (build-dataflow
+ [(cell :source strength 10)
+ (cell :source agility 10)
+ (cell :source magic 10)
+
+ (cell total-cost (apply + ?*cost))
+
+ (cell cost (- ?strength 10))
+ (cell cost (- ?agility 10))
+ (cell cost (- ?magic 10))
+
+ (cell combat (+ ?strength ?agility ?combat-mod))
+ (cell speed (+ ?agility (/ ?strength 10.0) ?speed-mod))
+ (cell casting (+ ?agility ?magic ?magic-mod))
+
+ (cell combat-mod (apply + ?*combat-mods))
+ (cell speed-mod (apply + ?*speed-mods))
+ (cell magic-mod (apply + ?*magic-mods))]))
+
+(def magic-skill
+ [(cell cost 5)
+ (cell speed-mods 1)
+ (cell magic-mods 2)])
+
+(defn gv [n] (get-value df-2 n))
+
+(deftest test-df-2
+ (is (and (= (gv 'total-cost) 0)
+ (= (gv 'strength) 10)
+ (= (gv 'casting) 20)))
+ (is (do (update-values df-2 {'magic 12})
+ (and (= (gv 'total-cost) 2)
+ (= (gv 'casting) 22))))
+ (is (do (add-cells df-2 magic-skill)
+ (and (= (gv 'total-cost) 7)
+ (= (gv 'casting) 24))))
+ (is (do (remove-cells df-2 magic-skill)
+ (and (= (gv 'total-cost) 2)
+ (= (gv 'casting) 22)))))
+
+
+(comment
+ (run-tests)
+
+ (use :reload 'clojure.contrib.dataflow)
+ (use 'clojure.contrib.stacktrace) (e)
+ (use 'clojure.contrib.trace)
+
+)
+
+
+;; End of file
diff --git a/modules/datalog/pom.xml b/modules/datalog/pom.xml
index 4a1bdf3b..90d5fbf7 100644
--- a/modules/datalog/pom.xml
+++ b/modules/datalog/pom.xml
@@ -17,5 +17,25 @@
<artifactId>except</artifactId>
<version>1.3.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.clojure.contrib</groupId>
+ <artifactId>seq</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.clojure.contrib</groupId>
+ <artifactId>def</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.clojure.contrib</groupId>
+ <artifactId>set</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.clojure.contrib</groupId>
+ <artifactId>graph</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ </dependency>
</dependencies>
</project> \ No newline at end of file
diff --git a/modules/datalog/src/test/clojure/clojure/contrib/datalog/tests/test.clj b/modules/datalog/src/test/clojure/clojure/contrib/datalog/tests/test.clj
new file mode 100644
index 00000000..121d264e
--- /dev/null
+++ b/modules/datalog/src/test/clojure/clojure/contrib/datalog/tests/test.clj
@@ -0,0 +1,45 @@
+;; Copyright (c) Jeffrey Straszheim. 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.
+;;
+;; test.clj
+;;
+;; A Clojure implementation of Datalog -- Tests
+;;
+;; straszheimjeffrey (gmail)
+;; Created 11 Feburary 2009
+
+(ns clojure.contrib.datalog.tests.test
+ (:use [clojure.test :only (run-tests)])
+ (:gen-class))
+
+(def test-names [:test-util
+ :test-database
+ :test-literals
+ :test-rules
+ :test-magic
+ :test-softstrat])
+
+(def test-namespaces
+ (map #(symbol (str "clojure.contrib.datalog.tests." (name %)))
+ test-names))
+
+(defn run
+ "Runs all defined tests"
+ []
+ (println "Loading tests...")
+ (apply require :reload-all test-namespaces)
+ (apply run-tests test-namespaces))
+
+(defn -main
+ "Run all defined tests from the command line"
+ [& args]
+ (run)
+ (System/exit 0))
+
+
+;; End of file
diff --git a/modules/datalog/src/test/clojure/clojure/contrib/datalog/tests/test_database.clj b/modules/datalog/src/test/clojure/clojure/contrib/datalog/tests/test_database.clj
new file mode 100644
index 00000000..77719008
--- /dev/null
+++ b/modules/datalog/src/test/clojure/clojure/contrib/datalog/tests/test_database.clj
@@ -0,0 +1,153 @@
+;; Copyright (c) Jeffrey Straszheim. All rights reserved. The use and
+;; distribution terms for this software are covered by the Eclipse Public
+;; License 1.0 (http://ope