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

ruby-changes:56765

From: Hiroshi <ko1@a...>
Date: Fri, 2 Aug 2019 21:10:11 +0900 (JST)
Subject: [ruby-changes:56765] Hiroshi SHIBATA: eb638b75b3 (master): It can be share to use CoreAssertions for default gems.

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

From eb638b75b33c7be30021d1de57f44498c6b5f6d6 Mon Sep 17 00:00:00 2001
From: Hiroshi SHIBATA <hsbt@r...>
Date: Tue, 23 Jul 2019 16:09:46 +0900
Subject: It can be share to use CoreAssertions for default gems.

  ref. https://github.com/ruby/logger/pull/35

diff --git a/tool/lib/test/unit/core_assertions.rb b/tool/lib/test/unit/core_assertions.rb
index 21be860..5533c54 100644
--- a/tool/lib/test/unit/core_assertions.rb
+++ b/tool/lib/test/unit/core_assertions.rb
@@ -1,11 +1,36 @@ https://github.com/ruby/ruby/blob/trunk/tool/lib/test/unit/core_assertions.rb#L1
 # frozen_string_literal: true
 
-require_relative '../../envutil'
-
 module Test
   module Unit
     module CoreAssertions
-      include MiniTest::Assertions
+      if defined?(MiniTest)
+        require_relative '../../envutil'
+        # for ruby core testing
+        include MiniTest::Assertions
+      else
+        require 'pp'
+        require_relative 'envutil'
+        include Test::Unit::Assertions
+
+        def _assertions= n # :nodoc:
+          @_assertions = n
+        end
+
+        def _assertions # :nodoc:
+          @_assertions ||= 0
+        end
+
+        ##
+        # Returns a proc that will output +msg+ along with the default message.
+
+        def message msg = nil, ending = nil, &default
+          proc {
+            msg = msg.call.chomp(".") if Proc === msg
+            custom_message = "#{msg}.\n" unless msg.nil? or msg.to_s.empty?
+            "#{custom_message}#{default.call}#{ending || "."}"
+          }
+        end
+      end
 
       def mu_pp(obj) #:nodoc:
         obj.pretty_inspect.chomp
@@ -99,7 +124,7 @@ module Test https://github.com/ruby/ruby/blob/trunk/tool/lib/test/unit/core_assertions.rb#L124
         end
         src = <<eom
 # -*- coding: #{line += __LINE__; src.encoding}; -*-
-  require #{__dir__.dump};include Test::Unit::Assertions
+  require "test/unit";include Test::Unit::Assertions;require #{(__dir__ + "/core_assertions").dump};include Test::Unit::CoreAssertions
   END {
     puts [Marshal.dump($!)].pack('m'), "assertions=\#{self._assertions}"
   }
-- 
cgit v0.10.2


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

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