Navigation Menu

Skip to content

Commit

Permalink
more tests for single step delay
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Apr 27, 2014
1 parent 7f55448 commit 39d3585
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 0 additions & 1 deletion lib/Mojo/IOLoop/Delay.pm
Expand Up @@ -245,7 +245,6 @@ gets emitted, only works when L</"ioloop"> is not running already.
my ($delay, @args) = @_;
...
});
Mojo::IOLoop->timer($_ => $delay->begin) for 1 .. 10;
$delay->wait unless $delay->ioloop->is_running;
=head1 SEE ALSO
Expand Down
10 changes: 10 additions & 0 deletions t/mojo/delay.t
Expand Up @@ -107,6 +107,16 @@ is $result, undef, 'no result';
$delay->wait;
is $result, 1, 'right result';

# One step (reverse)
$result = undef;
$delay = Mojo::IOLoop::Delay->new;
$end = $delay->begin(0);
Mojo::IOLoop->next_tick(sub { $end->(23) });
$delay->steps(sub { $result = pop });
is $result, undef, 'no result';
$delay->wait;
is $result, 23, 'right result';

# End chain after first step
($finished, $result) = ();
$delay = Mojo::IOLoop::Delay->new;
Expand Down

0 comments on commit 39d3585

Please sign in to comment.