diff options
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_bignum.rb | 2 | ||||
-rw-r--r-- | test/ruby/test_dir.rb | 2 | ||||
-rw-r--r-- | test/ruby/test_exception.rb | 2 | ||||
-rw-r--r-- | test/ruby/test_io.rb | 2 | ||||
-rw-r--r-- | test/ruby/test_process.rb | 2 | ||||
-rw-r--r-- | test/ruby/test_settracefunc.rb | 8 | ||||
-rw-r--r-- | test/ruby/test_thread.rb | 14 | ||||
-rw-r--r-- | test/ruby/test_thread_cv.rb | 52 | ||||
-rw-r--r-- | test/ruby/test_thread_queue.rb | 80 |
9 files changed, 82 insertions, 82 deletions
diff --git a/test/ruby/test_bignum.rb b/test/ruby/test_bignum.rb index 68c8461951..3ffe7114b5 100644 --- a/test/ruby/test_bignum.rb +++ b/test/ruby/test_bignum.rb @@ -632,7 +632,7 @@ class TestBignum < Test::Unit::TestCase time = Time.now end_flag = false num = (65536 ** 65536) - q = Queue.new + q = Thread::Queue.new thread = Thread.new do assert_raise(RuntimeError) { q << true diff --git a/test/ruby/test_dir.rb b/test/ruby/test_dir.rb index bb268f2ab3..71bff5f5c3 100644 --- a/test/ruby/test_dir.rb +++ b/test/ruby/test_dir.rb @@ -131,7 +131,7 @@ class TestDir < Test::Unit::TestCase def test_chdir_conflict pwd = Dir.pwd - q = Queue.new + q = Thread::Queue.new t = Thread.new do q.pop Dir.chdir(pwd) rescue $! diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb index 8c4e6889ab..62da13d1b9 100644 --- a/test/ruby/test_exception.rb +++ b/test/ruby/test_exception.rb @@ -814,7 +814,7 @@ end.join bug12741 = '[ruby-core:77222] [Bug #12741]' x = Thread.current - q = Queue.new + q = Thread::Queue.new y = Thread.start do q.pop begin diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 7acedb60e2..f7240c4cf6 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -3736,7 +3736,7 @@ __END__ begin; bug13158 = '[ruby-core:79262] [Bug #13158]' closed = nil - q = Queue.new + q = Thread::Queue.new IO.pipe do |r, w| thread = Thread.new do begin diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb index 0493544139..80d2eefca9 100644 --- a/test/ruby/test_process.rb +++ b/test/ruby/test_process.rb @@ -2433,7 +2433,7 @@ EOS rescue SystemCallError w.syswrite("exec failed\n") end - q = Queue.new + q = Thread::Queue.new th1 = Thread.new { i = 0; i += 1 while q.empty?; i } th2 = Thread.new { j = 0; j += 1 while q.empty? && Thread.pass.nil?; j } sleep 0.5 diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb index c8ec81c72a..dafe58d70c 100644 --- a/test/ruby/test_settracefunc.rb +++ b/test/ruby/test_settracefunc.rb @@ -1984,7 +1984,7 @@ class TestSetTraceFunc < Test::Unit::TestCase def test_thread_add_trace_func events = [] base_line = __LINE__ - q = Queue.new + q = Thread::Queue.new t = Thread.new{ Thread.current.add_trace_func proc{|ev, file, line, *args| events << [ev, line] @@ -2010,7 +2010,7 @@ class TestSetTraceFunc < Test::Unit::TestCase # other thread events = [] - m2t_q = Queue.new + m2t_q = Thread::Queue.new t = Thread.new{ Thread.current.abort_on_exception = true @@ -2320,8 +2320,8 @@ class TestSetTraceFunc < Test::Unit::TestCase events << Thread.current end - q1 = Queue.new - q2 = Queue.new + q1 = Thread::Queue.new + q2 = Thread::Queue.new th = Thread.new{ q1 << :ok; q2.pop diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb index dbd0328e28..a75d42b962 100644 --- a/test/ruby/test_thread.rb +++ b/test/ruby/test_thread.rb @@ -496,7 +496,7 @@ class TestThread < Test::Unit::TestCase end assert_in_out_err([], <<-INPUT, %w(false :sig), [], :signal=>:INT, timeout: 1, timeout_error: nil) p Thread.ignore_deadlock - q = Queue.new + q = Thread::Queue.new trap(:INT){q.push :sig} Thread.ignore_deadlock = true p q.pop @@ -731,8 +731,8 @@ class TestThread < Test::Unit::TestCase def make_handle_interrupt_test_thread1 flag r = [] - ready_q = Queue.new - done_q = Queue.new + ready_q = Thread::Queue.new + done_q = Thread::Queue.new th = Thread.new{ begin Thread.handle_interrupt(RuntimeError => flag){ @@ -809,7 +809,7 @@ class TestThread < Test::Unit::TestCase def test_handle_interrupt_blocking r = nil - q = Queue.new + q = Thread::Queue.new e = Class.new(Exception) th_s = Thread.current th = Thread.start { @@ -833,7 +833,7 @@ class TestThread < Test::Unit::TestCase def test_handle_interrupt_and_io assert_in_out_err([], <<-INPUT, %w(ok), []) th_waiting = true - q = Queue.new + q = Thread::Queue.new t = Thread.new { Thread.current.report_on_exception = false @@ -1235,7 +1235,7 @@ q.pop end if Process.respond_to?(:fork) def test_fork_while_locked - m = Mutex.new + m = Thread::Mutex.new thrs = [] 3.times do |i| thrs << Thread.new { m.synchronize { Process.waitpid2(fork{})[1] } } @@ -1268,7 +1268,7 @@ q.pop def test_fork_while_mutex_locked_by_forker skip 'needs fork' unless Process.respond_to?(:fork) - m = Mutex.new + m = Thread::Mutex.new m.synchronize do pid = fork do exit!(2) unless m.locked? diff --git a/test/ruby/test_thread_cv.rb b/test/ruby/test_thread_cv.rb index 38bcc3b8fa..5f19b85bc0 100644 --- a/test/ruby/test_thread_cv.rb +++ b/test/ruby/test_thread_cv.rb @@ -13,8 +13,8 @@ class TestThreadConditionVariable < Test::Unit::TestCase end def test_condvar_signal_and_wait - mutex = Mutex.new - condvar = ConditionVariable.new + mutex = Thread::Mutex.new + condvar = Thread::ConditionVariable.new result = [] mutex.synchronize do t = Thread.new do @@ -35,8 +35,8 @@ class TestThreadConditionVariable < Test::Unit::TestCase def test_condvar_wait_exception_handling # Calling wait in the only thread running should raise a ThreadError of # 'stopping only thread' - mutex = Mutex.new - condvar = ConditionVariable.new + mutex = Thread::Mutex.new + condvar = Thread::ConditionVariable.new locked = false thread = Thread.new do @@ -61,8 +61,8 @@ class TestThreadConditionVariable < Test::Unit::TestCase def test_condvar_wait_and_broadcast nr_threads = 3 threads = Array.new - mutex = Mutex.new - condvar = ConditionVariable.new + mutex = Thread::Mutex.new + condvar = Thread::ConditionVariable.new result = [] nr_threads.times do |i| @@ -91,8 +91,8 @@ class TestThreadConditionVariable < Test::Unit::TestCase def test_condvar_wait_deadlock assert_in_out_err([], <<-INPUT, /\Afatal\nNo live threads left\. Deadlock/, []) - mutex = Mutex.new - cv = ConditionVariable.new + mutex = Thread::Mutex.new + cv = Thread::ConditionVariable.new klass = nil mesg = nil @@ -112,8 +112,8 @@ INPUT def test_condvar_wait_deadlock_2 nr_threads = 3 threads = Array.new - mutex = Mutex.new - condvar = ConditionVariable.new + mutex = Thread::Mutex.new + condvar = Thread::ConditionVariable.new nr_threads.times do |i| if (i != 0) @@ -136,8 +136,8 @@ INPUT end def test_condvar_timed_wait - mutex = Mutex.new - condvar = ConditionVariable.new + mutex = Thread::Mutex.new + condvar = Thread::ConditionVariable.new timeout = 0.3 locked = false @@ -157,15 +157,15 @@ INPUT end def test_condvar_nolock - mutex = Mutex.new - condvar = ConditionVariable.new + mutex = Thread::Mutex.new + condvar = Thread::ConditionVariable.new assert_raise(ThreadError) {condvar.wait(mutex)} end def test_condvar_nolock_2 - mutex = Mutex.new - condvar = ConditionVariable.new + mutex = Thread::Mutex.new + condvar = Thread::ConditionVariable.new Thread.new do assert_raise(ThreadError) {condvar.wait(mutex)} @@ -173,8 +173,8 @@ INPUT end def test_condvar_nolock_3 - mutex = Mutex.new - condvar = ConditionVariable.new + mutex = Thread::Mutex.new + condvar = Thread::ConditionVariable.new Thread.new do assert_raise(ThreadError) {condvar.wait(mutex, 0.1)} @@ -182,22 +182,22 @@ INPUT end def test_condvar_empty_signal - mutex = Mutex.new - condvar = ConditionVariable.new + mutex = Thread::Mutex.new + condvar = Thread::ConditionVariable.new assert_nothing_raised(Exception) { mutex.synchronize {condvar.signal} } end def test_condvar_empty_broadcast - mutex = Mutex.new - condvar = ConditionVariable.new + mutex = Thread::Mutex.new + condvar = Thread::ConditionVariable.new assert_nothing_raised(Exception) { mutex.synchronize {condvar.broadcast} } end def test_dup bug9440 = '[ruby-core:59961] [Bug #9440]' - condvar = ConditionVariable.new + condvar = Thread::ConditionVariable.new assert_raise(NoMethodError, bug9440) do condvar.dup end @@ -207,7 +207,7 @@ INPUT def test_dump bug9674 = '[ruby-core:61677] [Bug #9674]' - condvar = ConditionVariable.new + condvar = Thread::ConditionVariable.new assert_raise_with_message(TypeError, /#{ConditionVariable}/, bug9674) do Marshal.dump(condvar) end @@ -219,8 +219,8 @@ INPUT end def test_condvar_fork - mutex = Mutex.new - condvar = ConditionVariable.new + mutex = Thread::Mutex.new + condvar = Thread::ConditionVariable.new thrs = (1..10).map do Thread.new { mutex.synchronize { condvar.wait(mutex) } } end diff --git a/test/ruby/test_thread_queue.rb b/test/ruby/test_thread_queue.rb index 6185abff9f..3fa0eae2c1 100644 --- a/test/ruby/test_thread_queue.rb +++ b/test/ruby/test_thread_queue.rb @@ -66,7 +66,7 @@ class TestThreadQueue < Test::Unit::TestCase [e, "Enumerable"], [Struct.new(:to_a), "Array-like"], ) do |a, type| - q = Queue.new(a.new([1,2,3])) + q = Thread::Queue.new(a.new([1,2,3])) assert_equal(3, q.size, type) assert_not_predicate(q, :empty?, type) assert_equal(1, q.pop, type) @@ -77,14 +77,14 @@ class TestThreadQueue < Test::Unit::TestCase end def test_sized_queue_initialize - q = SizedQueue.new(1) + q = Thread::SizedQueue.new(1) assert_equal 1, q.max - assert_raise(ArgumentError) { SizedQueue.new(0) } - assert_raise(ArgumentError) { SizedQueue.new(-1) } + assert_raise(ArgumentError) { Thread::SizedQueue.new(0) } + assert_raise(ArgumentError) { Thread::SizedQueue.new(-1) } end def test_sized_queue_assign_max - q = SizedQueue.new(2) + q = Thread::SizedQueue.new(2) assert_equal(2, q.max) q.max = 1 assert_equal(1, q.max) @@ -104,7 +104,7 @@ class TestThreadQueue < Test::Unit::TestCase end def test_queue_pop_interrupt - q = Queue.new + q = Thread::Queue.new t1 = Thread.new { q.pop } sleep 0.01 until t1.stop? t1.kill.join @@ -112,14 +112,14 @@ class TestThreadQueue < Test::Unit::TestCase end def test_queue_pop_non_block - q = Queue.new + q = Thread::Queue.new assert_raise_with_message(ThreadError, /empty/) do q.pop(true) end end def test_sized_queue_pop_interrupt - q = SizedQueue.new(1) + q = Thread::SizedQueue.new(1) t1 = Thread.new { q.pop } sleep 0.01 until t1.stop? t1.kill.join @@ -127,14 +127,14 @@ class TestThreadQueue < Test::Unit::TestCase end def test_sized_queue_pop_non_block - q = SizedQueue.new(1) + q = Thread::SizedQueue.new(1) assert_raise_with_message(ThreadError, /empty/) do q.pop(true) end end def test_sized_queue_push_interrupt - q = SizedQueue.new(1) + q = Thread::SizedQueue.new(1) q.push(1) assert_raise_with_message(ThreadError, /full/) do q.push(2, true) @@ -142,7 +142,7 @@ class TestThreadQueue < Test::Unit::TestCase end def test_sized_queue_push_non_block - q = SizedQueue.new(1) + q = Thread::SizedQueue.new(1) q.push(1) t1 = Thread.new { q.push(2) } sleep 0.01 until t1.stop? @@ -159,7 +159,7 @@ class TestThreadQueue < Test::Unit::TestCase assert_normal_exit(<<-"_eom", bug5343, **{:timeout => timeout, :chdir=>d}) #{total_count}.times do |i| open("test_thr_kill_count", "w") {|f| f.puts i } - queue = Queue.new + queue = Thread::Queue.new r, w = IO.pipe th = Thread.start { queue.push(nil) @@ -178,20 +178,20 @@ class TestThreadQueue < Test::Unit::TestCase end def test_queue_push_return_value - q = Queue.new + q = Thread::Queue.new retval = q.push(1) assert_same q, retval end def test_queue_clear_return_value - q = Queue.new + q = Thread::Queue.new retval = q.clear assert_same q, retval end def test_sized_queue_clear - # Fill queue, then test that SizedQueue#clear wakes up all waiting threads - sq = SizedQueue.new(2) + # Fill queue, then test that Thread::SizedQueue#clear wakes up all waiting threads + sq = Thread::SizedQueue.new(2) 2.times { sq << 1 } t1 = Thread.new do @@ -212,19 +212,19 @@ class TestThreadQueue < Test::Unit::TestCase end def test_sized_queue_push_return_value - q = SizedQueue.new(1) + q = Thread::SizedQueue.new(1) retval = q.push(1) assert_same q, retval end def test_sized_queue_clear_return_value - q = SizedQueue.new(1) + q = Thread::SizedQueue.new(1) retval = q.clear assert_same q, retval end def test_sized_queue_throttle - q = SizedQueue.new(1) + q = Thread::SizedQueue.new(1) i = 0 consumer = Thread.new do while q.pop @@ -247,7 +247,7 @@ class TestThreadQueue < Test::Unit::TestCase end def test_queue_thread_raise - q = Queue.new + q = Thread::Queue.new th1 = Thread.new do begin q.pop @@ -277,7 +277,7 @@ class TestThreadQueue < Test::Unit::TestCase def test_dup bug9440 = '[ruby-core:59961] [Bug #9440]' - q = Queue.new + q = Thread::Queue.new assert_raise(NoMethodError, bug9440) do q.dup end @@ -287,12 +287,12 @@ class TestThreadQueue < Test::Unit::TestCase def test_dump bug9674 = '[ruby-core:61677] [Bug #9674]' - q = Queue.new + q = Thread::Queue.new assert_raise_with_message(TypeError, /#{Queue}/, bug9674) do Marshal.dump(q) end - sq = SizedQueue.new(1) + sq = Thread::SizedQueue.new(1) assert_raise_with_message(TypeError, /#{SizedQueue}/, bug9674) do Marshal.dump(sq) end @@ -304,7 +304,7 @@ class TestThreadQueue < Test::Unit::TestCase end def test_close - [->{Queue.new}, ->{SizedQueue.new 3}].each do |qcreate| + [->{Thread::Queue.new}, ->{Thread::SizedQueue.new 3}].each do |qcreate| q = qcreate.call assert_equal false, q.closed? q << :something @@ -343,15 +343,15 @@ class TestThreadQueue < Test::Unit::TestCase end def test_queue_close_wakeup - close_wakeup(15, 18){Queue.new} + close_wakeup(15, 18){Thread::Queue.new} end def test_size_queue_close_wakeup - close_wakeup(5, 8){SizedQueue.new 9} + close_wakeup(5, 8){Thread::SizedQueue.new 9} end def test_sized_queue_one_closed_interrupt - q = SizedQueue.new 1 + q = Thread::SizedQueue.new 1 q << :one t1 = Thread.new { Thread.current.report_on_exception = false @@ -368,7 +368,7 @@ class TestThreadQueue < Test::Unit::TestCase # make sure that shutdown state is handled properly by empty? for the non-blocking case def test_empty_non_blocking - q = SizedQueue.new 3 + q = Thread::SizedQueue.new 3 3.times{|i| q << i} # these all block cos the queue is full @@ -394,13 +394,13 @@ class TestThreadQueue < Test::Unit::TestCase end def test_sized_queue_closed_push_non_blocking - q = SizedQueue.new 7 + q = Thread::SizedQueue.new 7 q.close assert_raise_with_message(ClosedQueueError, /queue closed/){q.push(non_block=true)} end def test_blocked_pushers - q = SizedQueue.new 3 + q = Thread::SizedQueue.new 3 prod_threads = 6.times.map do |i| thr = Thread.new{ Thread.current.report_on_exception = false @@ -446,9 +446,9 @@ class TestThreadQueue < Test::Unit::TestCase end def test_deny_pushers - [->{Queue.new}, ->{SizedQueue.new 3}].each do |qcreate| + [->{Thread::Queue.new}, ->{Thread::SizedQueue.new 3}].each do |qcreate| q = qcreate[] - synq = Queue.new + synq = Thread::Queue.new prod_threads = 20.times.map do |i| Thread.new { synq.pop @@ -466,7 +466,7 @@ class TestThreadQueue < Test::Unit::TestCase # size should account for waiting pushers during shutdown def sized_queue_size_close - q = SizedQueue.new 4 + q = Thread::SizedQueue.new 4 4.times{|i| q << i} Thread.new{ q << 5 } Thread.new{ q << 6 } @@ -478,7 +478,7 @@ class TestThreadQueue < Test::Unit::TestCase end def test_blocked_pushers_empty - q = SizedQueue.new 3 + q = Thread::SizedQueue.new 3 prod_threads = 6.times.map do |i| Thread.new{ Thread.current.report_on_exception = false @@ -510,14 +510,14 @@ class TestThreadQueue < Test::Unit::TestCase # test thread wakeup on one-element SizedQueue with close def test_one_element_sized_queue - q = SizedQueue.new 1 + q = Thread::SizedQueue.new 1 t = Thread.new{ q.pop } q.close assert_nil t.value end def test_close_twice - [->{Queue.new}, ->{SizedQueue.new 3}].each do |qcreate| + [->{Thread::Queue.new}, ->{Thread::SizedQueue.new 3}].each do |qcreate| q = qcreate[] q.close assert_nothing_raised(ClosedQueueError){q.close} @@ -525,7 +525,7 @@ class TestThreadQueue < Test::Unit::TestCase end def test_queue_close_multi_multi - q = SizedQueue.new rand(800..1200) + q = Thread::SizedQueue.new rand(800..1200) count_items = rand(3000..5000) count_producers = rand(10..20) @@ -587,7 +587,7 @@ class TestThreadQueue < Test::Unit::TestCase end assert_in_out_err([], <<-INPUT, %w(INT INT exit), []) - q = Queue.new + q = Thread::Queue.new trap(:INT){ q.push 'INT' } @@ -604,8 +604,8 @@ class TestThreadQueue < Test::Unit::TestCase end def test_fork_while_queue_waiting - q = Queue.new - sq = SizedQueue.new(1) + q = Thread::Queue.new + sq = Thread::SizedQueue.new(1) thq = Thread.new { q.pop } thsq = Thread.new { sq.pop } Thread.pass until thq.stop? && thsq.stop? |