--- Coro/t/16_signal.t 2008/11/19 00:06:55 1.1 +++ Coro/t/16_signal.t 2009/06/24 02:52:38 1.3 @@ -1,5 +1,5 @@ $|=1; -print "1..7\n"; +print "1..18\n"; no warnings; use Coro; @@ -10,7 +10,7 @@ $as1 = async { my $g = $sig->wait; - print "ok 2\n"; + print "ok 3\n"; }; $as2 = async { @@ -18,39 +18,58 @@ print "ok 4\n"; }; - cede; - - $sig->send; + cede; # put 1, 2 in wait q $as3 = async { my $g = $sig->wait; - print "ok 5\n"; + print "ok 2\n"; }; - $sig->send; - $as4 = async { my $g = $sig->wait; print "ok 6\n"; }; - $sig->send; + $as5 = async { + my $g = $sig->wait; + print "ok 9\n"; + }; + + $sig->send; # ready 1 + $sig->send; # ready 2 + $sig->send; # remember print +(Coro::Semaphore::count $sig) == 1 ? "" : "not ", "ok 1\n"; - cede; + cede; # execute 3 (already ready, no contention), 1, 2 - print +(Coro::Semaphore::count $sig) == 0 ? "" : "not ", "ok 3\n"; + print +(Coro::Semaphore::count $sig) == 0 ? "" : "not ", "ok 5\n"; $sig->send; cede; - print +(Coro::Semaphore::count $sig) == 0 ? "" : "not ", "ok 5\n"; + print +(Coro::Semaphore::count $sig) == 0 ? "" : "not ", "ok 7\n"; $sig->broadcast; - print +(Coro::Semaphore::count $sig) == 0 ? "" : "not ", "ok 6\n"; + print +(Coro::Semaphore::count $sig) == 0 ? "" : "not ", "ok 8\n"; cede; - print +(Coro::Semaphore::count $sig) == 0 ? "" : "not ", "ok 7\n"; + $sig->wait (sub { print "ok 12\n" }); + print "ok 10\n"; + + print "ok 11\n"; + + $sig->send; + print "ok 13\n"; + cede; + + print "ok 14\n"; + $sig->send; + print "ok 15\n"; + + $sig->wait (sub { print "ok 16\n" }); + print "ok 17\n"; + + print +(Coro::Semaphore::count $sig) == 0 ? "" : "not ", "ok 18\n"; }