Permalink
Browse files

Add basic test for condvar

  • Loading branch information...
1 parent 8136ac5 commit fa7367d2cbf7db95e5779437fd89261045fb7b39 @am0c am0c committed Oct 30, 2012
Showing with 26 additions and 0 deletions.
  1. +26 −0 t/04-condvar.t
View
@@ -0,0 +1,26 @@
+use Test;
+use MuEvent;
+
+plan 5;
+
+my $start = time;
+my $plan = 1;
+
+{
+ my $cv = MuEvent::condvar;
+ ok $cv.send( "foo" ), "send";
+ ok $cv.recv ~~ "foo", "recv";
+}
+
+{
+ my $cv = MuEvent::condvar;
+
+ MuEvent::timer(after => 2, cb => sub {
+ ok $plan++ == 2 && $start+1 <= time <= $start+3, "timer occured";
+ $cv.send;
+ });
+
+ ok $plan++ == 1 && time - $start < 1, "not block timer";
+ $cv.recv;
+ ok $plan++ == 3 && $start+1 <= time <= $start+3, "received blocked";
+}

0 comments on commit fa7367d

Please sign in to comment.