ruby-changes:64926
From: Nobuhiro <ko1@a...>
Date: Mon, 18 Jan 2021 02:18:39 +0900 (JST)
Subject: [ruby-changes:64926] d290a02bd7 (master): [ruby/irb] handle repeated exception separately
https://git.ruby-lang.org/ruby.git/commit/?id=d290a02bd7 From d290a02bd7035eb186eb5c275af4e1ddc20ad47f Mon Sep 17 00:00:00 2001 From: Nobuhiro IMAI <nov@y...> Date: Fri, 15 Jan 2021 22:00:38 +0900 Subject: [ruby/irb] handle repeated exception separately https://github.com/ruby/irb/commit/fcf6b34bc5 diff --git a/lib/irb.rb b/lib/irb.rb index cf53130..3f7f169 100644 --- a/lib/irb.rb +++ b/lib/irb.rb @@ -574,6 +574,8 @@ module IRB https://github.com/ruby/ruby/blob/trunk/lib/irb.rb#L574 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 4949502..a32b1fc 100644 --- a/test/irb/test_context.rb +++ b/test/irb/test_context.rb @@ -105,6 +105,24 @@ module TestIRB https://github.com/ruby/ruby/blob/trunk/test/irb/test_context.rb#L105 $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 `<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| -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/