diff options
author | Kenta Murata <mrkn@mrkn.jp> | 2020-01-16 13:13:35 +0900 |
---|---|---|
committer | aycabta <aycabta@gmail.com> | 2020-01-21 09:51:16 +0900 |
commit | 51a8055d7db8a6ae35a9f624700c0910ec20aeb8 (patch) | |
tree | 0d718d09fa2668497e8735666b5c67f188472c28 /test/irb/test_context.rb | |
parent | f451bb5406878e1ac9ce9d37952f171837d0cb09 (diff) | |
download | ruby-51a8055d7db8a6ae35a9f624700c0910ec20aeb8.tar.gz |
[ruby/irb] Add newline_before_multiline_output
https://github.com/ruby/irb/commit/9eb1801a66
Diffstat (limited to 'test/irb/test_context.rb')
-rw-r--r-- | test/irb/test_context.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/irb/test_context.rb b/test/irb/test_context.rb index 693ebbeaea..8a6521bf69 100644 --- a/test/irb/test_context.rb +++ b/test/irb/test_context.rb @@ -216,5 +216,36 @@ module TestIRB assert(irb.context.echo?, "echo? should be true by default") assert(irb.context.echo_on_assignment?, "echo_on_assignment? should be true when IRB.conf[:ECHO_ON_ASSIGNMENT] is set to true") end + + def test_multiline_output_on_default_inspector + main = Object.new + def main.inspect + "abc\ndef" + end + input = TestInputMethod.new([ + "self" + ]) + irb = IRB::Irb.new(IRB::WorkSpace.new(main), input) + irb.context.return_format = "=> %s\n" + + # The default + irb.context.newline_before_multiline_output = true + out, err = capture_io do + irb.eval_input + end + assert_empty err + assert_equal("=> \nabc\ndef\n", + out) + + # No newline before multiline output + input.reset + irb.context.newline_before_multiline_output = false + out, err = capture_io do + irb.eval_input + end + assert_empty err + assert_equal("=> abc\ndef\n", + out) + end end end |