From: GOTO Kentaro Date: 2002-09-17T15:04:31+09:00 Subject: Re: Dependency "trees" - suggestions? At Tue, 17 Sep 2002 10:30:30 +0900, Massimiliano Mirra wrote: > Failure occurred in test_cycle(TSortTest) > [/home/bard/lib/ruby/runit/assert.rb:56]: Expected exception to > be of type but was > > def test_cycle > h = {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]} > assert_equal([[4], [2, 3], [1]], > h.strongly_connected_components.map {|nodes| nodes.sort}) > assert_exception(TSort::Cyclic) { h.tsort } # <----- > end That wasn't reproduced here with test/unit: % cat ~/foo.rb require "test/unit" require "test/unit/ui/console/testrunner" class Hash include TSort alias tsort_each_node each_key def tsort_each_child(node, &block) fetch(node).each(&block) end end class TestMe < Test::Unit::TestCase def test_cycle h = {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 } # <----- end end % ruby -r ~/ruby/ruby/lib/tsort.rb ~/foo.rb Loaded suite /home/gotoken/foo Started... .. Finished in 0.005655 seconds. 1 runs, 2 assertions, 0 failures, 0 errors % ruby -v ruby 1.6.7 (2002-05-23) [i386-freebsd4] % -- Gotoken