Sha256: 6bb2609177dd7b6a749845f79b45d3006b0540b03207a4da6daf705662615fa6

Contents?: true

Size: 695 Bytes

Versions: 3

Compression:

Stored size: 695 Bytes

Contents

# frozen_string_literal: true

require_relative 'helper'

class AsyncTest < MiniTest::Test
  def test_that_async_watcher_receives_signal_across_threads
    count = 0
    a = Gyro::Async.new
    spin {
      a.await
      count += 1
    }
    snooze
    Thread.new do
      orig_sleep 0.001
      a.signal
    end
    suspend
    assert_equal 1, count
  end

  def test_that_async_watcher_coalesces_signals
    count = 0
    a = Gyro::Async.new
    coproc = spin {
      loop {
        a.await
        count += 1
        spin { coproc.stop }
      }
    }
    snooze
    Thread.new do
      orig_sleep 0.001
      3.times { a.signal }
    end
    coproc.await
    assert_equal 1, count
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
polyphony-0.39 test/test_async.rb
polyphony-0.38 test/test_async.rb
polyphony-0.36 test/test_async.rb