diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-07-19 05:38:48 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-07-19 05:38:48 +0000 |
commit | 09ce106ab3341030cc1893ca308532d196658508 (patch) | |
tree | e63986a0a7c33f6adaab73bb230bd41699e7ed2f /test/ruby/test_integer.rb | |
parent | ec6e26742cd467b210c8d2935edb1a0dcb26e0dd (diff) | |
download | ruby-09ce106ab3341030cc1893ca308532d196658508.tar.gz |
* bignum.c (rb_big_lshift, rb_big_rshift): separated functions
to get rid of infinite recursion. fixed calculation in edge
cases. [ruby-dev:31244]
* numeric.c (rb_fix_lshift, rb_fix_rshift): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12814 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_integer.rb')
-rw-r--r-- | test/ruby/test_integer.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/ruby/test_integer.rb b/test/ruby/test_integer.rb index d4b45d8287..dd2be1e2ca 100644 --- a/test/ruby/test_integer.rb +++ b/test/ruby/test_integer.rb @@ -93,6 +93,14 @@ class TestInteger < Test::Unit::TestCase #VS.map! {|v| 0x4000000000000000.coerce(v)[0] } + BDSIZE = 0x4000000000000000.coerce(0)[0].size + def self.bdsize(x) + ((x + 1) / 8 + BDSIZE) / BDSIZE * BDSIZE + end + def bdsize(x) + self.class.bdsize(x) + end + def test_aref VS.each {|a| 100.times {|i| @@ -233,6 +241,11 @@ class TestInteger < Test::Unit::TestCase end } } + assert_equal(0, 1 << -0x40000000) + assert_equal(0, 1 << -0x40000001) + assert_equal(0, 1 << -0x80000000) + assert_equal(0, 1 << -0x80000001) + # assert_equal(bdsize(0x80000000), (1 << 0x80000000).size) end def test_rshift @@ -248,6 +261,12 @@ class TestInteger < Test::Unit::TestCase end } } + # assert_equal(bdsize(0x40000001), (1 >> -0x40000001).size) + assert((1 >> 0x80000000).zero?) + assert((1 >> 0xffffffff).zero?) + assert((1 >> 0x100000000).zero?) + # assert_equal((1 << 0x40000000), (1 >> -0x40000000)) + # assert_equal((1 << 0x40000001), (1 >> -0x40000001)) end def test_succ |