Branch Coverage

src/future.c
Criterion Covered Total %
branch 4 626 0.6


line true false branch
126 0 0 if(!SvROK(sv) || !SvOBJECT(SvRV(sv)))
0 0 if(!SvROK(sv) || !SvOBJECT(SvRV(sv)))
129 0 0 if(sv_derived_from(sv, "Future") || sv_derived_from(sv, "Future::XS"))
0 0 if(sv_derived_from(sv, "Future") || sv_derived_from(sv, "Future::XS"))
143 0 0 if(self || nullok)
0 0 if(self || nullok)
150 0 0 if(!cls)
162 0 0 if(capture_times)
169 0 0 if(future_debug)
170 0 0 self->constructed_at = newSVpvf("constructed at %s line %d", CopFILE(PL_curcop), CopLINE(PL_curcop));
211 0 0 EXTEND(SP, 1);
212 0 0 PUSHMARK(SP);
223 0 0 FREETMPS;
247 0 0 if(flags & CB_SEQ_ANY) {
254 0 0 SvREFCNT_dec(CB_NONSEQ_CODE(cb));
262 0 0 while(callbacksav && AvFILLp(callbacksav) > -1) {
0 0 while(callbacksav && AvFILLp(callbacksav) > -1) {
275 0 0 if(self->label)
277 0 0 if(future_debug)
297 0 0 if(!f || !SvROK(f))
0 0 if(!f || !SvROK(f))
300 0 0 if(!self)
303 0 0 if(future_debug &&
304 0 0 (!self->ready || (self->failure && !self->reported))) {
0 0 (!self->ready || (self->failure && !self->reported))) {
0 0 (!self->ready || (self->failure && !self->reported))) {
305 0 0 if(!self->ready)
306 0 0 warn("%" SVf " was lost near %s line %d before it was ready\n",
311 0 0 warn("%" SVf " was lost near %s line %d with an unreported failure of: %" SVf "\n",
330 0 0 while(revocationsav && AvFILLp(revocationsav) > -1) {
0 0 while(revocationsav && AvFILLp(revocationsav) > -1) {
361 0 0 return self->ready && !self->failure && !self->cancelled;
0 0 return self->ready && !self->failure && !self->cancelled;
0 0 return self->ready && !self->failure && !self->cancelled;
367 0 0 return self->ready && self->failure;
0 0 return self->ready && self->failure;
379 0 0 if(!self->on_cancel)
395 0 0 if(cb->flags & CB_SEQ_ANY) {
402 0 0 new->code = CB_NONSEQ_CODE(cb);
405 0 0 if(!self->callbacks)
420 0 0 EXTEND(SP, 3);
421 0 0 PUSHMARK(SP);
433 0 0 FREETMPS;
445 0 0 bool is_done = !self->cancelled && !is_fail;
0 0 bool is_done = !self->cancelled && !is_fail;
447 0 0 AV *result = (is_done) ? self->result :
448 0 0 (is_fail) ? self->failure :
451 0 0 SV *code = (is_done) ? cb->seq.thencode :
452 0 0 (is_fail) ? cb->seq.elsecode :
455 0 0 if(is_fail && result && av_count(result) > 1 && cb->seq.catches) {
0 0 if(is_fail && result && av_count(result) > 1 && cb->seq.catches) {
0 0 if(is_fail && result && av_count(result) > 1 && cb->seq.catches) {
0 0 if(is_fail && result && av_count(result) > 1 && cb->seq.catches) {
457 0 0 if(SvOK(category)) {
459 0 0 if(he && HeVAL(he))
0 0 if(he && HeVAL(he))
464 0 0 if(!code || !SvOK(code))
0 0 if(!code || !SvOK(code))
472 0 0 PUSHMARK(SP);
473 0 0 if(flags & CB_SELF)
474 0 0 XPUSHs(selfsv);
475 0 0 if(flags & CB_RESULT)
476 0 0 XPUSHs_from_AV(result);
0 0 XPUSHs_from_AV(result);
0 0 XPUSHs_from_AV(result);
0 0 XPUSHs_from_AV(result);
0 0 XPUSHs_from_AV(result);
0 0 XPUSHs_from_AV(result);
0 0 XPUSHs_from_AV(result);
484 0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
0 0 if(SvROK(ERRSV) || SvTRUE(ERRSV)) {
489 0 0 if(!fseq)
492 0 0 future_failv(fseq, &ERRSV, 1);
494 0 0 FREETMPS;
504 0 0 FREETMPS;
507 0 0 if(!sv_is_future(f2)) {
526 0 0 bool is_done = !is_cancelled && !is_fail;
0 0 bool is_done = !is_cancelled && !is_fail;
528 0 0 AV *result = (is_done) ? self->result :
529 0 0 (is_fail) ? self->failure :
532 0 0 if(is_done && !(flags & CB_DONE))
0 0 if(is_done && !(flags & CB_DONE))
534 0 0 if(is_fail && !(flags & CB_FAIL))
0 0 if(is_fail && !(flags & CB_FAIL))
536 0 0 if(is_cancelled && !(flags & CB_CANCEL))
0 0 if(is_cancelled && !(flags & CB_CANCEL))
539 0 0 if(flags & CB_IS_FUTURE) {
545 0 0 PUSHMARK(SP);
546 0 0 XPUSHs(CB_NONSEQ_CODE(cb)); // really a Future RV
0 0 XPUSHs(CB_NONSEQ_CODE(cb)); // really a Future RV
547 0 0 if(result)
548 0 0 XPUSHs_from_AV(result);
0 0 XPUSHs_from_AV(result);
0 0 XPUSHs_from_AV(result);
0 0 XPUSHs_from_AV(result);
0 0 XPUSHs_from_AV(result);
0 0 XPUSHs_from_AV(result);
0 0 XPUSHs_from_AV(result);
551 0 0 if(is_done)
553 0 0 else if(is_fail)
558 0 0 FREETMPS;
561 0 0 else if(flags & CB_SEQ_ANY) {
564 0 0 if(!SvOK(fseq)) {
571 0 0 if(f2 == fseq)
577 0 0 if(future_is_ready(f2)) {
578 0 0 if(!future_is_cancelled(f2))
580 0 0 else if(flags & CB_CANCEL)
596 0 0 SV *code = CB_NONSEQ_CODE(cb);
603 0 0 PUSHMARK(SP);
604 0 0 if(flags & CB_SELF)
605 0 0 XPUSHs(selfsv);
606 0 0 if((flags & CB_RESULT) && result)
0 0 if((flags & CB_RESULT) && result)
607 0 0 XPUSHs_from_AV(result);
0 0 XPUSHs_from_AV(result);
0 0 XPUSHs_from_AV(result);
0 0 XPUSHs_from_AV(result);
0 0 XPUSHs_from_AV(result);
0 0 XPUSHs_from_AV(result);
0 0 XPUSHs_from_AV(result);
613 0 0 FREETMPS;
621 0 0 if(rev->toclear_sv_at && SvROK(rev->toclear_sv_at)) {
0 0 if(rev->toclear_sv_at && SvROK(rev->toclear_sv_at)) {
629 0 0 if(!SvOK(rev->precedent_f))
637 0 0 if(self->empty_revocation_slots >= 8 && on_cancel &&
0 0 if(self->empty_revocation_slots >= 8 && on_cancel &&
0 0 if(self->empty_revocation_slots >= 8 && on_cancel &&
638 0 0 self->empty_revocation_slots >= AvFILL(on_cancel)/2) {
643 0 0 **end = AvARRAY(on_cancel) + AvFILL(on_cancel);
645 0 0 while(rdsv <= end) {
646 0 0 if(SvOK(*rdsv))
666 0 0 if(capture_times)
673 0 0 if(self->precedent_f) {
679 0 0 if(self->revoke_when_ready) {
681 0 0 for(size_t i = 0; i < av_count(revocations); i++) {
694 0 0 if(!self->callbacks)
701 0 0 for(i = 0; i < n; i++) {
716 0 0 if(self->ready) {
725 0 0 if(cb->flags & CB_SEQ_CANCEL)
729 0 0 if(cb->seq.thencode)
731 0 0 if(cb->seq.elsecode)
744 0 0 if(!CvANON(cv)) {
750 0 0 while(cop && OP_CLASS(cop) != OA_COP)
0 0 while(cop && OP_CLASS(cop) != OA_COP)
0 0 while(cop && OP_CLASS(cop) != OA_COP)
0 0 while(cop && OP_CLASS(cop) != OA_COP)
753 0 0 if(!cop)
756 0 0 return newSVpvf("__ANON__(%s line %d)", CopFILE((COP *)cop), CopLINE((COP *)cop));
761 0 0 if(!self->ready)
763 0 0 if(self->cancelled)
765 0 0 if(self->failure)
775 0 0 if(self->cancelled)
778 0 0 if(self->ready)
791 0 0 if(self->cancelled)
794 0 0 if(self->ready)
798 0 0 if(n == 1 &&
799 0 0 SvROK(svp[0]) && SvOBJECT(SvRV(svp[0])) &&
810 0 0 EXTEND(SP, 1);
811 0 0 PUSHMARK(SP);
822 0 0 FREETMPS;
830 0 0 EXTEND(SP, 1);
831 0 0 PUSHMARK(SP);
842 0 0 FREETMPS;
850 0 0 EXTEND(SP, 1);
851 0 0 PUSHMARK(SP);
861 0 0 for(SSize_t i = 0; i < count; i++)
866 0 0 FREETMPS;
882 0 0 if(self->cancelled)
885 0 0 if(self->ready)
898 0 0 if(self->ready)
904 0 0 if(!self->on_cancel)
910 0 0 if(is_future) {
918 0 0 if(!codeself->revoke_when_ready)
933 0 0 if(is_future)
941 0 0 if(self->ready)
957 0 0 if(is_future)
965 0 0 if(self->ready)
981 0 0 if(is_future)
989 0 0 if(self->ready)
1005 0 0 PUSHMARK(SP);
1006 0 0 mXPUSHs(newSVsv(f));
1011 0 0 FREETMPS;
1019 0 0 if(await && !self->ready)
0 0 if(await && !self->ready)
1022 0 0 if(!self->ready)
1025 0 0 if(self->failure) {
1029 0 0 if(av_count(self->failure) > 1) {
1034 0 0 PUSHMARK(SP);
1035 0 0 EXTEND(SP, 1 + av_count(self->failure));
1037 0 0 for(SSize_t i = 0; i < av_count(self->failure); i++)
1048 0 0 FREETMPS;
1054 0 0 if(SvROK(exception) || SvPV_nolen(exception)[SvCUR(exception)-1] == '\n')
0 0 if(SvROK(exception) || SvPV_nolen(exception)[SvCUR(exception)-1] == '\n')
1062 0 0 for(cxix = cxstack_ix; cxix; cxix--) {
1063 0 0 if(CxTYPE(&cxstack[cxix]) != CXt_SUB)
1067 0 0 if(!cv)
1070 0 0 const char *stashname = HvNAME(CvSTASH(cv));
0 0 const char *stashname = HvNAME(CvSTASH(cv));
0 0 const char *stashname = HvNAME(CvSTASH(cv));
0 0 const char *stashname = HvNAME(CvSTASH(cv));
0 0 const char *stashname = HvNAME(CvSTASH(cv));
0 0 const char *stashname = HvNAME(CvSTASH(cv));
1071 0 0 if(!stashname)
1075 0 0 if(strEQ(stashname, "Future::_base"))
1078 0 0 const COP *cop = cxix < cxstack_ix ? cxstack[cxix+1].blk_oldcop : PL_curcop;
1080 0 0 sv_catpvf(exception, " at %s line %d.\n", CopFILE(cop), CopLINE(cop));
1088 0 0 if(self->cancelled)
1092 0 0 if(!self->result)
1102 0 0 if(!self->ready)
1105 0 0 if(!self->failure)
1117 0 0 if(!self)
1120 0 0 if(self->ready)
1126 0 0 if(self->subs) {
1127 0 0 for(Size_t i = 0; i < av_count(self->subs); i++) {
1129 0 0 if(!(flags & SUBFLAG_NO_CANCEL))
1137 0 0 for(int i = on_cancel ? AvFILL(on_cancel) : -1; i >= 0; i--) {
0 0 for(int i = on_cancel ? AvFILL(on_cancel) : -1; i >= 0; i--) {
0 0 for(int i = on_cancel ? AvFILL(on_cancel) : -1; i >= 0; i--) {
1139 0 0 if(!SvOK(code))
1142 0 0 if(sv_is_future(code)) {
1148 0 0 PUSHMARK(SP);
1154 0 0 FREETMPS;
1163 0 0 PUSHMARK(SP);
1170 0 0 FREETMPS;
1200 0 0 if(flags & FUTURE_THEN_WITH_F)
1225 0 0 if(flags & FUTURE_THEN_WITH_F)
1241 0 0 for(Size_t i = 0; i < n; i++) {
1242 0 0 if(!SvROK(subs[i]) && SvPOK(subs[i]) && strEQ(SvPVX(subs[i]), "also"))
0 0 if(!SvROK(subs[i]) && SvPOK(subs[i]) && strEQ(SvPVX(subs[i]), "also"))
0 0 if(!SvROK(subs[i]) && SvPOK(subs[i]) && strEQ(SvPVX(subs[i]), "also"))
1245 0 0 if(!SvROK(subs[i]) || !SvOBJECT(SvRV(subs[i])))
0 0 if(!SvROK(subs[i]) || !SvOBJECT(SvRV(subs[i])))
1250 0 0 if(!proto && SvSTASH(SvRV(subs[i])) != future_stash)
0 0 if(!proto && SvSTASH(SvRV(subs[i])) != future_stash)
1254 0 0 SV *f = proto ? future_new_proto(proto) : future_new(cls);
1257 0 0 if(!self->subs)
1260 0 0 if(!self->subflags)
1263 0 0 for(Size_t i = 0, subi = 0; i < n; i++, subi++) {
1265 0 0 if(!SvROK(subs[i]) && SvPOK(subs[i]) && strEQ(SvPVX(subs[i]), "also"))
0 0 if(!SvROK(subs[i]) && SvPOK(subs[i]) && strEQ(SvPVX(subs[i]), "also"))
0 0 if(!SvROK(subs[i]) && SvPOK(subs[i]) && strEQ(SvPVX(subs[i]), "also"))
1284 0 0 if(srcself->failure) {
1296 0 0 if(!self->subs)
1299 0 0 for(Size_t i = 0; i < av_count(self->subs); i++) {
1303 0 0 if(!(flags & SUBFLAG_NO_CANCEL) && !future_is_ready(sub))
0 0 if(!(flags & SUBFLAG_NO_CANCEL) && !future_is_ready(sub))
1313 0 0 if(!SvOK(f))
1324 0 0 if(self->pending_subs)
1342 0 0 for(Size_t i = 0; i < n; i++) {
1344 0 0 if(!future_is_ready(subs[i]))
1348 0 0 if(!self->pending_subs) {
1363 0 0 for(Size_t i = 0; i < n; i++) {
1364 0 0 if(!future_is_ready(subs[i]))
1379 0 0 if(!SvOK(f))
1388 0 0 if(self->result || self->failure)
0 0 if(self->result || self->failure)
1395 0 0 if(self->pending_subs && this_cancelled)
0 0 if(self->pending_subs && this_cancelled)
1398 0 0 if(this_cancelled) {
1419 0 0 if(!n) {
1425 0 0 for(Size_t i = 0; i < n; i++) {
1427 0 0 if(future_is_ready(subs[i]) && !future_is_cancelled(subs[i])) {
0 0 if(future_is_ready(subs[i]) && !future_is_cancelled(subs[i])) {
1433 0 0 if(immediate_ready) {
1453 0 0 for(Size_t i = 0; i < n; i++) {
1454 0 0 if(future_is_cancelled(subs[i]))
1470 0 0 for(Size_t i = 0; i < av_count(self->subs); i++) {
1484 0 0 if(!SvOK(f))
1493 0 0 if(self->result || self->failure)
0 0 if(self->result || self->failure)
1496 0 0 if(future_is_cancelled(thissub)) {
1501 0 0 else if(future_is_failed(thissub)) {
1508 0 0 if(self->pending_subs)
1524 0 0 if(!n) {
1530 0 0 for(Size_t i = 0; i < n; i++) {
1531 0 0 if(future_is_cancelled(subs[i])) {
1536 0 0 if(future_is_failed(subs[i])) {
1542 0 0 if(immediate_fail) {
1559 0 0 for(Size_t i = 0; i < n; i++) {
1560 0 0 if(future_is_ready(subs[i]))
1567 0 0 if(!self->pending_subs) {
1583 0 0 if(!SvOK(f))
1592 0 0 if(self->result || self->failure)
0 0 if(self->result || self->failure)
1599 0 0 if(self->pending_subs && this_cancelled)
0 0 if(self->pending_subs && this_cancelled)
1602 0 0 if(this_cancelled) {
1605 0 0 else if(future_is_failed(thissub)) {
1606 0 0 if(self->pending_subs)
1628 0 0 if(!n) {
1634 0 0 for(Size_t i = 0; i < n; i++) {
1635 0 0 if(future_is_done(subs[i])) {
1641 0 0 if(immediate_done) {
1658 0 0 for(Size_t i = 0; i < n; i++) {
1659 0 0 if(future_is_ready(subs[i]))
1666 0 0 if(!self->pending_subs) {
1683 0 0 for(Size_t i = 0; self->subs && i < av_count(self->subs); i++) {
0 0 for(Size_t i = 0; self->subs && i < av_count(self->subs); i++) {
1709 0 0 if(want) {
1710 0 0 XPUSHs(sv_mortalcopy(sub));
1735 0 0 if(self->label)
1752 0 0 if(!self->udata)
1762 0 0 if(!self->udata)
1766 0 0 return he ? HeVAL(he) : &PL_sv_undef;
1853 0 6 if(!val || !val[0])
0 0 if(!val || !val[0])
1855 0 0 if(val[0] == '0' && strlen(val) == 1)
0 0 if(val[0] == '0' && strlen(val) == 1)
1868 3 0 capture_times = future_debug || getenv_bool("PERL_FUTURE_TIMES");
0 3 capture_times = future_debug || getenv_bool("PERL_FUTURE_TIMES");
1869 0 3 sv_setsv(get_sv("Future::TIMES", GV_ADDMULTI), capture_times ? &PL_sv_yes : &PL_sv_no);