diff options
author | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-02-05 05:39:49 +0000 |
---|---|---|
committer | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-02-05 05:39:49 +0000 |
commit | d22ce4a522141c2f6e847846944ddc1ec3a949f2 (patch) | |
tree | 1d1f246b6457ebed0d45ae33ba34d12e62d7facb /test/ruby/test_fixnum.rb | |
parent | 8797ebd662954c96a25bac1648279431a3a378a8 (diff) | |
download | ruby-d22ce4a522141c2f6e847846944ddc1ec3a949f2.tar.gz |
* numeric.c (fix_pow): Handle special cases when base is 0, -1 or +1
[Bug #5713] [Bug #5715]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39064 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_fixnum.rb')
-rw-r--r-- | test/ruby/test_fixnum.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/ruby/test_fixnum.rb b/test/ruby/test_fixnum.rb index 4567da0a60..85c8bdfa7b 100644 --- a/test/ruby/test_fixnum.rb +++ b/test/ruby/test_fixnum.rb @@ -279,4 +279,23 @@ class TestFixnum < Test::Unit::TestCase def test_frozen assert_equal(true, 1.frozen?) end + + def assert_eql(a, b, mess) + assert a.eql?(b), "expected #{a} & #{b} to be eql? #{mess}" + end + + def test_power_of_1_and_minus_1 + bug5715 = '[ruby-core:41498]' + big = 1 << 66 + assert_eql 1, 1 ** -big , bug5715 + assert_eql 1, (-1) ** -big , bug5715 + assert_eql -1, (-1) ** -(big+1) , bug5715 + end + + def test_power_of_0 + bug5713 = '[ruby-core:41494]' + big = 1 << 66 + assert_raise(ZeroDivisionError, bug5713) { 0 ** -big } + assert_raise(ZeroDivisionError, bug5713) { 0 ** Rational(-2,3) } + end end |