Skip to content

Commit fcf6b34

Browse files
committed
handle repeated exception separately
1 parent a859215 commit fcf6b34

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

lib/irb.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,8 @@ def eval_input
574574
next
575575
end
576576
handle_exception(exc)
577+
@context.workspace.local_variable_set(:_, exc)
578+
exc = nil
577579
end
578580
end
579581
end

test/irb/test_context.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,24 @@ def test_eval_input
105105
$VERBOSE = verbose
106106
end
107107

108+
def test_eval_input_raise2x
109+
input = TestInputMethod.new([
110+
"raise 'Foo'\n",
111+
"raise 'Bar'\n",
112+
"_\n",
113+
])
114+
irb = IRB::Irb.new(IRB::WorkSpace.new(Object.new), input)
115+
out, err = capture_output do
116+
irb.eval_input
117+
end
118+
assert_empty err
119+
assert_pattern_list([
120+
:*, /\(irb\):1:in `<main>': Foo \(RuntimeError\)\n/,
121+
:*, /\(irb\):2:in `<main>': Bar \(RuntimeError\)\n/,
122+
:*, /#<RuntimeError: Bar>\n/,
123+
], out)
124+
end
125+
108126
def test_eval_object_without_inspect_method
109127
verbose, $VERBOSE = $VERBOSE, nil
110128
all_assertions do |all|

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy