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

ruby-changes:56787

From: Hiroshi <ko1@a...>
Date: Sat, 3 Aug 2019 22:18:59 +0900 (JST)
Subject: [ruby-changes:56787] Hiroshi SHIBATA: d569d721f9 (master): Move assert_ruby_status and assert_throw to CoreAssertions for default gems.

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

From d569d721f978d2e0b5b331b3c3aa69c89f94d70b Mon Sep 17 00:00:00 2001
From: Hiroshi SHIBATA <hsbt@r...>
Date: Sat, 3 Aug 2019 22:17:45 +0900
Subject: Move assert_ruby_status and assert_throw to CoreAssertions for
 default gems.


diff --git a/tool/lib/test/unit/assertions.rb b/tool/lib/test/unit/assertions.rb
index 0c68a93..33f31fe 100644
--- a/tool/lib/test/unit/assertions.rb
+++ b/tool/lib/test/unit/assertions.rb
@@ -217,35 +217,6 @@ module Test https://github.com/ruby/ruby/blob/trunk/tool/lib/test/unit/assertions.rb#L217
       end
 
       # :call-seq:
-      #   assert_throw( tag, failure_message = nil, &block )
-      #
-      #Fails unless the given block throws +tag+, returns the caught
-      #value otherwise.
-      #
-      #An optional failure message may be provided as the final argument.
-      #
-      #    tag = Object.new
-      #    assert_throw(tag, "#{tag} was not thrown!") do
-      #      throw tag
-      #    end
-      def assert_throw(tag, msg = nil)
-        ret = catch(tag) do
-          begin
-            yield(tag)
-          rescue UncaughtThrowError => e
-            thrown = e.tag
-          end
-          msg = message(msg) {
-            "Expected #{mu_pp(tag)} to have been thrown"\
-            "#{%Q[, not #{thrown}] if thrown}"
-          }
-          assert(false, msg)
-        end
-        assert(true)
-        ret
-      end
-
-      # :call-seq:
       #   assert_equal( expected, actual, failure_message = nil )
       #
       #Tests if +expected+ is equal to +actual+.
@@ -551,14 +522,6 @@ EOT https://github.com/ruby/ruby/blob/trunk/tool/lib/test/unit/assertions.rb#L522
         assert !status.signaled?, FailDesc[status, message, out]
       end
 
-      def assert_ruby_status(args, test_stdin="", message=nil, **opt)
-        out, _, status = EnvUtil.invoke_ruby(args, test_stdin, true, :merge_to_stdout, **opt)
-        desc = FailDesc[status, message, out]
-        assert(!status.signaled?, desc)
-        message ||= "ruby exit status is not success:"
-        assert(status.success?, desc)
-      end
-
       def assert_warning(pat, msg = nil)
         result = nil
         stderr = EnvUtil.with_default_internal(pat.encoding) {
diff --git a/tool/lib/test/unit/core_assertions.rb b/tool/lib/test/unit/core_assertions.rb
index 5533c54..b637748 100644
--- a/tool/lib/test/unit/core_assertions.rb
+++ b/tool/lib/test/unit/core_assertions.rb
@@ -114,6 +114,14 @@ module Test https://github.com/ruby/ruby/blob/trunk/tool/lib/test/unit/core_assertions.rb#L114
         end
       end
 
+      def assert_ruby_status(args, test_stdin="", message=nil, **opt)
+        out, _, status = EnvUtil.invoke_ruby(args, test_stdin, true, :merge_to_stdout, **opt)
+        desc = FailDesc[status, message, out]
+        assert(!status.signaled?, desc)
+        message ||= "ruby exit status is not success:"
+        assert(status.success?, desc)
+      end
+
       ABORT_SIGNALS = Signal.list.values_at(*%w"ILL ABRT BUS SEGV TERM")
 
       def assert_separately(args, file = nil, line = nil, src, ignore_stderr: nil, **opt)
@@ -165,6 +173,35 @@ eom https://github.com/ruby/ruby/blob/trunk/tool/lib/test/unit/core_assertions.rb#L173
         raise marshal_error if marshal_error
       end
 
+      # :call-seq:
+      #   assert_throw( tag, failure_message = nil, &block )
+      #
+      #Fails unless the given block throws +tag+, returns the caught
+      #value otherwise.
+      #
+      #An optional failure message may be provided as the final argument.
+      #
+      #    tag = Object.new
+      #    assert_throw(tag, "#{tag} was not thrown!") do
+      #      throw tag
+      #    end
+      def assert_throw(tag, msg = nil)
+        ret = catch(tag) do
+          begin
+            yield(tag)
+          rescue UncaughtThrowError => e
+            thrown = e.tag
+          end
+          msg = message(msg) {
+            "Expected #{mu_pp(tag)} to have been thrown"\
+            "#{%Q[, not #{thrown}] if thrown}"
+          }
+          assert(false, msg)
+        end
+        assert(true)
+        ret
+      end
+
       class << (AssertFile = Struct.new(:failure_message).new)
         include CoreAssertions
         def assert_file_predicate(predicate, *args)
-- 
cgit v0.10.2


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

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