Sha256: 3f4e8e4053665bdc86048ee120c1683ebc1300a4478b18ab9559a50a6fc8c2dd
Contents?: true
Size: 1.05 KB
Versions: 1
Compression:
Stored size: 1.05 KB
Contents
# frozen_string_literal: true require_relative 'helper' class EventTest < MiniTest::Test def test_that_event_receives_signal_across_threads count = 0 a = Polyphony::Event.new spin { a.await count += 1 } snooze t = Thread.new do orig_sleep 0.001 a.signal end suspend assert_equal 1, count ensure t&.kill t&.join end def test_that_event_coalesces_signals count = 0 a = Polyphony::Event.new f = spin { loop { a.await count += 1 spin { f.stop } } } snooze t = Thread.new do orig_sleep 0.001 3.times { a.signal } end f.await assert_equal 1, count ensure t&.kill t&.join end def test_exception_while_waiting_for_event e = Polyphony::Event.new f = spin { e.await } g = spin { f.raise 'foo' } assert_raises(RuntimeError) do f.await end end def test_event_signal_before_await e = Polyphony::Event.new e.signal(:foo) assert_equal :foo, e.await end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
polyphony-1.6 | test/test_event.rb |