Skip to content

Commit

Permalink
better tests for Mojo::IOLoop::Delay
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Apr 4, 2013
1 parent 0cb328d commit 14fafc6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/Mojo/IOLoop/Delay.pm
Expand Up @@ -118,7 +118,7 @@ emit the following new ones.
...
});
Emitted once the active event counter reaches zero or there are no more steps.
Emitted once the active event counter reaches zero.
=head1 ATTRIBUTES
Expand Down
10 changes: 6 additions & 4 deletions t/mojo/delay.t
Expand Up @@ -79,21 +79,23 @@ is $finished, 1, 'finish event has been emitted once';
is $result, 'success', 'right result';

# End chain after second step
my $remaining;
($finished, $result) = ();
$delay = Mojo::IOLoop::Delay->new;
$delay->on(finish => sub { $finished++ });
$delay->steps(
sub { Mojo::IOLoop->timer(0 => shift->begin) },
sub {
$result = 'success';
shift->begin->();
$result = 'success';
$remaining = shift->begin->();
},
sub { $result = 'fail' },
sub { $result = 'fail' }
);
$delay->wait;
is $finished, 1, 'finish event has been emitted once';
is $result, 'success', 'right result';
is $remaining, 0, 'none remaining';
is $finished, 1, 'finish event has been emitted once';
is $result, 'success', 'right result';

# Finish steps with event
$result = undef;
Expand Down

0 comments on commit 14fafc6

Please sign in to comment.