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

ruby-changes:58161

From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Tue, 8 Oct 2019 11:25:53 +0900 (JST)
Subject: [ruby-changes:58161] 11b6ff12af (master): more use of RbConfig::LIMITS

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

From 11b6ff12af99b177979c7a4f57f49b91a50fcc0c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?=
 <shyouhei@r...>
Date: Tue, 8 Oct 2019 11:21:20 +0900
Subject: more use of RbConfig::LIMITS

`8 * RbConfig::SIZEOF` ... is not straight.

diff --git a/test/-ext-/string/test_modify_expand.rb b/test/-ext-/string/test_modify_expand.rb
index b7f9642..9aa3b9a 100644
--- a/test/-ext-/string/test_modify_expand.rb
+++ b/test/-ext-/string/test_modify_expand.rb
@@ -19,9 +19,8 @@ class Test_StringModifyExpand < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/-ext-/string/test_modify_expand.rb#L19
     return if RbConfig::SIZEOF['size_t'] > RbConfig::SIZEOF['long']
     bug12390 = '[ruby-core:75592] [Bug #12390]'
     s = Bug::String.new
-    long_max = (1 << (8 * RbConfig::SIZEOF['long'] - 1)) - 1
     assert_raise(ArgumentError, bug12390) {
-      s.modify_expand!(long_max)
+      s.modify_expand!(RbConfig::LIMITS["LONG_MAX"])
     }
   end
 end
diff --git a/test/stringio/test_stringio.rb b/test/stringio/test_stringio.rb
index b4369ed..07fe350 100644
--- a/test/stringio/test_stringio.rb
+++ b/test/stringio/test_stringio.rb
@@ -199,9 +199,8 @@ class TestStringIO < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/stringio/test_stringio.rb#L199
   end
 
   def test_write_integer_overflow
-    long_max = (1 << (RbConfig::SIZEOF["long"] * 8 - 1)) - 1
     f = StringIO.new
-    f.pos = long_max
+    f.pos = RbConfig::LIMITS["LONG_MAX"]
     assert_raise(ArgumentError) {
       f.write("pos + len overflows")
     }
@@ -767,7 +766,7 @@ class TestStringIO < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/stringio/test_stringio.rb#L766
 
   def test_overflow
     skip if RbConfig::SIZEOF["void*"] > RbConfig::SIZEOF["long"]
-    limit = (1 << (RbConfig::SIZEOF["void*"]*8-1)) - 0x10
+    limit = RbConfig::LIMITS["INTPTR_MAX"] - 0x10
     assert_separately(%w[-rstringio], "#{<<-"begin;"}\n#{<<-"end;"}")
     begin;
       limit = #{limit}
-- 
cgit v0.10.2


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

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