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

ruby-changes:66681

From: Nobuyoshi <ko1@a...>
Date: Sun, 4 Jul 2021 15:28:46 +0900 (JST)
Subject: [ruby-changes:66681] 2488589b2f (master): Removed extra double quotes from domain error messages

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

From 2488589b2f1a70dbfdc4155ac9bea3c533ef35d8 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Sun, 4 Jul 2021 15:28:25 +0900
Subject: Removed extra double quotes from domain error messages

---
 math.c                 |  2 +-
 test/ruby/test_math.rb | 32 ++++++++++++++++----------------
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/math.c b/math.c
index 3b72149..d099e25 100644
--- a/math.c
+++ b/math.c
@@ -39,7 +39,7 @@ VALUE rb_eMathDomainError; https://github.com/ruby/ruby/blob/trunk/math.c#L39
 #define Get_Double(x) rb_num_to_dbl(x)
 
 #define domain_error(msg) \
-    rb_raise(rb_eMathDomainError, "Numerical argument is out of domain - " #msg)
+    rb_raise(rb_eMathDomainError, "Numerical argument is out of domain - " msg)
 
 /*
  *  call-seq:
diff --git a/test/ruby/test_math.rb b/test/ruby/test_math.rb
index 6c2b257..abfb980 100644
--- a/test/ruby/test_math.rb
+++ b/test/ruby/test_math.rb
@@ -73,9 +73,9 @@ class TestMath < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_math.rb#L73
     check(1 * Math::PI / 4, Math.acos( 1.0 / Math.sqrt(2)))
     check(2 * Math::PI / 4, Math.acos( 0.0))
     check(4 * Math::PI / 4, Math.acos(-1.0))
-    assert_raise(Math::DomainError) { Math.acos(+1.0 + Float::EPSILON) }
-    assert_raise(Math::DomainError) { Math.acos(-1.0 - Float::EPSILON) }
-    assert_raise(Math::DomainError) { Math.acos(2.0) }
+    assert_raise_with_message(Math::DomainError, /\bacos\b/) { Math.acos(+1.0 + Float::EPSILON) }
+    assert_raise_with_message(Math::DomainError, /\bacos\b/) { Math.acos(-1.0 - Float::EPSILON) }
+    assert_raise_with_message(Math::DomainError, /\bacos\b/) { Math.acos(2.0) }
   end
 
   def test_asin
@@ -83,9 +83,9 @@ class TestMath < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_math.rb#L83
     check( 1 * Math::PI / 4, Math.asin( 1.0 / Math.sqrt(2)))
     check( 2 * Math::PI / 4, Math.asin( 1.0))
     check(-2 * Math::PI / 4, Math.asin(-1.0))
-    assert_raise(Math::DomainError) { Math.asin(+1.0 + Float::EPSILON) }
-    assert_raise(Math::DomainError) { Math.asin(-1.0 - Float::EPSILON) }
-    assert_raise(Math::DomainError) { Math.asin(2.0) }
+    assert_raise_with_message(Math::DomainError, /\basin\b/) { Math.asin(+1.0 + Float::EPSILON) }
+    assert_raise_with_message(Math::DomainError, /\basin\b/) { Math.asin(-1.0 - Float::EPSILON) }
+    assert_raise_with_message(Math::DomainError, /\basin\b/) { Math.asin(2.0) }
   end
 
   def test_atan
@@ -119,8 +119,8 @@ class TestMath < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_math.rb#L119
     check(0, Math.acosh(1))
     check(1, Math.acosh((Math::E ** 1 + Math::E ** -1) / 2))
     check(2, Math.acosh((Math::E ** 2 + Math::E ** -2) / 2))
-    assert_raise(Math::DomainError) { Math.acosh(1.0 - Float::EPSILON) }
-    assert_raise(Math::DomainError) { Math.acosh(0) }
+    assert_raise_with_message(Math::DomainError, /\bacosh\b/) { Math.acosh(1.0 - Float::EPSILON) }
+    assert_raise_with_message(Math::DomainError, /\bacosh\b/) { Math.acosh(0) }
   end
 
   def test_asinh
@@ -135,8 +135,8 @@ class TestMath < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_math.rb#L135
     check(2, Math.atanh(Math.sinh(2) / Math.cosh(2)))
     assert_nothing_raised { assert_infinity(Math.atanh(1)) }
     assert_nothing_raised { assert_infinity(-Math.atanh(-1)) }
-    assert_raise(Math::DomainError) { Math.atanh(+1.0 + Float::EPSILON) }
-    assert_raise(Math::DomainError) { Math.atanh(-1.0 - Float::EPSILON) }
+    assert_raise_with_message(Math::DomainError, /\batanh\b/) { Math.atanh(+1.0 + Float::EPSILON) }
+    assert_raise_with_message(Math::DomainError, /\batanh\b/) { Math.atanh(-1.0 - Float::EPSILON) }
   end
 
   def test_exp
@@ -157,7 +157,7 @@ class TestMath < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_math.rb#L157
     assert_nothing_raised { assert_infinity(Math.log(1.0/0)) }
     assert_nothing_raised { assert_infinity(-Math.log(+0.0)) }
     assert_nothing_raised { assert_infinity(-Math.log(-0.0)) }
-    assert_raise(Math::DomainError) { Math.log(-1.0) }
+    assert_raise_with_message(Math::DomainError, /\blog\b/) { Math.log(-1.0) }
     assert_raise(TypeError) { Math.log(1,nil) }
     assert_raise(Math::DomainError, '[ruby-core:62309] [ruby-Bug #9797]') { Math.log(1.0, -1.0) }
     assert_nothing_raised { assert_nan(Math.log(0.0, 0.0)) }
@@ -172,7 +172,7 @@ class TestMath < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_math.rb#L172
     assert_nothing_raised { assert_infinity(Math.log2(1.0/0)) }
     assert_nothing_raised { assert_infinity(-Math.log2(+0.0)) }
     assert_nothing_raised { assert_infinity(-Math.log2(-0.0)) }
-    assert_raise(Math::DomainError) { Math.log2(-1.0) }
+    assert_raise_with_message(Math::DomainError, /\blog2\b/) { Math.log2(-1.0) }
   end
 
   def test_log10
@@ -184,7 +184,7 @@ class TestMath < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_math.rb#L184
     assert_nothing_raised { assert_infinity(Math.log10(1.0/0)) }
     assert_nothing_raised { assert_infinity(-Math.log10(+0.0)) }
     assert_nothing_raised { assert_infinity(-Math.log10(-0.0)) }
-    assert_raise(Math::DomainError) { Math.log10(-1.0) }
+    assert_raise_with_message(Math::DomainError, /\blog10\b/) { Math.log10(-1.0) }
   end
 
   def test_sqrt
@@ -193,7 +193,7 @@ class TestMath < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_math.rb#L193
     check(2, Math.sqrt(4))
     assert_nothing_raised { assert_infinity(Math.sqrt(1.0/0)) }
     assert_equal("0.0", Math.sqrt(-0.0).to_s) # insure it is +0.0, not -0.0
-    assert_raise(Math::DomainError) { Math.sqrt(-1.0) }
+    assert_raise_with_message(Math::DomainError, /\bsqrt\b/) { Math.sqrt(-1.0) }
   end
 
   def test_cbrt
@@ -258,7 +258,7 @@ class TestMath < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_math.rb#L258
       assert_infinity(Math.gamma(i-1), "Math.gamma(#{i-1}) should be INF")
     end
 
-    assert_raise(Math::DomainError) { Math.gamma(-Float::INFINITY) }
+    assert_raise_with_message(Math::DomainError, /\bgamma\b/) { Math.gamma(-Float::INFINITY) }
     x = Math.gamma(-0.0)
     mesg = "Math.gamma(-0.0) should be -INF"
     assert_infinity(x, mesg)
@@ -278,7 +278,7 @@ class TestMath < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_math.rb#L278
     assert_float_and_int([Math.log(15 * sqrt_pi / 8), 1], Math.lgamma(3.5))
     assert_float_and_int([Math.log(6),                1], Math.lgamma(4))
 
-    assert_raise(Math::DomainError) { Math.lgamma(-Float::INFINITY) }
+    assert_raise_with_message(Math::DomainError, /\blgamma\b/) { Math.lgamma(-Float::INFINITY) }
     x, sign = Math.lgamma(-0.0)
     mesg = "Math.lgamma(-0.0) should be [INF, -1]"
     assert_infinity(x, mesg)
-- 
cgit v1.1


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

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