From 090a6ca4e9382e811404a15e099d55d1c1bd833d Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 16 Mar 2013 14:48:35 +0000 Subject: 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 --- test/ruby/test_bignum.rb | 13 +++++-------- 1 file 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 -- cgit v1.2.3