From 340fabca2c8abe29efe5c5a5c0f3ddc9b2ba8035 Mon Sep 17 00:00:00 2001 From: aycabta Date: Mon, 11 Oct 2021 15:31:58 +0900 Subject: [ruby/irb] Set default return_format https://github.com/ruby/irb/commit/7ee15bc668 --- lib/irb/context.rb | 1 + test/irb/test_context.rb | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/lib/irb/context.rb b/lib/irb/context.rb index 698378cc62..9c18b5d6e3 100644 --- a/lib/irb/context.rb +++ b/lib/irb/context.rb @@ -386,6 +386,7 @@ module IRB @prompt_c = pconf[:PROMPT_C] @prompt_n = pconf[:PROMPT_N] @return_format = pconf[:RETURN] + @return_format = "%s\n" if @return_format == nil if ai = pconf.include?(:AUTO_INDENT) @auto_indent_mode = ai else diff --git a/test/irb/test_context.rb b/test/irb/test_context.rb index ba3b94ce49..d908195e6a 100644 --- a/test/irb/test_context.rb +++ b/test/irb/test_context.rb @@ -448,6 +448,28 @@ module TestIRB out) end + def test_default_return_format + IRB.conf[:PROMPT][:MY_PROMPT] = { + :PROMPT_I => "%03n> ", + :PROMPT_N => "%03n> ", + :PROMPT_S => "%03n> ", + :PROMPT_C => "%03n> " + # without :RETURN + # :RETURN => "%s\n" + } + IRB.conf[:PROMPT_MODE] = :MY_PROMPT + input = TestInputMethod.new([ + "3" + ]) + irb = IRB::Irb.new(IRB::WorkSpace.new(Object.new), input) + out, err = capture_output do + irb.eval_input + end + assert_empty err + assert_equal("3\n", + out) + end + def test_eval_input_with_exception pend if RUBY_ENGINE == 'truffleruby' verbose, $VERBOSE = $VERBOSE, nil -- cgit v1.2.3