aboutsummaryrefslogtreecommitdiffstats
path: root/test/irb
diff options
context:
space:
mode:
authortomoya ishida <tomoyapenguin@gmail.com>2023-11-24 02:33:08 +0900
committergit <svn-admin@ruby-lang.org>2023-11-23 17:33:13 +0000
commit11d7c75fb33138e9ecadcf222286897826aa0a36 (patch)
treebc31d98132534a2c618e249e76d8d9ad738c83cf /test/irb
parentecdb11288113b5e8b907530512af449f3ffc6c07 (diff)
downloadruby-11d7c75fb33138e9ecadcf222286897826aa0a36.tar.gz
[ruby/irb] Handle handle_exception's exception
(https://github.com/ruby/irb/pull/780) https://github.com/ruby/irb/commit/d42138c477
Diffstat (limited to 'test/irb')
-rw-r--r--test/irb/test_raise_exception.rb (renamed from test/irb/test_raise_no_backtrace_exception.rb)25
1 files changed, 23 insertions, 2 deletions
diff --git a/test/irb/test_raise_no_backtrace_exception.rb b/test/irb/test_raise_exception.rb
index 929577ad8e..9ca534dba1 100644
--- a/test/irb/test_raise_no_backtrace_exception.rb
+++ b/test/irb/test_raise_exception.rb
@@ -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'] : []