diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-11-26 10:46:50 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-11-26 10:46:50 +0000 |
commit | 0eadc632c1c377d52965e67a8ef09a80fa54f341 (patch) | |
tree | b6fcb5e1c51ff735aa4af9d14354a407a5fe6d2a /test/test_tsort.rb | |
parent | eab191040e9356a8ed4aaa418a7904d6f94064b9 (diff) |
* lib/tsort.rb: Returns an enumerator if no block is given.
[ruby-core:66270] [Feature #10508] Proposed by Andrey Savchenko.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48584 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/test_tsort.rb')
-rw-r--r-- | test/test_tsort.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/test_tsort.rb b/test/test_tsort.rb index bd60f696a8..4a13a6e635 100644 --- a/test/test_tsort.rb +++ b/test/test_tsort.rb @@ -57,6 +57,9 @@ class TSortTest < Test::Unit::TestCase # :nodoc: r = [] TSort.tsort_each(each_node, each_child) {|n| r << n } assert_equal([4, 2, 3, 1], r) + + r = TSort.tsort_each(each_node, each_child).map {|n| n.to_s } + assert_equal(['4', '2', '3', '1'], r) end def test_s_strongly_connected_components @@ -85,6 +88,11 @@ class TSortTest < Test::Unit::TestCase # :nodoc: r << scc } assert_equal([[4], [2, 3], [1]], r) + + r = TSort.each_strongly_connected_component(each_node, each_child).map {|scc| + scc.map(&:to_s) + } + assert_equal([['4'], ['2', '3'], ['1']], r) end def test_s_each_strongly_connected_component_from @@ -95,6 +103,11 @@ class TSortTest < Test::Unit::TestCase # :nodoc: r << scc } assert_equal([[4], [2, 3], [1]], r) + + r = TSort.each_strongly_connected_component_from(1, each_child).map {|scc| + scc.map(&:to_s) + } + assert_equal([['4'], ['2', '3'], ['1']], r) end end |