tomoya ishida 2023-11-24 02:33:08 +09:00 коммит произвёл git
Родитель ecdb112881
Коммит 11d7c75fb3
2 изменённых файлов: 31 добавлений и 3 удалений

Просмотреть файл

@ -743,7 +743,14 @@ module IRB
message = message.gsub(/\(irb\):(?<num>\d+):in `<(?<frame>top \(required\))>'/) { "(irb):#{$~[:num]}:in `<main>'" }
puts message
end
print "Maybe IRB bug!\n" if irb_bug
puts 'Maybe IRB bug!' if irb_bug
rescue Exception => handler_exc
begin
puts exc.inspect
puts "backtraces are hidden because #{handler_exc} was raised when processing them"
rescue Exception
puts 'Uninspectable exception occurred'
end
end
# Evaluates the given block using the given +path+ as the Context#irb_path

Просмотреть файл

@ -4,8 +4,8 @@ require "tmpdir"
require_relative "helper"
module TestIRB
class RaiseNoBacktraceExceptionTest < TestCase
def test_raise_exception
class RaiseExceptionTest < TestCase
def test_raise_exception_with_nil_backtrace
bundle_exec = ENV.key?('BUNDLE_GEMFILE') ? ['-rbundler/setup'] : []
assert_in_out_err(bundle_exec + %w[-rirb -W0 -e IRB.start(__FILE__) -- -f --], <<-IRB, /Exception: foo/, [])
e = Exception.new("foo")
@ -15,6 +15,27 @@ module TestIRB
IRB
end
def test_raise_exception_with_message_exception
bundle_exec = ENV.key?('BUNDLE_GEMFILE') ? ['-rbundler/setup'] : []
expected = /#<Exception: foo>\nbacktraces are hidden because bar was raised when processing them/
assert_in_out_err(bundle_exec + %w[-rirb -W0 -e IRB.start(__FILE__) -- -f --], <<-IRB, expected, [])
e = Exception.new("foo")
def e.message; raise 'bar'; end
raise e
IRB
end
def test_raise_exception_with_message_inspect_exception
bundle_exec = ENV.key?('BUNDLE_GEMFILE') ? ['-rbundler/setup'] : []
expected = /Uninspectable exception occurred/
assert_in_out_err(bundle_exec + %w[-rirb -W0 -e IRB.start(__FILE__) -- -f --], <<-IRB, expected, [])
e = Exception.new("foo")
def e.message; raise; end
def e.inspect; raise; end
raise e
IRB
end
def test_raise_exception_with_invalid_byte_sequence
pend if RUBY_ENGINE == 'truffleruby' || /mswin|mingw/ =~ RUBY_PLATFORM
bundle_exec = ENV.key?('BUNDLE_GEMFILE') ? ['-rbundler/setup'] : []