From 651b394a12fba26b9c64676978f9b2b3205c0b14 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 26 Feb 2014 04:26:23 +0000 Subject: eval.c: preserve errinfo * eval.c (setup_exception): preserve errinfo across calling #to_s method on the exception. [ruby-core:61091] [Bug #9568] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_exception.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'test/ruby/test_exception.rb') diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb index fc1c209e99..ffcee80ca3 100644 --- a/test/ruby/test_exception.rb +++ b/test/ruby/test_exception.rb @@ -78,6 +78,28 @@ class TestException < Test::Unit::TestCase assert(!bad) end + def test_errinfo_in_debug + bug9568 = EnvUtil.labeled_class("[ruby-core:61091] [Bug #9568]", RuntimeError) do + def to_s + require '\0' + rescue LoadError + self.class.to_s + end + end + + err = EnvUtil.verbose_warning do + assert_raise(bug9568) do + $DEBUG, debug = true, $DEBUG + begin + raise bug9568 + ensure + $DEBUG = debug + end + end + end + assert_include(err, bug9568.to_s) + end + def test_break_ensure bad = true while true -- cgit v1.2.3