Sha256: 223c65cb4ee003f6a084cfff8cdf8758527d418a56eec7ebb715af89fdca9fc5
Contents?: true
Size: 1.23 KB
Versions: 3
Compression:
Stored size: 1.23 KB
Contents
require File.expand_path(File.join(*%w[ .. helper ]), File.dirname(__FILE__)) class PigeonDispatcherTest < Minitest::Test def test_routine_dispatching dispatcher = Pigeon::Dispatcher.new assert_equal Pigeon::Dispatcher.thread_limit, dispatcher.thread_limit checks = { } count = 100 count.times do |n| dispatcher.perform do x = 0 1000.times do dispatcher.perform do x += 1 end end checks[n] = x end end assert_timeout(10) do dispatcher.wait! end assert_equal 0, dispatcher.backlog_size assert_equal 0, dispatcher.thread_count assert dispatcher.empty? assert_equal [ ], dispatcher.exceptions assert !dispatcher.exceptions? assert_equal (0..count - 1).to_a, checks.keys.sort end def test_dispatch_variants dispatcher = Pigeon::Dispatcher.new result = [ ] dispatcher.perform do result[0] = :a end dispatcher.perform(:b) do |b| result[1] = b end dispatcher.perform(:c, :d) do |c, d| result[2] = c result[3] = d end dispatcher.wait! assert_equal [ :a, :b, :c, :d ], result end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pigeon-1.0.2 | test/unit/pigeon_dispatcher_test.rb |
pigeon-1.0.1 | test/unit/pigeon_dispatcher_test.rb |
pigeon-1.0.0 | test/unit/pigeon_dispatcher_test.rb |