Skip to content

Commit

Permalink
Merge pull request #172 from no6v/repeated-excption
Browse files Browse the repository at this point in the history
handle repeated exception separately
  • Loading branch information
aycabta authored Jan 16, 2021
2 parents 1e03eba + 5e00a0a commit 6fef020
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/irb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,8 @@ def eval_input
next
end
handle_exception(exc)
@context.workspace.local_variable_set(:_, exc)
exc = nil
end
end
end
Expand Down
19 changes: 19 additions & 0 deletions test/irb/test_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,25 @@ def test_eval_input
$VERBOSE = verbose
end

def test_eval_input_raise2x
skip if RUBY_ENGINE == 'truffleruby'
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 `<main>': Foo \(RuntimeError\)\n/,
:*, /\(irb\):2:in `<main>': Bar \(RuntimeError\)\n/,
:*, /#<RuntimeError: Bar>\n/,
], out)
end

def test_eval_object_without_inspect_method
verbose, $VERBOSE = $VERBOSE, nil
all_assertions do |all|
Expand Down

0 comments on commit 6fef020

Please sign in to comment.