summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/ruby/test_class.rb4
-rw-r--r--test/ruby/test_module.rb30
2 files changed, 32 insertions, 2 deletions
diff --git a/test/ruby/test_class.rb b/test/ruby/test_class.rb
index 7e072c27b7..055ddca629 100644
--- a/test/ruby/test_class.rb
+++ b/test/ruby/test_class.rb
@@ -106,13 +106,14 @@ class TestClass < Test::Unit::TestCase
end
def test_method_redefinition
+ line = __LINE__+4
stderr = EnvUtil.verbose_warning do
Class.new do
def foo; end
def foo; end
end
end
- assert_match(/method redefined; discarding old foo/, stderr)
+ assert_match(/:#{line}: warning: method redefined; discarding old foo/, stderr)
stderr = EnvUtil.verbose_warning do
Class.new do
@@ -132,6 +133,7 @@ class TestClass < Test::Unit::TestCase
end
assert_equal("", stderr)
+ line = __LINE__+4
stderr = EnvUtil.verbose_warning do
Class.new do
define_method(:foo) do end
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb
index 8829a3dcf1..bfb347c468 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -788,19 +788,47 @@ class TestModule < Test::Unit::TestCase
end
def test_method_redefinition
+ line = __LINE__+4
stderr = EnvUtil.verbose_warning do
Module.new do
def foo; end
def foo; end
end
end
- assert_match(/method redefined; discarding old foo/, stderr)
+ assert_match(/:#{line}: warning: method redefined; discarding old foo/, stderr)
stderr = EnvUtil.verbose_warning do
Module.new do
def foo; end
alias bar foo
+ def foo; end
+ end
+ end
+ assert_equal("", stderr)
+
+ stderr = EnvUtil.verbose_warning do
+ Module.new do
+ def foo; end
+ alias bar foo
+ alias bar foo
+ end
+ end
+ assert_equal("", stderr)
+
+ line = __LINE__+4
+ stderr = EnvUtil.verbose_warning do
+ Module.new do
+ define_method(:foo) do end
+ def foo; end
+ end
+ end
+ assert_match(/:#{line}: warning: method redefined; discarding old foo/, stderr)
+
+ stderr = EnvUtil.verbose_warning do
+ Module.new do
+ define_method(:foo) do end
alias bar foo
+ alias barf oo
end
end
assert_equal("", stderr)