aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_exception.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb
index 208c5ecfc0..3735e492d8 100644
--- a/test/ruby/test_exception.rb
+++ b/test/ruby/test_exception.rb
@@ -913,4 +913,31 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status|
end
end
end
+
+ def test_warning_warn
+ verbose = $VERBOSE
+ warning = nil
+
+ ::Warning.class_eval do
+ alias_method :warn2, :warn
+ remove_method :warn
+
+ define_method(:warn) do |str|
+ warning = str
+ end
+ end
+
+ $VERBOSE = true
+ a = @a
+
+ assert_match(/instance variable @a not initialized/, warning)
+ ensure
+ $VERBOSE = verbose
+
+ ::Warning.class_eval do
+ remove_method :warn
+ alias_method :warn, :warn2
+ remove_method :warn2
+ end
+ end
end