Skip to content

Commit

Permalink
Merge pull request #303 from aycabta/set-default-return_format
Browse files Browse the repository at this point in the history
Set default @return_format
  • Loading branch information
aycabta authored Oct 11, 2021
2 parents 65399d5 + 7ee15bc commit 3cb2d0e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/irb/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ def prompt_mode=(mode)
@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
Expand Down
22 changes: 22 additions & 0 deletions test/irb/test_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,28 @@ def main.inspect
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
Expand Down

0 comments on commit 3cb2d0e

Please sign in to comment.