Sha256: 66859b504691fb8573058ea6afa437661cbd9ddafe585d1e6502cd35a3b66592
Contents?: true
Size: 1.24 KB
Versions: 4
Compression:
Stored size: 1.24 KB
Contents
require_relative '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 def test_big_queue EM.run do q = EM::Queue.new 2000.times do |i| q.push(*0..1000) q.pop { |v| assert_equal v, i % 1001 } end q.pop do assert_equal 1_999_999, q.size EM.stop end end end end
Version data entries
4 entries across 4 versions & 2 rubygems
Version | Path |
---|---|
eventmachine-mkroman-1.3.0.dev.1 | tests/test_queue.rb |
wj_eventmachine-1.3.2 | tests/test_queue.rb |
wj_eventmachine-1.3.1 | tests/test_queue.rb |
wj_eventmachine-1.3.0.dev.1 | tests/test_queue.rb |