diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/testunit/collector/test_objectspace.rb | 24 | ||||
-rw-r--r-- | test/testunit/test_testsuite.rb | 33 |
2 files changed, 37 insertions, 20 deletions
diff --git a/test/testunit/collector/test_objectspace.rb b/test/testunit/collector/test_objectspace.rb index 37de5a439b..488f2e394c 100644 --- a/test/testunit/collector/test_objectspace.rb +++ b/test/testunit/collector/test_objectspace.rb @@ -11,6 +11,9 @@ module Test class TC_ObjectSpace < TestCase def setup @tc1 = Class.new(TestCase) do + def self.name + "tc_1" + end def test_1 end def test_2 @@ -18,6 +21,9 @@ module Test end @tc2 = Class.new(TestCase) do + def self.name + "tc_2" + end def test_0 end end @@ -35,9 +41,8 @@ module Test def test_basic_collection expected = TestSuite.new("name") - expected << @tc2.new('test_0') - expected << @tc1.new('test_1') - expected << @tc1.new('test_2') + 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")) c = ObjectSpace.new(@object_space) @@ -52,23 +57,22 @@ module Test assert_equal(expected, collector.collect) expected = TestSuite.new(ObjectSpace::NAME) - expected << @tc2.new('test_0') - expected << @tc1.new('test_1') - expected << @tc1.new('test_2') + 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) expected = TestSuite.new(ObjectSpace::NAME) - expected << @tc2.new('test_0') - expected << @tc1.new('test_1') + 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) expected = TestSuite.new(ObjectSpace::NAME) - expected << @tc2.new('test_0') - expected << @tc1.new('test_1') + 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) diff --git a/test/testunit/test_testsuite.rb b/test/testunit/test_testsuite.rb index 97f639da82..5f6631d3eb 100644 --- a/test/testunit/test_testsuite.rb +++ b/test/testunit/test_testsuite.rb @@ -2,8 +2,7 @@ # Copyright:: Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved. # License:: Ruby license. -require 'test/unit/testcase' -require 'test/unit/testsuite' +require 'test/unit' module Test module Unit @@ -28,15 +27,29 @@ module Test end end + def test_add + s = TestSuite.new + assert_equal(s, s << self.class.new("test_add")) + end + + def test_delete + s = TestSuite.new + t1 = self.class.new("test_delete") + s << t1 + t2 = self.class.new("test_add") + s << t2 + assert_equal(t1, s.delete(t1)) + assert_nil(s.delete(t1)) + assert_equal(TestSuite.new << t2, s) + end + def test_size - assert_block("The count should be correct") do - suite = TestSuite.new - suite2 = TestSuite.new - suite2 << self.class.new("test_size") - suite << suite2 - suite << self.class.new("test_size") - suite.size == 2 - end + suite = TestSuite.new + suite2 = TestSuite.new + suite2 << self.class.new("test_size") + suite << suite2 + suite << self.class.new("test_size") + assert_equal(2, suite.size, "The count should be correct") end def test_run |