diff options
author | Nobuhiro IMAI <nov@yo.rim.or.jp> | 2021-01-23 02:45:00 +0900 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2021-01-27 15:02:05 +0900 |
commit | e80e5a2f897088bc5284ea61817a910d1d334652 (patch) | |
tree | 99f01f494f2332274cb057956afc6f13761160df /test/irb | |
parent | 5b05b85d85002fd47eeb5e28f9f2898e99507b75 (diff) |
[ruby/irb] use `RubyLex::TerminateLineInput` appropriately [Bug #17564]
* using the appropriciate exception instead of `break` so that the session
can be continue after the `irb_source` and `irb_load` commands
* suppress extra new line due to one more `#prompt` call
https://github.com/ruby/irb/commit/bdefaa7cfd
Diffstat (limited to 'test/irb')
-rw-r--r-- | test/irb/test_cmd.rb | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/test/irb/test_cmd.rb b/test/irb/test_cmd.rb index b2246dfff5..9febcc8671 100644 --- a/test/irb/test_cmd.rb +++ b/test/irb/test_cmd.rb @@ -275,5 +275,59 @@ module TestIRB assert_empty err assert_match(/\A=> 3\nCUSTOM is added\.\n=> nil\ncustom processing time: .+\n=> 3\n=> nil\n=> 3\n/, out) end + + def test_irb_source + IRB.init_config(nil) + File.write("#{@tmpdir}/a.rb", "a = 'hi'\n") + input = TestInputMethod.new([ + "a = 'bug17564'\n", + "a\n", + "irb_source '#{@tmpdir}/a.rb'\n", + "a\n", + ]) + IRB.conf[:PROMPT_MODE] = :SIMPLE + irb = IRB::Irb.new(IRB::WorkSpace.new, input) + IRB.conf[:MAIN_CONTEXT] = irb.context + out, err = capture_output do + irb.eval_input + end + assert_empty err + assert_pattern_list([ + /=> "bug17564"\n/, + /=> "bug17564"\n/, + />> a = 'hi'\n/, + /=> "hi"\n/, + />> \n/, + /=> nil\n/, + /=> "hi"\n/, + ], out) + end + + def test_irb_load + IRB.init_config(nil) + File.write("#{@tmpdir}/a.rb", "a = 'hi'\n") + input = TestInputMethod.new([ + "a = 'bug17564'\n", + "a\n", + "irb_load '#{@tmpdir}/a.rb'\n", + "a\n", + ]) + IRB.conf[:PROMPT_MODE] = :SIMPLE + irb = IRB::Irb.new(IRB::WorkSpace.new, input) + IRB.conf[:MAIN_CONTEXT] = irb.context + out, err = capture_output do + irb.eval_input + end + assert_empty err + assert_pattern_list([ + /=> "bug17564"\n/, + /=> "bug17564"\n/, + />> a = 'hi'\n/, + /=> "hi"\n/, + />> \n/, + /=> nil\n/, + /=> "bug17564"\n/, + ], out) + end end end |