diff options
author | Alan Wu <[email protected]> | 2024-07-23 18:27:07 -0400 |
---|---|---|
committer | Benoit Daloze <[email protected]> | 2024-07-24 18:20:30 +0200 |
commit | 28382505b286a404fdf53bb17720f850d8dfdecc (patch) | |
tree | db0b996b51769d8039bf971573bb3e27a6129ca5 /spec/mspec/lib | |
parent | fbb981b9f819d24c4e11132c02ec02401eabcc5e (diff) |
Get fixnum_{min,max} from RbConfig::LIMITS when available
It's better than guessing based on the pointer size if the
implementation provides it directly.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/11130
Diffstat (limited to 'spec/mspec/lib')
-rw-r--r-- | spec/mspec/lib/mspec/helpers/numeric.rb | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/spec/mspec/lib/mspec/helpers/numeric.rb b/spec/mspec/lib/mspec/helpers/numeric.rb index 3be3dcdcd1..d877fc9296 100644 --- a/spec/mspec/lib/mspec/helpers/numeric.rb +++ b/spec/mspec/lib/mspec/helpers/numeric.rb @@ -31,7 +31,24 @@ end # specs based on the relationship between values rather than specific # values. if PlatformGuard.standard? or PlatformGuard.implementation? :topaz - if PlatformGuard.c_long_size? 32 + limits_available = begin + require 'rbconfig/sizeof' + defined?(RbConfig::LIMITS.[]) && ['FIXNUM_MAX', 'FIXNUM_MIN'].all? do |key| + Integer === RbConfig::LIMITS[key] + end + rescue LoadError + false + end + + if limits_available + def fixnum_max + RbConfig::LIMITS['FIXNUM_MAX'] + end + + def fixnum_min + RbConfig::LIMITS['FIXNUM_MIN'] + end + elsif PlatformGuard.c_long_size? 32 def fixnum_max (2**30) - 1 end |