From 00be97da7e260f3d801fe64c01c13dd820f6b1a8 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@25145 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_class.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'test/ruby/test_class.rb') 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 -- cgit v1.2.3