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>
* 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:
add-log-time-format: (lambda ()
(let* ((time (current-time))
(diff (+ (cadr time) 32400))
(diff (+ (cadr time) 32400))
(lo (% diff 65536))
(hi (+ (car time) (/ diff 65536))))
(format-time-string "%a %b %e %H:%M:%S %Y" (list hi lo) t)))

View file

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

View file

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

View file

@ -29,7 +29,7 @@ module Test
# Creates a new instance of the fixture for running the
# test represented by 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
end
@method_name = test_method_name
@ -41,9 +41,9 @@ module Test
# each method.
def self.suite
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)
tests.each do
tests.sort.each do
|test|
catch(:invalid_test) do
suite << new(test)

View file

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

View file

@ -17,7 +17,7 @@ module Test
end
@tc2 = Class.new(TestCase) do
def test_3
def test_0
end
end
@ -34,9 +34,9 @@ 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 << @tc2.new('test_3')
assert_equal(expected, ObjectSpace.new(@object_space).collect("name"))
end
@ -47,25 +47,25 @@ 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 << @tc2.new('test_3')
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 << @tc2.new('test_3')
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)
expected = TestSuite.new(ObjectSpace::NAME)
expected << @tc2.new('test_0')
expected << @tc1.new('test_1')
expected << @tc2.new('test_3')
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)
end
end

View file

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