ruby-changes:74234
From: st0012 <ko1@a...>
Date: Mon, 24 Oct 2022 22:37:14 +0900 (JST)
Subject: [ruby-changes:74234] d377cc4530 (master): [ruby/irb] Add tests for RelineInputMethod
https://git.ruby-lang.org/ruby.git/commit/?id=d377cc4530 From d377cc4530c1edeb4281a6a5a7ee2a4d13b1b561 Mon Sep 17 00:00:00 2001 From: st0012 <stan001212@g...> Date: Tue, 18 Oct 2022 11:24:04 +0100 Subject: [ruby/irb] Add tests for RelineInputMethod --- test/irb/test_input_method.rb | 58 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 test/irb/test_input_method.rb diff --git a/test/irb/test_input_method.rb b/test/irb/test_input_method.rb new file mode 100644 index 0000000000..5b2d35aeab --- /dev/null +++ b/test/irb/test_input_method.rb @@ -0,0 +1,58 @@ https://github.com/ruby/ruby/blob/trunk/test/irb/test_input_method.rb#L1 +# frozen_string_literal: false + +require "test/unit" +require "irb" + +module TestIRB + class TestRelineInputMethod < Test::Unit::TestCase + def setup + @conf_backup = IRB.conf.dup + IRB.conf[:LC_MESSAGES] = IRB::Locale.new + end + + def teardown + IRB.conf.replace(@conf_backup) + end + + def test_initialization + IRB::RelineInputMethod.new + + assert_nil Reline.completion_append_character + assert_equal '', Reline.completer_quote_characters + assert_equal IRB::InputCompletor::BASIC_WORD_BREAK_CHARACTERS, Reline.basic_word_break_characters + assert_equal IRB::InputCompletor::CompletionProc, Reline.completion_proc + assert_equal IRB::InputCompletor::PerfectMatchedProc, Reline.dig_perfect_match_proc + end + + def test_initialization_without_use_autocomplete + original_show_doc_proc = Reline.dialog_proc(:show_doc)&.dialog_proc + empty_proc = Proc.new {} + Reline.add_dialog_proc(:show_doc, empty_proc) + + IRB.conf[:USE_AUTOCOMPLETE] = false + + IRB::RelineInputMethod.new + + refute Reline.autocompletion + assert_equal empty_proc, Reline.dialog_proc(:show_doc).dialog_proc + ensure + Reline.add_dialog_proc(:show_doc, original_show_doc_proc, Reline::DEFAULT_DIALOG_CONTEXT) + end + + def test_initialization_with_use_autocomplete + original_show_doc_proc = Reline.dialog_proc(:show_doc)&.dialog_proc + empty_proc = Proc.new {} + Reline.add_dialog_proc(:show_doc, empty_proc) + + IRB.conf[:USE_AUTOCOMPLETE] = true + + IRB::RelineInputMethod.new + + assert Reline.autocompletion + assert_equal IRB::RelineInputMethod::SHOW_DOC_DIALOG, Reline.dialog_proc(:show_doc).dialog_proc + ensure + Reline.add_dialog_proc(:show_doc, original_show_doc_proc, Reline::DEFAULT_DIALOG_CONTEXT) + end + end +end + -- cgit v1.2.3 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/