summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-02-29 17:35:11 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-02-29 17:35:11 +0000
commite811e5e4729b46b1c5522977437e25901852580f (patch)
tree4f53ac4cb3bcb9823a7c93f030309f2e888b8967 /test
parentf8f371c011d9b671f5061b2a36fe111b73c53ed6 (diff)
* bignum.c (big2str_find_n1): check integer overflow.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15646 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_bignum.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/ruby/test_bignum.rb b/test/ruby/test_bignum.rb
index 48e8d9a92c..bfc47784f0 100644
--- a/test/ruby/test_bignum.rb
+++ b/test/ruby/test_bignum.rb
@@ -95,4 +95,13 @@ class TestBignum < Test::Unit::TestCase
assert_equal("1777777777777777777777" ,18446744073709551615.to_s(8))
assert_equal("-1777777777777777777777" ,-18446744073709551615.to_s(8))
end
+
+ def test_too_big_to_s
+ i = 32
+ while (big = 2**(i-1)-1).is_a?(Fixnum)
+ i *= 2
+ end
+ e = assert_raise(RangeError) {(1 << big).to_s}
+ assert_match(/too big to convert/, e.message)
+ end
end