From e208464986d5b5fc2320be47fad9911c05954c87 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 29 Sep 2009 03:53:44 +0000 Subject: * test/ruby/test_class.rb (test_module_function): tests for warnings. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@25145 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_class.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'test') diff --git a/test/ruby/test_class.rb b/test/ruby/test_class.rb index bc0f79a68..8d618822a 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 -- cgit