diff options
Diffstat (limited to 'test/test_tsort.rb')
-rw-r--r-- | test/test_tsort.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/test_tsort.rb b/test/test_tsort.rb index 38018c49c0..a732064f31 100644 --- a/test/test_tsort.rb +++ b/test/test_tsort.rb @@ -40,5 +40,15 @@ class TSortTest < Test::Unit::TestCase # :nodoc: assert_equal([[0], [1]], a.strongly_connected_components.map {|nodes| nodes.sort}) end + + def test_noclass + g = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]} + each_child = lambda {|n, &b| g[n].each(&b) } + r = [] + TSort.each_strongly_connected_component_from(1, each_child) {|scc| + r << scc + } + assert_equal([[4], [2, 3], [1]], r) + end end |