ruby-changes:55596
From: Yusuke <ko1@a...>
Date: Sun, 28 Apr 2019 23:42:49 +0900 (JST)
Subject: [ruby-changes:55596] Yusuke Endoh:cb55024613 (trunk): test/ruby/test_integer.rb: Add a sane test for Integer#[]
https://git.ruby-lang.org/ruby.git/commit/?id=cb55024613 From cb550246136b90a63b4f75f5e7cfaccb9da08eda Mon Sep 17 00:00:00 2001 From: Yusuke Endoh <mame@r...> Date: Sun, 28 Apr 2019 23:23:00 +0900 Subject: test/ruby/test_integer.rb: Add a sane test for Integer#[] diff --git a/test/ruby/test_integer.rb b/test/ruby/test_integer.rb index 69347b6..ad088aa 100644 --- a/test/ruby/test_integer.rb +++ b/test/ruby/test_integer.rb @@ -10,7 +10,21 @@ class TestInteger < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_integer.rb#L10 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] -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/