diff options
author | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-02-05 05:39:33 +0000 |
---|---|---|
committer | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-02-05 05:39:33 +0000 |
commit | 8797ebd662954c96a25bac1648279431a3a378a8 (patch) | |
tree | 6569f60a29873f16cf46033422e34aee03a5d644 /test | |
parent | 075ae2955cc34980005a3bd3327049d28d1c1a25 (diff) | |
download | ruby-8797ebd662954c96a25bac1648279431a3a378a8.tar.gz |
* rational.c (nurat_expt): Deal with special cases for rationals 0, ±1
[bug #5713] [bug #5715]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39063 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_rational.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/ruby/test_rational.rb b/test/ruby/test_rational.rb index 208099a4ab..0496c0afe3 100644 --- a/test/ruby/test_rational.rb +++ b/test/ruby/test_rational.rb @@ -1143,6 +1143,26 @@ class Rational_Test < Test::Unit::TestCase assert_equal(1.0, Rational(n + 2, n + 1).to_f, '[ruby-dev:33852]') end + def test_power_of_1_and_minus_1 + bug5715 = '[ruby-core:41498]' + big = 1 << 66 + one = Rational( 1, 1) + assert_eql one, one ** -big , bug5715 + assert_eql one, (-one) ** -big , bug5715 + assert_eql -one, (-one) ** -(big+1) , bug5715 + assert_equal Complex, ((-one) ** Rational(1,3)).class + end + + def test_power_of_0 + bug5713 = '[ruby-core:41494]' + big = 1 << 66 + zero = Rational(0, 1) + assert_eql zero, zero ** big + assert_eql zero, zero ** Rational(2, 3) + assert_raise(ZeroDivisionError, bug5713) { Rational(0, 1) ** -big } + assert_raise(ZeroDivisionError, bug5713) { Rational(0, 1) ** Rational(-2,3) } + end + def test_known_bug end |