From: Joel VanderWerf Date: 2007-10-28T15:23:04+09:00 Subject: Re: How fast does your Ruby run? Charles Oliver Nutter wrote: > In general, the tricky bit is that there's at least one key library in > stdlib that depends on ObjectSpace: test/unit, which uses it to locate > tests. However I've implemented in JRuby the ability to walk all child > classes from a parent class, which provides the each_object(Class) used > in test/unit. The dependence on ObjectSpace is kind of nasty, isn't it? A library shouldn't use ObjectSpace in this way, because what it finds there may depend on whether GC has run recently or not. Good to hear you found a way to support it anyway, though. Does your mechanism to walk child classes prevent them from being collected, if there are no other references to them? If so, then it isn't quite bug-compatible (though it is unlikely to matter): require 'test/unit' def add_a_test_case str puts "adding test case #{str}" Class.new(Test::Unit::TestCase).class_eval do define_method :test_foo do puts "running test case #{str}" end end end at_exit { GC.start } at_exit { add_a_test_case 1 } at_exit { add_a_test_case 2 } at_exit { add_a_test_case 3 } at_exit { add_a_test_case 4 } __END__ adding test case 4 adding test case 3 adding test case 2 adding test case 1 Loaded suite - Started running test case 1 . Finished in 0.000918 seconds. 1 tests, 0 assertions, 0 failures, 0 errors -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407