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: added a default message for #assert,

#assert_block, and #flunk.

	* test/testunit/test_assertions.rb: ditto.

	* lib/test/unit/failure.rb: failures now show a better trace of where
	  they occurred.

	* test/testunit/test_failure.rb: ditto (added).

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

	* test/testunit/test_testcase.rb: ditto.

	* lib/test/unit/util/backtracefilter.rb: added.

	* test/testunit/util/test_backtracefilter.rb: added.

	* lib/test/unit/error.rb: changed to use BacktraceFilter and improved
	  output.

	* test/testunit/test_error.rb: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4657 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ntalbott 2003-10-02 23:03:13 +00:00
parent 56db4c8fb0
commit 47bd3ed9ce
11 changed files with 219 additions and 67 deletions

View file

@ -9,6 +9,7 @@ require 'test/unit/failure'
require 'test/unit/error'
require 'test/unit/testsuite'
require 'test/unit/assertionfailederror'
require 'test/unit/util/backtracefilter'
module Test
module Unit
@ -20,6 +21,7 @@ module Test
# collecting its results into a Test::Unit::TestResult object.
class TestCase
include Assertions
include Util::BacktraceFilter
attr_reader :method_name
@ -116,18 +118,7 @@ module Test
def add_failure(message, all_locations=caller()) # :nodoc:
@test_passed = false
assertions_pattern = /[^A-Za-z_]assertions\.rb:/
if (all_locations.detect { |entry| entry =~ assertions_pattern })
all_locations.shift
until (all_locations[0] =~ assertions_pattern || all_locations.empty?)
all_locations.shift
end
location = all_locations.detect { |entry| entry !~ assertions_pattern }
else
location = all_locations[0]
end
location = location[/^.+:\d+/]
@_result.add_failure(Failure.new("#{name} [#{location}]", message))
@_result.add_failure(Failure.new(name, filter_backtrace(all_locations), message))
end
private :add_failure