1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/lib/test/unit/collector/objectspace.rb
ntalbott 18ef8f1078 * lib/test/unit/assertions.rb: should not capture an
AssertionFailedError unless explicitly requested.

	* test/testunit/test_assertions.rb: ditto.

	* test/testunit/collector/test_objectspace.rb: fixed a test failure
	  caused by methods being returned in different orders on different
	  platforms by moving test sorting from TestSuite into the locations
	  where suites are constructed. [ruby-talk:83156]

	* lib/test/unit/testcase.rb: ditto.

	* lib/test/unit/testsuite.rb: ditto.

	* lib/test/unit/collector/objectspace.rb: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4648 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-10-02 02:20:42 +00:00

44 lines
1.1 KiB
Ruby

# Author:: Nathaniel Talbott.
# Copyright:: Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved.
# License:: Ruby license.
module Test
module Unit
module Collector
class ObjectSpace
NAME = 'collected from the ObjectSpace'
def initialize(source=::ObjectSpace)
@source = source
end
def collect(name=NAME)
suite = TestSuite.new(name)
tests = []
@source.each_object(Class) do |klass|
tests.concat(klass.suite.tests) if(Test::Unit::TestCase > klass)
end
tests.sort_by{|t| t.name}.each{|test| suite << test if(include(test))}
suite
end
def include(test)
return true unless(@filters)
@filters.each do |filter|
return true if(filter.call(test))
end
false
end
def filter=(filters)
@filters = case(filters)
when Proc
[filters]
when Array
filters
end
end
end
end
end
end