diff options
author | ntalbott <ntalbott@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-10-02 02:20:42 +0000 |
---|---|---|
committer | ntalbott <ntalbott@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-10-02 02:20:42 +0000 |
commit | dab02799d72bdcce27dfb07869755b3b6519c3ed (patch) | |
tree | c7f409e15a07e445cdb5ee22335735eb1e75c229 /lib | |
parent | d8b6d8b933720565cf111d5a72319489ed2effd6 (diff) | |
download | ruby-dab02799d72bdcce27dfb07869755b3b6519c3ed.tar.gz ruby-dab02799d72bdcce27dfb07869755b3b6519c3ed.tar.xz ruby-dab02799d72bdcce27dfb07869755b3b6519c3ed.zip |
* 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: http://svn.ruby-lang.org/repos/ruby/trunk@4648 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/test/unit/assertions.rb | 8 | ||||
-rw-r--r-- | lib/test/unit/collector/objectspace.rb | 2 | ||||
-rw-r--r-- | lib/test/unit/testcase.rb | 6 | ||||
-rw-r--r-- | lib/test/unit/testsuite.rb | 2 |
4 files changed, 9 insertions, 9 deletions
diff --git a/lib/test/unit/assertions.rb b/lib/test/unit/assertions.rb index b0df0ea2d..2833eba10 100644 --- a/lib/test/unit/assertions.rb +++ b/lib/test/unit/assertions.rb @@ -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 diff --git a/lib/test/unit/collector/objectspace.rb b/lib/test/unit/collector/objectspace.rb index 32b633268..162f1ec4f 100644 --- a/lib/test/unit/collector/objectspace.rb +++ b/lib/test/unit/collector/objectspace.rb @@ -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 diff --git a/lib/test/unit/testcase.rb b/lib/test/unit/testcase.rb index 369c94434..c831b764a 100644 --- a/lib/test/unit/testcase.rb +++ b/lib/test/unit/testcase.rb @@ -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) diff --git a/lib/test/unit/testsuite.rb b/lib/test/unit/testsuite.rb index 589ad7151..4ece3257c 100644 --- a/lib/test/unit/testsuite.rb +++ b/lib/test/unit/testsuite.rb @@ -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) |