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

ruby-changes:62105

From: Hiroshi <ko1@a...>
Date: Thu, 2 Jul 2020 20:53:58 +0900 (JST)
Subject: [ruby-changes:62105] 59ded36c60 (master): Expose `assert_pattern_list` for drb test with test-unit gem.

https://git.ruby-lang.org/ruby.git/commit/?id=59ded36c60

From 59ded36c60b9420d1071679510acc07424b235f3 Mon Sep 17 00:00:00 2001
From: Hiroshi SHIBATA <hsbt@r...>
Date: Thu, 2 Jul 2020 20:48:56 +0900
Subject: Expose `assert_pattern_list` for drb test with test-unit gem.


diff --git a/tool/lib/test/unit/assertions.rb b/tool/lib/test/unit/assertions.rb
index 907e918..88b9536 100644
--- a/tool/lib/test/unit/assertions.rb
+++ b/tool/lib/test/unit/assertions.rb
@@ -372,49 +372,6 @@ EOT https://github.com/ruby/ruby/blob/trunk/tool/lib/test/unit/assertions.rb#L372
         assert(1.0/f == -Float::INFINITY, "#{f} is not -0.0")
       end
 
-      # pattern_list is an array which contains regexp and :*.
-      # :* means any sequence.
-      #
-      # pattern_list is anchored.
-      # Use [:*, regexp, :*] for non-anchored match.
-      def assert_pattern_list(pattern_list, actual, message=nil)
-        rest = actual
-        anchored = true
-        pattern_list.each_with_index {|pattern, i|
-          if pattern == :*
-            anchored = false
-          else
-            if anchored
-              match = /\A#{pattern}/.match(rest)
-            else
-              match = pattern.match(rest)
-            end
-            unless match
-              msg = message(msg) {
-                expect_msg = "Expected #{mu_pp pattern}\n"
-                if /\n[^\n]/ =~ rest
-                  actual_mesg = +"to match\n"
-                  rest.scan(/.*\n+/) {
-                    actual_mesg << '  ' << $&.inspect << "+\n"
-                  }
-                  actual_mesg.sub!(/\+\n\z/, '')
-                else
-                  actual_mesg = "to match " + mu_pp(rest)
-                end
-                actual_mesg << "\nafter #{i} patterns with #{actual.length - rest.length} characters"
-                expect_msg + actual_mesg
-              }
-              assert false, msg
-            end
-            rest = match.post_match
-            anchored = true
-          end
-        }
-        if anchored
-          assert_equal("", rest)
-        end
-      end
-
       def assert_all_assertions_foreach(msg = nil, *keys, &block)
         all = AllFailures.new
         all.foreach(*keys, &block)
diff --git a/tool/lib/test/unit/core_assertions.rb b/tool/lib/test/unit/core_assertions.rb
index 127ff49..adb797b 100644
--- a/tool/lib/test/unit/core_assertions.rb
+++ b/tool/lib/test/unit/core_assertions.rb
@@ -456,6 +456,49 @@ eom https://github.com/ruby/ruby/blob/trunk/tool/lib/test/unit/core_assertions.rb#L456
         ex
       end
 
+      # pattern_list is an array which contains regexp and :*.
+      # :* means any sequence.
+      #
+      # pattern_list is anchored.
+      # Use [:*, regexp, :*] for non-anchored match.
+      def assert_pattern_list(pattern_list, actual, message=nil)
+        rest = actual
+        anchored = true
+        pattern_list.each_with_index {|pattern, i|
+          if pattern == :*
+            anchored = false
+          else
+            if anchored
+              match = /\A#{pattern}/.match(rest)
+            else
+              match = pattern.match(rest)
+            end
+            unless match
+              msg = message(msg) {
+                expect_msg = "Expected #{mu_pp pattern}\n"
+                if /\n[^\n]/ =~ rest
+                  actual_mesg = +"to match\n"
+                  rest.scan(/.*\n+/) {
+                    actual_mesg << '  ' << $&.inspect << "+\n"
+                  }
+                  actual_mesg.sub!(/\+\n\z/, '')
+                else
+                  actual_mesg = "to match " + mu_pp(rest)
+                end
+                actual_mesg << "\nafter #{i} patterns with #{actual.length - rest.length} characters"
+                expect_msg + actual_mesg
+              }
+              assert false, msg
+            end
+            rest = match.post_match
+            anchored = true
+          end
+        }
+        if anchored
+          assert_equal("", rest)
+        end
+      end
+
       def assert_warning(pat, msg = nil)
         result = nil
         stderr = EnvUtil.with_default_internal(pat.encoding) {
-- 
cgit v0.10.2


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

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