diff options
author | Yusuke Endoh <mame@ruby-lang.org> | 2019-04-28 23:23:00 +0900 |
---|---|---|
committer | Yusuke Endoh <mame@ruby-lang.org> | 2019-04-28 23:23:00 +0900 |
commit | cb550246136b90a63b4f75f5e7cfaccb9da08eda (patch) | |
tree | ef8aca42c6a1460b85e797aaaad6a1ed366652aa /test | |
parent | 3bc810334c776bb68bddeeced9bd91f918c8581f (diff) | |
download | ruby-cb550246136b90a63b4f75f5e7cfaccb9da08eda.tar.gz |
test/ruby/test_integer.rb: Add a sane test for Integer#[]
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_integer.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/ruby/test_integer.rb b/test/ruby/test_integer.rb index 69347b6b11..ad088aa72f 100644 --- a/test/ruby/test_integer.rb +++ b/test/ruby/test_integer.rb @@ -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] |