diff options
author | sorah <sorah@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-07-21 05:12:32 +0000 |
---|---|---|
committer | sorah <sorah@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-07-21 05:12:32 +0000 |
commit | 7773a911f5bd0b171ae0bc6c62dbf6ca58360776 (patch) | |
tree | 6b7a7fa806674cb2b0a35ba5be163e7ee8a90e32 /lib/test/unit | |
parent | c4827de949c6c1a940e1d3e48421397d01b0da8a (diff) | |
download | ruby-7773a911f5bd0b171ae0bc6c62dbf6ca58360776.tar.gz |
* lib/test/unit.rb: warn when test_* method is redefined.
Patch by mame (Yusuke Endoh). [Feature #2643] [ruby-core:27790]
* test/testunit/test_redefinition.rb: Test for above.
* test/testunit/test4test_redefinition.rb: Ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36484 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/test/unit')
-rw-r--r-- | lib/test/unit/testcase.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/test/unit/testcase.rb b/lib/test/unit/testcase.rb index 02f0f97987..11f34b6f51 100644 --- a/lib/test/unit/testcase.rb +++ b/lib/test/unit/testcase.rb @@ -20,6 +20,17 @@ module Test def self.test_order :sorted end + + Methods = {} + + def self.method_added(name) + return unless name.to_s[/\Atest_/] + Methods[self] ||= {} + if Methods[self][name] + warn("test/unit warning: method #{ self }##{ name } is redefined") + end + Methods[self][name] = true + end end end end |