1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
nobu 2009-09-29 03:53:44 +00:00
parent b3854e7162
commit 00be97da7e

View file

@ -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