Skip Menu |
 
rt.cpan.org will be shut down on March 1st, 2021.

This queue is for tickets about the future CPAN distribution.

Report information
The Basics
Id: 100067
Status: resolved
Priority: 0/
Queue: future

People
Owner: Nobody in particular
Requestors: leonerd-cpan [...] leonerd.org.uk
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.29
Fixed in: 0.30



Subject: repeat does not capture failure of 'while' etc.. conditions
Download (untitled) / with headers
text/plain 490b
This correctly captures failure: my $f = repeat { die "I failed in body" } while => sub { 0 }; $f->failure and print STDERR "Future caught failure: " . $f->failure; output: Future caught failure: I failed in body at ... This doesn't: my $f = repeat { Future->done } while => sub { die "I failed in the while condition" }; $f->failure and print STDERR "Future caught failure: " . $f->failure; Output: I failed in the while condition at ... -- Paul Evans
Fixed in attached patch -- Paul Evans
Subject: rt100067.patch
Download rt100067.patch
text/x-diff 1.1k
=== modified file 'lib/Future/Utils.pm' --- lib/Future/Utils.pm 2014-07-17 11:21:45 +0000 +++ lib/Future/Utils.pm 2014-11-05 17:01:49 +0000 @@ -280,7 +280,14 @@ return $return; } - if( !$cond->( $trial ) ^ $sense ) { + my $stop; + if( not eval { $stop = !$cond->( $trial ) ^ $sense; 1 } ) { + $return ||= $trial->new; + $return->fail( $@ ); + return $return; + } + + if( $stop ) { # Return result $return ||= $trial->new; $trial->on_done( $return ); === modified file 't/32utils-repeat.t' --- t/32utils-repeat.t 2014-07-17 10:14:30 +0000 +++ t/32utils-repeat.t 2014-11-05 17:01:49 +0000 @@ -96,7 +96,7 @@ is( scalar $future->get, "four", '$future->get' ); } -# code dies +# body code dies { my $future; @@ -113,6 +113,15 @@ is( $future->failure, "It failed\n", 'repeat until failure after code exception' ); } +# condition code dies (RT100067) +{ + my $future = repeat { + Future->done(1); + } while => sub { die "it dies!\n" }; + + is( $future->failure, "it dies!\n", 'repeat while failure after condition exception' ); +} + # Non-Future return fails { my $future;
Released in 0.30 -- Paul Evans


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.