1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
ntalbott 2003-10-02 02:20:42 +00:00
parent 8caf81f1ea
commit 18ef8f1078
7 changed files with 40 additions and 17 deletions

View file

@ -1,3 +1,21 @@
Thu Oct 2 11:17:00 2003 Nathaniel Talbott <ntalbott@ruby-lang.org>
* 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.
Thu Oct 2 03:25:01 2003 NAKAMURA Usaku <usa@ruby-lang.org> Thu Oct 2 03:25:01 2003 NAKAMURA Usaku <usa@ruby-lang.org>
* eval.c (rb_thread_raise): prototype; avoid VC++ warning. * eval.c (rb_thread_raise): prototype; avoid VC++ warning.
@ -1554,7 +1572,7 @@ For the changes before 1.8.0, see doc/ChangeLog-1.8.0
Local variables: Local variables:
add-log-time-format: (lambda () add-log-time-format: (lambda ()
(let* ((time (current-time)) (let* ((time (current-time))
(diff (+ (cadr time) 32400)) (diff (+ (cadr time) 32400))
(lo (% diff 65536)) (lo (% diff 65536))
(hi (+ (car time) (/ diff 65536)))) (hi (+ (car time) (/ diff 65536))))
(format-time-string "%a %b %e %H:%M:%S %Y" (list hi lo) t))) (format-time-string "%a %b %e %H:%M:%S %Y" (list hi lo) t)))

View file

@ -182,15 +182,15 @@ module Test # :nodoc:
end end
begin begin
yield yield
rescue Exception => thrown_exception rescue Exception => e
if (args.empty? || args.include?(thrown_exception.class)) if ((args.empty? && !e.instance_of?(AssertionFailedError)) || args.include?(e.class))
full_message = build_message(message, thrown_exception) do |arg1| full_message = build_message(message, e) do |arg1|
"Exception raised:\n" + "Exception raised:\n" +
arg1 arg1
end end
flunk(full_message) flunk(full_message)
else else
raise thrown_exception.class, thrown_exception.message, thrown_exception.backtrace raise e.class, e.message, e.backtrace
end end
end end
nil nil

View file

@ -18,7 +18,7 @@ module Test
@source.each_object(Class) do |klass| @source.each_object(Class) do |klass|
tests.concat(klass.suite.tests) if(Test::Unit::TestCase > klass) tests.concat(klass.suite.tests) if(Test::Unit::TestCase > klass)
end end
tests.each{|test| suite << test if(include(test))} tests.sort_by{|t| t.name}.each{|test| suite << test if(include(test))}
suite suite
end end

View file

@ -29,7 +29,7 @@ module Test
# Creates a new instance of the fixture for running the # Creates a new instance of the fixture for running the
# test represented by test_method_name. # test represented by test_method_name.
def initialize(test_method_name) def initialize(test_method_name)
if ((!respond_to?(test_method_name)) || (method(test_method_name).arity != 0)) unless(respond_to?(test_method_name) && method(test_method_name).arity == 0)
throw :invalid_test throw :invalid_test
end end
@method_name = test_method_name @method_name = test_method_name
@ -41,9 +41,9 @@ module Test
# each method. # each method.
def self.suite def self.suite
method_names = public_instance_methods(true) method_names = public_instance_methods(true)
tests = method_names.delete_if { |method_name| method_name !~ /^test.+/ } tests = method_names.delete_if {|method_name| method_name !~ /^test./}
suite = TestSuite.new(name) suite = TestSuite.new(name)
tests.each do tests.sort.each do
|test| |test|
catch(:invalid_test) do catch(:invalid_test) do
suite << new(test) suite << new(test)

View file

@ -30,7 +30,7 @@ module Test
# TestSuite. # TestSuite.
def run(result, &progress_block) def run(result, &progress_block)
yield(STARTED, name) yield(STARTED, name)
@tests.sort { |test1, test2| test1.name <=> test2.name }.each do |test| @tests.each do |test|
test.run(result, &progress_block) test.run(result, &progress_block)
end end
yield(FINISHED, name) yield(FINISHED, name)

View file

@ -17,7 +17,7 @@ module Test
end end
@tc2 = Class.new(TestCase) do @tc2 = Class.new(TestCase) do
def test_3 def test_0
end end
end end
@ -34,9 +34,9 @@ module Test
def test_basic_collection def test_basic_collection
expected = TestSuite.new("name") expected = TestSuite.new("name")
expected << @tc2.new('test_0')
expected << @tc1.new('test_1') expected << @tc1.new('test_1')
expected << @tc1.new('test_2') expected << @tc1.new('test_2')
expected << @tc2.new('test_3')
assert_equal(expected, ObjectSpace.new(@object_space).collect("name")) assert_equal(expected, ObjectSpace.new(@object_space).collect("name"))
end end
@ -47,25 +47,25 @@ module Test
assert_equal(expected, collector.collect) assert_equal(expected, collector.collect)
expected = TestSuite.new(ObjectSpace::NAME) expected = TestSuite.new(ObjectSpace::NAME)
expected << @tc2.new('test_0')
expected << @tc1.new('test_1') expected << @tc1.new('test_1')
expected << @tc1.new('test_2') expected << @tc1.new('test_2')
expected << @tc2.new('test_3')
collector = ObjectSpace.new(@object_space) collector = ObjectSpace.new(@object_space)
collector.filter = proc{|test| true} collector.filter = proc{|test| true}
assert_equal(expected, collector.collect) assert_equal(expected, collector.collect)
expected = TestSuite.new(ObjectSpace::NAME) expected = TestSuite.new(ObjectSpace::NAME)
expected << @tc2.new('test_0')
expected << @tc1.new('test_1') expected << @tc1.new('test_1')
expected << @tc2.new('test_3')
collector = ObjectSpace.new(@object_space) collector = ObjectSpace.new(@object_space)
collector.filter = proc{|test| ['test_1', 'test_3'].include?(test.method_name)} collector.filter = proc{|test| ['test_1', 'test_0'].include?(test.method_name)}
assert_equal(expected, collector.collect) assert_equal(expected, collector.collect)
expected = TestSuite.new(ObjectSpace::NAME) expected = TestSuite.new(ObjectSpace::NAME)
expected << @tc2.new('test_0')
expected << @tc1.new('test_1') expected << @tc1.new('test_1')
expected << @tc2.new('test_3')
collector = ObjectSpace.new(@object_space) collector = ObjectSpace.new(@object_space)
collector.filter = [proc{|test| test.method_name == 'test_1'}, proc{|test| test.method_name == 'test_3'}] collector.filter = [proc{|test| test.method_name == 'test_1'}, proc{|test| test.method_name == 'test_0'}]
assert_equal(expected, collector.collect) assert_equal(expected, collector.collect)
end end
end end

View file

@ -283,6 +283,11 @@ module Test
raise "Error" raise "Error"
} }
} }
check_fails("Failure") do
assert_nothing_raised do
flunk("Failure")
end
end
end end
def test_flunk def test_flunk