mirror of
https://github.com/ruby/ruby.git
synced 2025-08-26 14:34:39 +02:00
error.c: redefined backtrace
* error.c (rb_get_backtrace): honor redefined Exception#backtrace method. [ruby-core:78097] [Bug #12925] * eval.c (setup_exception): rescue exceptions during backtrace setup. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56767 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d432839cbd
commit
7ab8dcebbf
3 changed files with 66 additions and 16 deletions
|
@ -965,4 +965,38 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status|
|
|||
}
|
||||
end;
|
||||
end
|
||||
|
||||
def test_redefined_backtrace
|
||||
assert_separately([], "#{<<-"begin;"}\n#{<<-"end;"}")
|
||||
begin;
|
||||
$exc = nil
|
||||
|
||||
class Exception
|
||||
undef backtrace
|
||||
def backtrace
|
||||
$exc = self
|
||||
end
|
||||
end
|
||||
|
||||
e = assert_raise(RuntimeError) {
|
||||
raise RuntimeError, "hello"
|
||||
}
|
||||
assert_same(e, $exc)
|
||||
end;
|
||||
end
|
||||
|
||||
def test_wrong_backtrace
|
||||
assert_separately([], "#{<<-"begin;"}\n#{<<-"end;"}")
|
||||
begin;
|
||||
class Exception
|
||||
undef backtrace
|
||||
def backtrace(a)
|
||||
end
|
||||
end
|
||||
|
||||
assert_raise(RuntimeError) {
|
||||
raise RuntimeError, "hello"
|
||||
}
|
||||
end;
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue