aboutsummaryrefslogtreecommitdiffstats
path: root/test/testunit/collector/test_objectspace.rb
diff options
context:
space:
mode:
authorntalbott <ntalbott@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-10-08 13:21:28 +0000
committerntalbott <ntalbott@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-10-08 13:21:28 +0000
commit09d2946061379d18407d4de2002a01f3a82c8c84 (patch)
treeeaefbd65eb42404ac9230f108bed0576943269ca /test/testunit/collector/test_objectspace.rb
parent777681bda1fe3fbc33bd2c3d4ce132e6b8c0042e (diff)
downloadruby-09d2946061379d18407d4de2002a01f3a82c8c84.tar.gz
* lib/test/unit.rb: removed installation instructions.
* lib/test/unit/ui/testrunnermediator.rb: moved the run flag to a more central location. * lib/test/unit.rb: ditto. * lib/test/unit.rb: extracted the running code in to AutoRunner. * lib/test/unit/autorunner.rb: added. * lib/test/unit/collector/objectspace.rb: extracted common test collection functionality in to a module. * lib/test/unit/collector.rb: ditto; added. * test/testunit/collector/test_objectspace.rb: ditto. * lib/test/unit/collector/dir.rb: added. Supports collecting tests out of a directory structure. * test/testunit/collector/test_dir.rb: added. * test/runner.rb: simplified to use the new capabilities. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4720 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/testunit/collector/test_objectspace.rb')
-rw-r--r--test/testunit/collector/test_objectspace.rb61
1 files changed, 38 insertions, 23 deletions
diff --git a/test/testunit/collector/test_objectspace.rb b/test/testunit/collector/test_objectspace.rb
index 488f2e394c..a1532ff3e6 100644
--- a/test/testunit/collector/test_objectspace.rb
+++ b/test/testunit/collector/test_objectspace.rb
@@ -37,45 +37,60 @@ module Test
def @object_space.each_object(type)
self[type].each{|item| yield(item) }
end
+
+ @c = ObjectSpace.new(@object_space)
end
-
- def test_basic_collection
- expected = TestSuite.new("name")
+
+ def full_suite(name=ObjectSpace::NAME)
+ expected = TestSuite.new(name)
expected << (TestSuite.new(@tc1.name) << @tc1.new('test_1') << @tc1.new('test_2'))
expected << (TestSuite.new(@tc2.name) << @tc2.new('test_0'))
- assert_equal(expected, ObjectSpace.new(@object_space).collect("name"))
+ end
+
+ def empty_suite
+ TestSuite.new(ObjectSpace::NAME)
+ end
+
+ def test_basic_collection
+ assert_equal(full_suite("name"), @c.collect("name"))
- c = ObjectSpace.new(@object_space)
- c.filter = []
- assert_equal(expected, c.collect("name"))
+ @c.filter = []
+ assert_equal(full_suite("name"), @c.collect("name"))
end
def test_filtered_collection
- expected = TestSuite.new(ObjectSpace::NAME)
- collector = ObjectSpace.new(@object_space)
- collector.filter = proc{|test| false}
- assert_equal(expected, collector.collect)
+ @c.filter = proc{false}
+ assert_equal(empty_suite, @c.collect)
- expected = TestSuite.new(ObjectSpace::NAME)
- expected << (TestSuite.new(@tc1.name) << @tc1.new('test_1') << @tc1.new('test_2'))
- expected << (TestSuite.new(@tc2.name) << @tc2.new('test_0'))
- collector = ObjectSpace.new(@object_space)
- collector.filter = proc{|test| true}
- assert_equal(expected, collector.collect)
+ @c.filter = proc{true}
+ assert_equal(full_suite, @c.collect)
+
+ @c.filter = proc{nil}
+ assert_equal(full_suite, @c.collect)
+
+ @c.filter = [proc{false}, proc{true}]
+ assert_equal(empty_suite, @c.collect)
+
+ @c.filter = [proc{true}, proc{false}]
+ assert_equal(full_suite, @c.collect)
+ @c.filter = [proc{nil}, proc{false}]
+ assert_equal(empty_suite, @c.collect)
+
+ @c.filter = [proc{nil}, proc{true}]
+ assert_equal(full_suite, @c.collect)
+
expected = TestSuite.new(ObjectSpace::NAME)
expected << (TestSuite.new(@tc1.name) << @tc1.new('test_1'))
expected << (TestSuite.new(@tc2.name) << @tc2.new('test_0'))
- collector = ObjectSpace.new(@object_space)
- collector.filter = proc{|test| ['test_1', 'test_0'].include?(test.method_name)}
- assert_equal(expected, collector.collect)
+ @c.filter = proc{|test| ['test_1', 'test_0'].include?(test.method_name)}
+ assert_equal(expected, @c.collect)
expected = TestSuite.new(ObjectSpace::NAME)
expected << (TestSuite.new(@tc1.name) << @tc1.new('test_1'))
expected << (TestSuite.new(@tc2.name) << @tc2.new('test_0'))
- collector = ObjectSpace.new(@object_space)
- collector.filter = [proc{|test| test.method_name == 'test_1'}, proc{|test| test.method_name == 'test_0'}]
- assert_equal(expected, collector.collect)
+ @c.filter = [proc{|t| t.method_name == 'test_1' ? true : nil}, proc{|t| t.method_name == 'test_0' ? true : nil}, proc{false}]
+ assert_equal(expected, @c.collect)
end
end
end