diff options
author | ntalbott <ntalbott@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-08-06 14:03:21 +0000 |
---|---|---|
committer | ntalbott <ntalbott@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-08-06 14:03:21 +0000 |
commit | 3158b75b0bf9c259ca6668cc4383de3836ad8f07 (patch) | |
tree | 0b388ae81f068b8678630d42504c035e61e55f05 /lib/test | |
parent | a7fd686ba4cd9ca635de087903744157b660c42a (diff) | |
download | ruby-3158b75b0bf9c259ca6668cc4383de3836ad8f07.tar.gz |
* lib/test/unit/testcase.rb: Added equality checking.
* lib/test/unit/testsuite.rb: Added equality checking.
* lib/test/unit/assertions.rb: Fixed a warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4341 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/test')
-rw-r--r-- | lib/test/unit/assertions.rb | 8 | ||||
-rw-r--r-- | lib/test/unit/testcase.rb | 9 | ||||
-rw-r--r-- | lib/test/unit/testsuite.rb | 9 |
3 files changed, 23 insertions, 3 deletions
diff --git a/lib/test/unit/assertions.rb b/lib/test/unit/assertions.rb index 0af3468b9b..b0df0ea2db 100644 --- a/lib/test/unit/assertions.rb +++ b/lib/test/unit/assertions.rb @@ -1,7 +1,7 @@ # :nodoc: # # Author:: Nathaniel Talbott. -# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved. +# Copyright:: Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved. # License:: Ruby license. require 'test/unit/assertionfailederror' @@ -138,6 +138,12 @@ module Test # :nodoc: "<#{arg1}> expected to be =~\n" + "<#{arg2}>" end + pattern = case(pattern) + when String + Regexp.new(pattern) + else + pattern + end assert_block(full_message) { string =~ pattern } end end diff --git a/lib/test/unit/testcase.rb b/lib/test/unit/testcase.rb index 2ccf192906..369c944349 100644 --- a/lib/test/unit/testcase.rb +++ b/lib/test/unit/testcase.rb @@ -1,7 +1,7 @@ # :nodoc: # # Author:: Nathaniel Talbott. -# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved. +# Copyright:: Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved. # License:: Ruby license. require 'test/unit/assertions' @@ -147,6 +147,13 @@ module Test def to_s name end + + # It's handy to be able to compare TestCase instances. + def ==(other) + return false unless(other.kind_of?(self.class)) + return false unless(@method_name == other.method_name) + self.class == other.class + end end end end diff --git a/lib/test/unit/testsuite.rb b/lib/test/unit/testsuite.rb index e3a164cb6e..589ad7151e 100644 --- a/lib/test/unit/testsuite.rb +++ b/lib/test/unit/testsuite.rb @@ -1,7 +1,7 @@ # :nodoc: # # Author:: Nathaniel Talbott. -# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved. +# Copyright:: Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved. # License:: Ruby license. module Test @@ -59,6 +59,13 @@ module Test def to_s @name end + + # It's handy to be able to compare TestSuite instances. + def ==(other) + return false unless(other.kind_of?(self.class)) + return false unless(@name == other.name) + @tests == other.tests + end end end end |