1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

test/ruby/test_integer.rb: Add a sane test for Integer#[]

This commit is contained in:
Yusuke Endoh 2019-04-28 23:23:00 +09:00
parent 3bc810334c
commit cb55024613

View file

@ -10,7 +10,21 @@ class TestInteger < Test::Unit::TestCase
self.class.bdsize(x)
end
FIXNUM_MIN = RbConfig::LIMITS['FIXNUM_MIN']
FIXNUM_MAX = RbConfig::LIMITS['FIXNUM_MAX']
def test_aref
[
*-16..16,
*(FIXNUM_MIN-2)..(FIXNUM_MIN+2),
*(FIXNUM_MAX-2)..(FIXNUM_MAX+2),
].each do |n|
(-64..64).each do |idx|
assert_equal((n >> idx) & 1, n[idx])
end
end
# assert_equal(1, (1 << 0x40000000)[0x40000000], "[ruby-dev:31271]")
# assert_equal(0, (-1 << 0x40000001)[0x40000000], "[ruby-dev:31271]")
big_zero = 0x40000000.coerce(0)[0]