ruby-changes:27728
From: nobu <ko1@a...>
Date: Sat, 16 Mar 2013 23:50:28 +0900 (JST)
Subject: [ruby-changes:27728] nobu:r39780 (trunk): test_bignum.rb: refine test
nobu 2013-03-16 23:48:35 +0900 (Sat, 16 Mar 2013) New Revision: 39780 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=39780 Log: 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. Modified files: trunk/test/ruby/test_bignum.rb Index: test/ruby/test_bignum.rb =================================================================== --- test/ruby/test_bignum.rb (revision 39779) +++ test/ruby/test_bignum.rb (revision 39780) @@ -560,27 +560,24 @@ class TestBignum < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_bignum.rb#L560 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/