[前][次][番号順一覧][スレッド一覧]

ruby-changes:61253

From: aycabta <ko1@a...>
Date: Thu, 14 May 2020 13:35:31 +0900 (JST)
Subject: [ruby-changes:61253] 4a620aff8d (master): Restore class variable setting for tests

https://git.ruby-lang.org/ruby.git/commit/?id=4a620aff8d

From 4a620aff8d1098900c8d0f336b2698ed1256621c Mon Sep 17 00:00:00 2001
From: aycabta <aycabta@g...>
Date: Thu, 14 May 2020 12:27:13 +0900
Subject: Restore class variable setting for tests


diff --git a/test/readline/test_readline.rb b/test/readline/test_readline.rb
index 52ca698..db67986 100644
--- a/test/readline/test_readline.rb
+++ b/test/readline/test_readline.rb
@@ -635,6 +635,8 @@ module BasetestReadline https://github.com/ruby/ruby/blob/trunk/test/readline/test_readline.rb#L635
   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 https://github.com/ruby/ruby/blob/trunk/test/readline/test_readline.rb#L653
     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 https://github.com/ruby/ruby/blob/trunk/test/readline/test_readline.rb#L678
     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 https://github.com/ruby/ruby/blob/trunk/test/readline/test_readline.rb#L690
     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 https://github.com/ruby/ruby/blob/trunk/test/readline/test_readline.rb#L704
     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 236901f..d2de469 100644
--- a/test/reline/test_reline.rb
+++ b/test/reline/test_reline.rb
@@ -20,6 +20,8 @@ class Reline::Test < Reline::TestCase https://github.com/ruby/ruby/blob/trunk/test/reline/test_reline.rb#L20
   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 https://github.com/ruby/ruby/blob/trunk/test/reline/test_reline.rb#L41
 
     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 https://github.com/ruby/ruby/blob/trunk/test/reline/test_reline.rb#L127
 
     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
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]