From fcf6b34bc57712c841f0ed8f95e687e777817c6d Mon Sep 17 00:00:00 2001 From: Nobuhiro IMAI Date: Fri, 15 Jan 2021 22:00:38 +0900 Subject: [PATCH 1/2] handle repeated exception separately --- lib/irb.rb | 2 ++ test/irb/test_context.rb | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/lib/irb.rb b/lib/irb.rb index cf5313075..3f7f169c6 100644 --- a/lib/irb.rb +++ b/lib/irb.rb @@ -574,6 +574,8 @@ def eval_input next end handle_exception(exc) + @context.workspace.local_variable_set(:_, exc) + exc = nil end end end diff --git a/test/irb/test_context.rb b/test/irb/test_context.rb index 49495027c..a32b1fc97 100644 --- a/test/irb/test_context.rb +++ b/test/irb/test_context.rb @@ -105,6 +105,24 @@ def test_eval_input $VERBOSE = verbose end + def test_eval_input_raise2x + input = TestInputMethod.new([ + "raise 'Foo'\n", + "raise 'Bar'\n", + "_\n", + ]) + irb = IRB::Irb.new(IRB::WorkSpace.new(Object.new), input) + out, err = capture_output do + irb.eval_input + end + assert_empty err + assert_pattern_list([ + :*, /\(irb\):1:in `
': Foo \(RuntimeError\)\n/, + :*, /\(irb\):2:in `
': Bar \(RuntimeError\)\n/, + :*, /#\n/, + ], out) + end + def test_eval_object_without_inspect_method verbose, $VERBOSE = $VERBOSE, nil all_assertions do |all| From 5e00a0ae613c5c723363d6ea94423a58a5e4a9a9 Mon Sep 17 00:00:00 2001 From: Nobuhiro IMAI Date: Sat, 16 Jan 2021 07:44:25 +0900 Subject: [PATCH 2/2] skip a failling test on TruffleRuby * due to the difference of backtrace pointed out by @aycabta --- test/irb/test_context.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/test/irb/test_context.rb b/test/irb/test_context.rb index a32b1fc97..f3d0626ca 100644 --- a/test/irb/test_context.rb +++ b/test/irb/test_context.rb @@ -106,6 +106,7 @@ def test_eval_input end def test_eval_input_raise2x + skip if RUBY_ENGINE == 'truffleruby' input = TestInputMethod.new([ "raise 'Foo'\n", "raise 'Bar'\n",