aboutsummaryrefslogtreecommitdiff
path: root/src/clojure/contrib/test_contrib
diff options
context:
space:
mode:
authorJeffrey Straszheim <straszheimjeffrey@gmail.com>2009-02-24 02:15:12 +0000
committerJeffrey Straszheim <straszheimjeffrey@gmail.com>2009-02-24 02:15:12 +0000
commit981971d6ad5d1981557a69b7efef846ee851ae39 (patch)
tree468adf2a7b25bec8ced2ab93d4337f3e3f3fe3f9 /src/clojure/contrib/test_contrib
parent432372af9773809955e4ce5fcfa2d140bcbbe1d7 (diff)
Dependency graphs
Diffstat (limited to 'src/clojure/contrib/test_contrib')
-rw-r--r--src/clojure/contrib/test_contrib/test_graph.clj58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/clojure/contrib/test_contrib/test_graph.clj b/src/clojure/contrib/test_contrib/test_graph.clj
index 093462b8..94daeccd 100644
--- a/src/clojure/contrib/test_contrib/test_graph.clj
+++ b/src/clojure/contrib/test_contrib/test_graph.clj
@@ -64,6 +64,64 @@
[#{8 9} #{7} #{6} #{5} #{0 1 2 3 4}]))
(is (empty? (scc empty-graph))))
+
+(deftest test-self-recursive-sets
+ (is (= (self-recursive-sets test-graph-2)
+ [#{8 9} #{5} #{0 1 2 3 4}]))
+ (is (empty? (self-recursive-sets empty-graph))))
+
+
+(def test-graph-3
+ (struct directed-graph 6
+ {0 [1]
+ 1 [2]
+ 2 [3]
+ 3 [4]
+ 4 [5]
+ 5 []}))
+
+(def test-graph-4
+ (struct directed-graph 8
+ {0 []
+ 1 [0]
+ 2 [0]
+ 3 [0 1]
+ 4 [3 2]
+ 5 [4]
+ 6 [3]
+ 7 [5]}))
+
+ (def test-graph-5
+ (struct directed-graph 8
+ {0 []
+ 1 []
+ 2 [1]
+ 3 []
+ 4 []
+ 5 []
+ 6 [5]
+ 7 []}))
+
+(deftest test-dependency-list
+ (is (thrown-with-msg? Exception #".*Fixed point overflow.*"
+ (dependency-list test-graph-2)))
+ (is (= (dependency-list test-graph-3)
+ [#{5} #{4} #{3} #{2} #{1} #{0}]))
+ (is (= (dependency-list test-graph-4)
+ [#{0} #{1 2} #{3} #{4 6} #{5} #{7}]))
+ (is (= (dependency-list test-graph-5)
+ [#{0 1 3 4 5 7} #{2 6}]))
+ (is (= (dependency-list empty-graph)
+ [#{}])))
+
+(deftest test-stratification-list
+ (is (thrown-with-msg? Exception #".*Fixed point overflow.*"
+ (stratification-list test-graph-2 test-graph-2)))
+ (is (= (stratification-list test-graph-4 test-graph-5)
+ [#{0} #{1 2} #{3} #{4} #{5 6} #{7}]))
+ (is (= (stratification-list empty-graph empty-graph)
+ [#{}])))
+
(comment
(run-tests)
)