Subject: | needs_all() throws an exception when immediate failed subfutures are given |
Future->needs_all(@subfutures) method throws an exception when
immediate failed Futures are included in @subfutures.
Future->needs_all() should accept immediate failed subfutures without
exceptions.
I ran the following test:
use strict;
use warnings;
use Test::More;
use Future 0.11;
foreach my $method (qw(wait_all wait_any needs_all needs_any)) {
foreach my $done_first (0,1) {
my $msg = "$method, done_first = $done_first";
my @done_subs = map { Future->new->done($_) } 1..5;
my @fail_subs = map { Future->new->fail("failure $_") } 1..5;
my @subs = $done_first
? (@done_subs, @fail_subs)
: (@fail_subs, @done_subs);
my $f = eval {
Future->$method(@subs);
pass($msg);
};
if($@) {
fail($msg);
diag("Exception: $@");
}
}
}
done_testing();
Then the result was:
ok 1 - wait_all, done_first = 0
ok 2 - wait_all, done_first = 1
ok 3 - wait_any, done_first = 0
ok 4 - wait_any, done_first = 1
not ok 5 - needs_all, done_first = 0
# Failed test 'needs_all, done_first = 0'
# at test.pl line 19.
# Exception: failure 1 at test.pl line 15.
not ok 6 - needs_all, done_first = 1
# Failed test 'needs_all, done_first = 1'
# at test.pl line 19.
# Exception: failure 1 at test.pl line 15.
ok 7 - needs_any, done_first = 0
ok 8 - needs_any, done_first = 1
1..8
# Looks like you failed 2 tests of 8.