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

ruby-changes:64775

From: Kenta <ko1@a...>
Date: Thu, 7 Jan 2021 10:21:34 +0900 (JST)
Subject: [ruby-changes:64775] 698d7947c3 (master): [ruby/bigdecimal] Include TestBigDecimalBase in TestBigDecimalUtil

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

From 698d7947c300a5f5d63965fb2ccce59601f2563b Mon Sep 17 00:00:00 2001
From: Kenta Murata <mrkn@m...>
Date: Wed, 6 Jan 2021 14:41:13 +0900
Subject: [ruby/bigdecimal] Include TestBigDecimalBase in TestBigDecimalUtil

https://github.com/ruby/bigdecimal/commit/f732201df1

diff --git a/test/bigdecimal/helper.rb b/test/bigdecimal/helper.rb
new file mode 100644
index 0000000..22b05f0
--- /dev/null
+++ b/test/bigdecimal/helper.rb
@@ -0,0 +1,28 @@ https://github.com/ruby/ruby/blob/trunk/test/bigdecimal/helper.rb#L1
+# frozen_string_literal: false
+require "test/unit"
+require "bigdecimal"
+
+module TestBigDecimalBase
+  def setup
+    @mode = BigDecimal.mode(BigDecimal::EXCEPTION_ALL)
+    BigDecimal.mode(BigDecimal::EXCEPTION_ALL, true)
+    BigDecimal.mode(BigDecimal::EXCEPTION_UNDERFLOW, true)
+    BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, true)
+    BigDecimal.mode(BigDecimal::ROUND_MODE, BigDecimal::ROUND_HALF_UP)
+    BigDecimal.limit(0)
+  end
+
+  def teardown
+    [BigDecimal::EXCEPTION_INFINITY, BigDecimal::EXCEPTION_NaN,
+     BigDecimal::EXCEPTION_UNDERFLOW, BigDecimal::EXCEPTION_OVERFLOW].each do |mode|
+      BigDecimal.mode(mode, !(@mode & mode).zero?)
+    end
+  end
+
+  def under_gc_stress
+    stress, GC.stress = GC.stress, true
+    yield
+  ensure
+    GC.stress = stress
+  end
+end
diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb
index 5599234..74c991f 100644
--- a/test/bigdecimal/test_bigdecimal.rb
+++ b/test/bigdecimal/test_bigdecimal.rb
@@ -1,5 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/test/bigdecimal/test_bigdecimal.rb#L1
 # frozen_string_literal: false
-require_relative "testbase"
+require_relative "helper"
 require 'bigdecimal/math'
 require 'rbconfig/sizeof'
 
diff --git a/test/bigdecimal/test_bigdecimal_util.rb b/test/bigdecimal/test_bigdecimal_util.rb
index b855fd5..3e3d9db 100644
--- a/test/bigdecimal/test_bigdecimal_util.rb
+++ b/test/bigdecimal/test_bigdecimal_util.rb
@@ -1,9 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/test/bigdecimal/test_bigdecimal_util.rb#L1
 # frozen_string_literal: false
-require_relative "testbase"
-
+require_relative "helper"
 require 'bigdecimal/util'
 
 class TestBigDecimalUtil < Test::Unit::TestCase
+  include TestBigDecimalBase
+
   def test_BigDecimal_to_d
     x = BigDecimal(1)
     assert_same(x, x.to_d)
diff --git a/test/bigdecimal/test_bigmath.rb b/test/bigdecimal/test_bigmath.rb
index 6f271d0..5bf1fbf 100644
--- a/test/bigdecimal/test_bigmath.rb
+++ b/test/bigdecimal/test_bigmath.rb
@@ -1,5 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/test/bigdecimal/test_bigmath.rb#L1
 # frozen_string_literal: false
-require_relative "testbase"
+require_relative "helper"
 require "bigdecimal/math"
 
 class TestBigMath < Test::Unit::TestCase
diff --git a/test/bigdecimal/test_ractor.rb b/test/bigdecimal/test_ractor.rb
index 3ccd7c8..f78663f 100644
--- a/test/bigdecimal/test_ractor.rb
+++ b/test/bigdecimal/test_ractor.rb
@@ -1,5 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/test/bigdecimal/test_ractor.rb#L1
 # frozen_string_literal: true
-require_relative "testbase"
+require_relative "helper"
 
 class TestBigDecimalRactor < Test::Unit::TestCase
   include TestBigDecimalBase
diff --git a/test/bigdecimal/testbase.rb b/test/bigdecimal/testbase.rb
deleted file mode 100644
index 22b05f0..0000000
--- a/test/bigdecimal/testbase.rb
+++ /dev/null
@@ -1,28 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/test/bigdecimal/test_ractor.rb#L0
-# frozen_string_literal: false
-require "test/unit"
-require "bigdecimal"
-
-module TestBigDecimalBase
-  def setup
-    @mode = BigDecimal.mode(BigDecimal::EXCEPTION_ALL)
-    BigDecimal.mode(BigDecimal::EXCEPTION_ALL, true)
-    BigDecimal.mode(BigDecimal::EXCEPTION_UNDERFLOW, true)
-    BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, true)
-    BigDecimal.mode(BigDecimal::ROUND_MODE, BigDecimal::ROUND_HALF_UP)
-    BigDecimal.limit(0)
-  end
-
-  def teardown
-    [BigDecimal::EXCEPTION_INFINITY, BigDecimal::EXCEPTION_NaN,
-     BigDecimal::EXCEPTION_UNDERFLOW, BigDecimal::EXCEPTION_OVERFLOW].each do |mode|
-      BigDecimal.mode(mode, !(@mode & mode).zero?)
-    end
-  end
-
-  def under_gc_stress
-    stress, GC.stress = GC.stress, true
-    yield
-  ensure
-    GC.stress = stress
-  end
-end
-- 
cgit v0.10.2


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

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