Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/irb/init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ def IRB.parse_opts(argv: ::ARGV)
@CONF[:COMPLETOR] = :type
when /^--prompt-mode(?:=(.+))?/, /^--prompt(?:=(.+))?/
opt = $1 || argv.shift
fail UndefinedPromptMode, opt unless opt
prompt_mode = opt.upcase.tr("-", "_").intern
@CONF[:PROMPT_MODE] = prompt_mode
when "--nobanner"
Expand Down
17 changes: 17 additions & 0 deletions test/irb/test_init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,23 @@ def test_nobanner
assert_equal(false, IRB.conf[:SHOW_BANNER])
end

def test_prompt_option
orig_prompt_mode = IRB.conf[:PROMPT_MODE]
IRB.setup(eval("__FILE__"), argv: %w[--prompt simple])
assert_equal(:SIMPLE, IRB.conf[:PROMPT_MODE])

IRB.setup(eval("__FILE__"), argv: %w[--prompt-mode=inf-ruby])
assert_equal(:INF_RUBY, IRB.conf[:PROMPT_MODE])

%w[--prompt --prompt-mode].each do |opt|
assert_raise(IRB::UndefinedPromptMode) do
IRB.setup(eval("__FILE__"), argv: [opt])
end
end
ensure
IRB.conf[:PROMPT_MODE] = orig_prompt_mode
end

def test_measure_when_exception_occurs
out, err = execute_lines(
"measure\n",
Expand Down
Loading