summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2020-05-14 12:27:13 +0900
committeraycabta <aycabta@gmail.com>2020-05-14 12:27:33 +0900
commit4a620aff8d1098900c8d0f336b2698ed1256621c (patch)
tree373b34c13a2aec10ff4e146e8aa9af09057b49b3
parent03a492fe45816d21ec8bb080229f0caf07626810 (diff)
Restore class variable setting for tests
-rw-r--r--test/readline/test_readline.rb12
-rw-r--r--test/reline/test_reline.rb32
2 files changed, 44 insertions, 0 deletions
diff --git a/test/readline/test_readline.rb b/test/readline/test_readline.rb
index 52ca69837d..db67986271 100644
--- a/test/readline/test_readline.rb
+++ b/test/readline/test_readline.rb
@@ -635,6 +635,8 @@ module BasetestReadline
def test_completion_quote_character_completing_unquoted_argument
return unless Readline.respond_to?(:completion_quote_character)
+ saved_completer_quote_characters = Readline.completer_quote_characters
+
quote_character = "original value"
Readline.completion_proc = -> (_) do
quote_character = Readline.completion_quote_character
@@ -651,11 +653,15 @@ module BasetestReadline
end
assert_nil(quote_character)
+ ensure
+ Readline.completer_quote_characters = saved_completer_quote_characters if saved_completer_quote_characters
end
def test_completion_quote_character_completing_quoted_argument
return unless Readline.respond_to?(:completion_quote_character)
+ saved_completer_quote_characters = Readline.completer_quote_characters
+
quote_character = "original value"
Readline.completion_proc = -> (_) do
quote_character = Readline.completion_quote_character
@@ -672,6 +678,8 @@ module BasetestReadline
end
assert_equal("'", quote_character)
+ ensure
+ Readline.completer_quote_characters = saved_completer_quote_characters if saved_completer_quote_characters
end
def test_completion_quote_character_after_completion
@@ -682,6 +690,8 @@ module BasetestReadline
end
omit 'Needs GNU Readline 6 or later' if /mswin|mingw/ =~ RUBY_PLATFORM and defined?(TestReadline) and kind_of?(TestReadline) and Readline::VERSION < '6.0'
+ saved_completer_quote_characters = Readline.completer_quote_characters
+
Readline.completion_proc = -> (_) { [] }
Readline.completer_quote_characters = "'\""
@@ -694,6 +704,8 @@ module BasetestReadline
end
assert_nil(Readline.completion_quote_character)
+ ensure
+ Readline.completer_quote_characters = saved_completer_quote_characters if saved_completer_quote_characters
end
private
diff --git a/test/reline/test_reline.rb b/test/reline/test_reline.rb
index 236901fb28..d2de4690d5 100644
--- a/test/reline/test_reline.rb
+++ b/test/reline/test_reline.rb
@@ -20,6 +20,8 @@ class Reline::Test < Reline::TestCase
end
def test_completion_append_character
+ completion_append_character = Reline.completion_append_character
+
assert_equal(nil, Reline.completion_append_character)
Reline.completion_append_character = ""
@@ -39,57 +41,85 @@ class Reline::Test < Reline::TestCase
Reline.completion_append_character = nil
assert_equal(nil, Reline.completion_append_character)
+ ensure
+ Reline.completion_append_character = completion_append_character
end
def test_basic_word_break_characters
+ basic_word_break_characters = Reline.basic_word_break_characters
+
assert_equal(" \t\n`><=;|&{(", Reline.basic_word_break_characters)
Reline.basic_word_break_characters = "[".encode(Encoding::ASCII)
assert_equal("[", Reline.basic_word_break_characters)
assert_equal(get_reline_encoding, Reline.basic_word_break_characters.encoding)
+ ensure
+ Reline.basic_word_break_characters = basic_word_break_characters
end
def test_completer_word_break_characters
+ completer_word_break_characters = Reline.completer_word_break_characters
+
assert_equal(" \t\n`><=;|&{(", Reline.completer_word_break_characters)
Reline.completer_word_break_characters = "[".encode(Encoding::ASCII)
assert_equal("[", Reline.completer_word_break_characters)
assert_equal(get_reline_encoding, Reline.completer_word_break_characters.encoding)
+ ensure
+ Reline.completer_word_break_characters = completer_word_break_characters
end
def test_basic_quote_characters
+ basic_quote_characters = Reline.basic_quote_characters
+
assert_equal('"\'', Reline.basic_quote_characters)
Reline.basic_quote_characters = "`".encode(Encoding::ASCII)
assert_equal("`", Reline.basic_quote_characters)
assert_equal(get_reline_encoding, Reline.basic_quote_characters.encoding)
+ ensure
+ Reline.basic_quote_characters = basic_quote_characters
end
def test_completer_quote_characters
+ completer_quote_characters = Reline.completer_quote_characters
+
assert_equal('"\'', Reline.completer_quote_characters)
Reline.completer_quote_characters = "`".encode(Encoding::ASCII)
assert_equal("`", Reline.completer_quote_characters)
assert_equal(get_reline_encoding, Reline.completer_quote_characters.encoding)
+ ensure
+ Reline.completer_quote_characters = completer_quote_characters
end
def test_filename_quote_characters
+ filename_quote_characters = Reline.filename_quote_characters
+
assert_equal('', Reline.filename_quote_characters)
Reline.filename_quote_characters = "\'".encode(Encoding::ASCII)
assert_equal("\'", Reline.filename_quote_characters)
assert_equal(get_reline_encoding, Reline.filename_quote_characters.encoding)
+ ensure
+ Reline.filename_quote_characters = filename_quote_characters
end
def test_special_prefixes
+ special_prefixes = Reline.special_prefixes
+
assert_equal('', Reline.special_prefixes)
Reline.special_prefixes = "\'".encode(Encoding::ASCII)
assert_equal("\'", Reline.special_prefixes)
assert_equal(get_reline_encoding, Reline.special_prefixes.encoding)
+ ensure
+ Reline.special_prefixes = special_prefixes
end
def test_completion_case_fold
+ completion_case_fold = Reline.completion_case_fold
+
assert_equal(nil, Reline.completion_case_fold)
Reline.completion_case_fold = true
@@ -97,6 +127,8 @@ class Reline::Test < Reline::TestCase
Reline.completion_case_fold = "hoge".encode(Encoding::ASCII)
assert_equal("hoge", Reline.completion_case_fold)
+ ensure
+ Reline.completion_case_fold = completion_case_fold
end
def test_completion_proc