diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-03-16 14:48:35 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-03-16 14:48:35 +0000 |
commit | 090a6ca4e9382e811404a15e099d55d1c1bd833d (patch) | |
tree | c59149e35dad2c8a51dd262b2bd119713ce246a8 | |
parent | de9911f5970bae5072a82ac33e054b5cf4bb7dac (diff) | |
download | ruby-090a6ca4e9382e811404a15e099d55d1c1bd833d.tar.gz |
test_bignum.rb: refine test
* test/ruby/test_bignum.rb (test_interrupt_during_to_s): rename and
merge with assert_interrupt, separate Bignum power from to_s, get
rid of busy loop, and skip if the conversion is too fast.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39780 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | test/ruby/test_bignum.rb | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/test/ruby/test_bignum.rb b/test/ruby/test_bignum.rb index 4af3748344..a3cba398e3 100644 --- a/test/ruby/test_bignum.rb +++ b/test/ruby/test_bignum.rb @@ -560,27 +560,24 @@ class TestBignum < Test::Unit::TestCase assert_equal(true, (2**32).even?) end - def assert_interrupt + def test_interrupt_during_to_s time = Time.now start_flag = false end_flag = false + num = (65536 ** 65536) thread = Thread.new do start_flag = true - yield + num.to_s end_flag = true end - Thread.pass until start_flag + sleep 0.001 until start_flag thread.raise thread.join rescue nil time = Time.now - time - assert_equal([true, false], [start_flag, end_flag]) + skip "too fast cpu" if end_flag assert_operator(time, :<, 10) end - def test_interrupt - assert_interrupt {(65536 ** 65536).to_s} - end - def test_interrupt_during_bigdivrem return unless Process.respond_to?(:kill) begin |