Sha256: c6318ffdad7a158eaed3526842c753066d4b84162fc5dba1f5b262f680ac660c
Contents?: true
Size: 1.18 KB
Versions: 3
Compression:
Stored size: 1.18 KB
Contents
require 'libuv' describe Libuv::Async do before :each do @log = [] @general_failure = [] @loop = Libuv::Loop.new @call = @loop.pipe @timeout = @loop.timer do @loop.stop @general_failure << "test timed out" end @timeout.start(5000) @loop.all(@server, @client, @timeout).catch do |reason| @general_failure << reason.inspect p "Failed with: #{reason.message}\n#{reason.backtrace.join("\n")}\n" end end it "Should call the async function from the thread pool stopping the counter" do @loop.run { |logger| logger.progress do |level, errorid, error| begin p "Log called: #{level}: #{errorid}\n#{error.message}\n#{error.backtrace.join("\n")}\n" rescue Exception p 'error in logger' end end @count = 0 timer = @loop.timer do @count += 1 end timer.start(0, 200) callback = @loop.async do stopper = @loop.timer do timer.close callback.close stopper.close @loop.stop end stopper.start(1000) end @loop.work(proc { callback.call }).catch do |err| @general_failure << err end } expect(@general_failure).to eq([]) expect(@count < 7 && @count > 3).to eq(true) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
libuv-0.11.19 | spec/async_spec.rb |
libuv-0.11.18 | spec/async_spec.rb |
libuv-0.11.7 | spec/async_spec.rb |