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:
parent
3bc810334c
commit
cb55024613
1 changed files with 14 additions and 0 deletions
|
@ -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]
|
||||
|
|
Loading…
Reference in a new issue