Sha256: 183b8193a6720c53912aa31cd8ce5ebc6bcbf7ae464296fc4d95300adc821d6f
Contents?: true
Size: 999 Bytes
Versions: 88
Compression:
Stored size: 999 Bytes
Contents
require 'em_test_helper' class TestEMQueue < Test::Unit::TestCase def test_queue_push s = 0 EM.run do q = EM::Queue.new q.push(1) EM.next_tick { s = q.size; EM.stop } end assert_equal 1, s end def test_queue_pop x,y,z = nil EM.run do q = EM::Queue.new q.push(1,2,3) q.pop { |v| x = v } q.pop { |v| y = v } q.pop { |v| z = v; EM.stop } end assert_equal 1, x assert_equal 2, y assert_equal 3, z end def test_queue_reactor_thread q = EM::Queue.new Thread.new { q.push(1,2,3) }.join assert q.empty? EM.run { EM.next_tick { EM.stop } } assert_equal 3, q.size x = nil Thread.new { q.pop { |v| x = v } }.join assert_equal nil, x EM.run { EM.next_tick { EM.stop } } assert_equal 1, x end def test_num_waiting q = EM::Queue.new many = 3 many.times { q.pop {} } EM.run { EM.next_tick { EM.stop } } assert_equal many, q.num_waiting end end
Version data entries
88 entries across 88 versions & 6 rubygems