summaryrefslogtreecommitdiff
path: root/spec/mspec/lib
diff options
context:
space:
mode:
authorBenoit Daloze <[email protected]>2024-11-06 21:57:33 +0100
committerBenoit Daloze <[email protected]>2024-11-06 21:58:28 +0100
commit9bc63e7ba066b31314bbd66def4932b398eaf4c9 (patch)
treee42a67d1f4ea5af70554e9e887adccbfc5f3a450 /spec/mspec/lib
parent35bf6603372360c7680653328274a670fa1d9f38 (diff)
Update to ruby/mspec@6499325
Diffstat (limited to 'spec/mspec/lib')
-rw-r--r--spec/mspec/lib/mspec/guards/platform.rb18
-rw-r--r--spec/mspec/lib/mspec/helpers/numeric.rb6
2 files changed, 18 insertions, 6 deletions
diff --git a/spec/mspec/lib/mspec/guards/platform.rb b/spec/mspec/lib/mspec/guards/platform.rb
index 03c0fca8f5..fadd8d75ef 100644
--- a/spec/mspec/lib/mspec/guards/platform.rb
+++ b/spec/mspec/lib/mspec/guards/platform.rb
@@ -53,17 +53,28 @@ class PlatformGuard < SpecGuard
end
end
+ # In bits
+ WORD_SIZE = 1.size * 8
+ deprecate_constant :WORD_SIZE
+
+ # In bits
POINTER_SIZE = begin
require 'rbconfig/sizeof'
RbConfig::SIZEOF["void*"] * 8
rescue LoadError
- [0].pack('j').size
+ [0].pack('j').size * 8
end
+ # In bits
C_LONG_SIZE = if defined?(RbConfig::SIZEOF[])
RbConfig::SIZEOF["long"] * 8
else
- [0].pack('l!').size
+ [0].pack('l!').size * 8
+ end
+
+ def self.wordsize?(size)
+ warn "#wordsize? is deprecated, use #c_long_size?"
+ size == WORD_SIZE
end
def self.pointer_size?(size)
@@ -91,6 +102,9 @@ class PlatformGuard < SpecGuard
match &&= PlatformGuard.os?(*value)
when :pointer_size
match &&= PlatformGuard.pointer_size? value
+ when :wordsize
+ warn ":wordsize is deprecated, use :c_long_size"
+ match &&= PlatformGuard.wordsize? value
when :c_long_size
match &&= PlatformGuard::c_long_size? value
end
diff --git a/spec/mspec/lib/mspec/helpers/numeric.rb b/spec/mspec/lib/mspec/helpers/numeric.rb
index d877fc9296..0b47855cd2 100644
--- a/spec/mspec/lib/mspec/helpers/numeric.rb
+++ b/spec/mspec/lib/mspec/helpers/numeric.rb
@@ -16,13 +16,11 @@ def bignum_value(plus = 0)
end
def max_long
- long_byte_size = [0].pack('l!').size
- 2**(long_byte_size * 8 - 1) - 1
+ 2**(PlatformGuard::C_LONG_SIZE - 1) - 1
end
def min_long
- long_byte_size = [0].pack('l!').size
- -(2**(long_byte_size * 8 - 1))
+ -(2**(PlatformGuard::C_LONG_SIZE - 1))
end
# This is a bit hairy, but we need to be able to write specs that cover the