diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-05-12 09:13:45 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-05-12 09:13:45 +0000 |
commit | 707c5ffab5e2ae5105c7d9823411332b160f33df (patch) | |
tree | 07d86a1c94adae8d5b15592862bef54da3d3f253 /test/irb | |
parent | 4969fb6282b2cfdc30c57a5a47aec40ba26c5b00 (diff) | |
download | ruby-707c5ffab5e2ae5105c7d9823411332b160f33df.tar.gz |
irb.rb: update `_`
* lib/irb.rb (IRB::Irb#eval_input): update `_` after exception.
[ruby-core:86989] [Bug #14749]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/irb')
-rw-r--r-- | test/irb/test_context.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/irb/test_context.rb b/test/irb/test_context.rb index 75e47cf1e9..fa2432b3f3 100644 --- a/test/irb/test_context.rb +++ b/test/irb/test_context.rb @@ -22,6 +22,10 @@ module TestIRB def eof? @line_no >= @list.size end + + def encoding + Encoding.default_external + end end def setup @@ -49,5 +53,24 @@ module TestIRB assert_equal('foo', e.message) assert_same(e, @context.evaluate('$!', 1, exception: e)) end + + def test_eval_input + input = TestInputMethod.new([ + "raise 'Foo'\n", + "_\n", + "0\n", + "_\n", + ]) + irb = IRB::Irb.new(IRB::WorkSpace.new(Object.new), input) + out, err = capture_io do + irb.eval_input + end + assert_empty err + assert_pattern_list([:*, /RuntimeError \(.*Foo.*\).*\n/, + :*, /#<RuntimeError: Foo>\n/, + :*, /0$/, + :*, /0$/, + /\s*/], out) + end end end |