summaryrefslogtreecommitdiffstats
path: root/lib/tsort.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-02-11 17:36:37 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-02-11 17:36:37 +0000
commitb808479dad77a34c2c2471ea421fc8e3ee8e7f1b (patch)
treee0d4b2e0013eb0bd59cc9d63b1e575e52e75011d /lib/tsort.rb
parent96ffa67b2a658d6762aa1ebca140c0144bc6a425 (diff)
downloadruby-b808479dad77a34c2c2471ea421fc8e3ee8e7f1b.tar.gz
ruby-b808479dad77a34c2c2471ea421fc8e3ee8e7f1b.tar.xz
ruby-b808479dad77a34c2c2471ea421fc8e3ee8e7f1b.zip
* lib/pathname.rb: use assert_raise instead of assert_raises.
* lib/pp.rb: ditto. * lib/time.rb: ditto. * lib/tsort.rb: ditto. use TSortHash and TSortArray instead of Hash and Array in test. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@5673 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/tsort.rb')
-rw-r--r--lib/tsort.rb14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/tsort.rb b/lib/tsort.rb
index 5efd6480d..f52d0996c 100644
--- a/lib/tsort.rb
+++ b/lib/tsort.rb
@@ -244,7 +244,7 @@ end
if __FILE__ == $0
require 'test/unit'
- class Hash # :nodoc:
+ class TSortHash < Hash # :nodoc:
include TSort
alias tsort_each_node each_key
def tsort_each_child(node, &block)
@@ -252,7 +252,7 @@ if __FILE__ == $0
end
end
- class Array # :nodoc:
+ class TSortArray < Array # :nodoc:
include TSort
alias tsort_each_node each_index
def tsort_each_child(node, &block)
@@ -262,24 +262,24 @@ if __FILE__ == $0
class TSortTest < Test::Unit::TestCase # :nodoc:
def test_dag
- h = {1=>[2, 3], 2=>[3], 3=>[]}
+ h = TSortHash[{1=>[2, 3], 2=>[3], 3=>[]}]
assert_equal([3, 2, 1], h.tsort)
assert_equal([[3], [2], [1]], h.strongly_connected_components)
end
def test_cycle
- h = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}
+ h = TSortHash[{1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}]
assert_equal([[4], [2, 3], [1]],
h.strongly_connected_components.map {|nodes| nodes.sort})
- assert_raises(TSort::Cyclic) { h.tsort }
+ assert_raise(TSort::Cyclic) { h.tsort }
end
def test_array
- a = [[1], [0], [0], [2]]
+ a = TSortArray[[1], [0], [0], [2]]
assert_equal([[0, 1], [2], [3]],
a.strongly_connected_components.map {|nodes| nodes.sort})
- a = [[], [0]]
+ a = TSortArray[[], [0]]
assert_equal([[0], [1]],
a.strongly_connected_components.map {|nodes| nodes.sort})
end