diff options
author | mrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-27 12:46:32 +0000 |
---|---|---|
committer | mrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-27 12:46:32 +0000 |
commit | 1dce5edf993a15c66c61965fcab4c2f5a07f6312 (patch) | |
tree | 34bcf7e5ea51b9c40738cea49635586b0ba7d191 /test | |
parent | 956cc2934d9848fa4c5cc7bcf79edd76f1171053 (diff) | |
download | ruby-1dce5edf993a15c66c61965fcab4c2f5a07f6312.tar.gz |
* bignum.c (bigdivrem): optimize the way to retry calculation of
bigdivrem so that the calculation is started from the point where
the last interruption was occurred.
* bignum.c (bigdivrem1): ditto.
* test/ruby/test_bignum.rb: add a test case for rb_bigdivrem in the
case that an interruption is occurred during bigdivrem1 is running.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37899 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_bignum.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/ruby/test_bignum.rb b/test/ruby/test_bignum.rb index b1497a9146..1ff23e2a00 100644 --- a/test/ruby/test_bignum.rb +++ b/test/ruby/test_bignum.rb @@ -581,6 +581,36 @@ class TestBignum < Test::Unit::TestCase assert_interrupt {(65536 ** 65536).to_s} end + def test_interrupt_during_bigdivrem + return unless Process.respond_to?(:kill) + begin + trace = [] + oldtrap = Signal.trap(:INT) {|sig| trace << :int } + a = 456 ** 100 + b = 123 ** 100 + c = nil + 100.times do |n| + a **= 3 + b **= 3 + trace.clear + th = Thread.new do + sleep 0.1; Process.kill :INT, $$ + sleep 0.1; Process.kill :INT, $$ + end + c = a / b + trace << :end + th.join + if trace == [:int, :int, :end] + assert_equal(a / b, c) + return + end + end + skip "cannot create suitable test case" + ensure + Signal.trap(:INT, oldtrap) if oldtrap + end + end + def test_too_big_to_s if (big = 2**31-1).is_a?(Fixnum) return |