Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add idle tests

  • Loading branch information...
commit d8b81b7e462c06427681bbfbfffa27b00d1006b9 1 parent 460f3db
@tadzik authored
Showing with 30 additions and 0 deletions.
  1. +30 −0 t/02-idle.t
View
30 t/02-idle.t
@@ -0,0 +1,30 @@
+use Test;
+use MuEvent;
+
+# all events sleep for 1 second, the first one is run after 2 seconds
+# (in 3rd second), the last one stops the program after 5,
+# so idle should run 3 times: 0th, 1st, 2nd and 4th second
+plan 5;
+
+my $start;
+
+MuEvent::timer(
+ after => 2,
+ cb => sub {
+ ok ($start + 2 <= time <= $start + 3), 'after 2';
+ sleep 1;
+ }
+);
+
+MuEvent::timer(
+ after => 5,
+ cb => sub {
+ ok ($start + 5 <= time <= $start + 6), 'after 5';
+ exit 0;
+ }
+);
+
+MuEvent::idle(cb => { pass 'idle'; sleep 1 });
+
+$start = time;
+MuEvent::run;

0 comments on commit d8b81b7

Please sign in to comment.
Something went wrong with that request. Please try again.