diff options
Diffstat (limited to 'test/irb/test_context.rb')
-rw-r--r-- | test/irb/test_context.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/irb/test_context.rb b/test/irb/test_context.rb index 693ebbeaea..d03cc30c78 100644 --- a/test/irb/test_context.rb +++ b/test/irb/test_context.rb @@ -63,6 +63,13 @@ module TestIRB assert_not_match(/rescue _\.class/, e.message) end + def test_evaluate_with_encoding_error_without_lineno + assert_raise_with_message(EncodingError, /invalid symbol/) { + @context.evaluate(%q[{"\xAE": 1}], 1) + # The backtrace of this invalid encoding hash doesn't contain lineno. + } + end + def test_evaluate_with_onigmo_warning assert_warning("(irb):1: warning: character class has duplicated range: /[aa]/\n") do @context.evaluate('/[aa]/', 1) @@ -216,5 +223,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 |