diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-09-29 03:53:44 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-09-29 03:53:44 +0000 |
commit | 00be97da7e260f3d801fe64c01c13dd820f6b1a8 (patch) | |
tree | e4f3f97498375dbd9d1b4c32eee05feafc566213 /test/ruby/test_class.rb | |
parent | b3854e7162a67aa9493d3ba7f6f552fda91f5b77 (diff) | |
download | ruby-00be97da7e260f3d801fe64c01c13dd820f6b1a8.tar.gz |
* test/ruby/test_class.rb (test_module_function): tests for warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25145 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_class.rb')
-rw-r--r-- | test/ruby/test_class.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/ruby/test_class.rb b/test/ruby/test_class.rb index bc0f79a681..8d618822a5 100644 --- a/test/ruby/test_class.rb +++ b/test/ruby/test_class.rb @@ -98,11 +98,38 @@ class TestClass < Test::Unit::TestCase assert_equal(nil, BasicObject.superclass) end + def verbose_warning + class << (stderr = "") + alias write << + end + stderr, $stderr, verbose, $VERBOSE = $stderr, stderr, $VERBOSE, true + yield + ensure + stderr, $stderr, $VERBOSE = $stderr, stderr, verbose + return stderr + end + def test_module_function c = Class.new assert_raise(TypeError) do Module.instance_method(:module_function).bind(c).call(:foo) end + + stderr = verbose_warning do + Module.new do + def foo; end + def foo; end + end + end + assert_match(/method redefined; discarding old foo/, stderr) + stderr = verbose_warning do + Module.new do + def foo; end + alias bar foo + alias bar foo + end + end + assert_equal("", stderr) end def test_check_inheritable |