Assert.xs

filter: Statementstmt 91.6% 22 / 24 Branchbran 70.8% 17 / 24 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 81.2% 39 / 48 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« blib/lib/Devel/Assert.pm ↑ Summary blib/lib/Devel/Assert/Global.pm »
1 #define PERL_NO_GET_CONTEXT
2  
3 #include "EXTERN.h"
4 #include "perl.h"
5 #include "XSUB.h"
6  
7 #ifndef OpSIBLING
8 #define OpSIBLING(o) ((o)->op_sibling)
9 #endif
10  
11 STATIC OP*
12 4 assert_checker(pTHX_ OP *op, GV *namegv, SV *ckobj) {
13 4 op_free(op);
14 4 return newOP(OP_NULL, 0);
15 }
16  
17 STATIC CV*
18 12 find_context_cv(pTHX) {
19 PERL_CONTEXT* cx;
20 14 ▶ for (cx = cxstack + cxstack_ix; cx >= cxstack; --cx) {
Branch: 1 branch
BranchTrueFalseTotal
for (cx = cxstack + cxstack_ix; cx >= cxstack; --cx) { 13 1 14
21 13 ▶ if (CxTYPE(cx) == CXt_SUB || CxTYPE(cx) == CXt_FORMAT) return cx->blk_sub.cv;
Branch: 2 branches
BranchTrueFalseTotal
if (CxTYPE(cx) == CXt_SUB || CxTYPE(cx) == CXt_FORMAT) return cx->blk_sub.cv; 4 9 13
if (CxTYPE(cx) == CXt_SUB || CxTYPE(cx) == CXt_FORMAT) return cx->blk_sub.cv; 0 4 4
22 4 ▶ if (CxTYPE(cx) == CXt_EVAL && cx->blk_eval.cv) return cx->blk_eval.cv;
Branch: 2 branches
BranchTrueFalseTotal
if (CxTYPE(cx) == CXt_EVAL && cx->blk_eval.cv) return cx->blk_eval.cv; 3 1 4
if (CxTYPE(cx) == CXt_EVAL && cx->blk_eval.cv) return cx->blk_eval.cv; 2 1 3
23 }
24  
25 1 return PL_main_cv;
26 }
27  
28 MODULE = Devel::Assert PACKAGE = Devel::Assert
29 PROTOTYPES: DISABLE
30  
31 BOOT:
32 {
33 7 CV* assert_cv = get_cv("Devel::Assert::assert_off", 0);
34 7 cv_set_call_checker(assert_cv, assert_checker, (SV*)assert_cv);
35 }
36  
37 void
38 assert_on(...)
39 PPCODE:
40 {
41 19 ▶ if (items != 1) croak("Wrong number of arguments in assert() call");
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) croak("Wrong number of arguments in assert() call"); 1 18 19
42 18 ▶ if (SvTRUE(ST(0))) XSRETURN_UNDEF;
Branch: 1 branch
BranchTrueFalseTotal
if (SvTRUE(ST(0))) XSRETURN_UNDEF; 6 12 18
43  
44 12 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 12 12
45 12 ▶ EXTEND(SP, 3);
Branch: 1 branch
BranchTrueFalseTotal
EXTEND(SP, 3); 0 12 12
46  
47 /* B.xs declares 'make_*_object' as static, so had to borrow it */
48 #define push_b_object(type, ptr) STMT_START { \
49 SV* tmpsv = sv_newmortal(); \
50 sv_setiv(newSVrv(tmpsv, type), PTR2IV(ptr));\
51 PUSHs(tmpsv); \
52 } STMT_END
53  
54 12 OP* o = cUNOP->op_first;
55 12 ▶ OP* kid = OpSIBLING(o);
Branch: 1 branch
BranchTrueFalseTotal
OP* kid = OpSIBLING(o); 0 12 12
56 12 ▶ if (!kid || kid->op_type == OP_NULL) o = cUNOPo->op_first;
Branch: 2 branches
BranchTrueFalseTotal
if (!kid || kid->op_type == OP_NULL) o = cUNOPo->op_first; 0 12 12
if (!kid || kid->op_type == OP_NULL) o = cUNOPo->op_first; 0 0 0
57 12 push_b_object("B::UNOP", o);
58  
59 12 push_b_object("B::COP", PL_curcop);
60 12 push_b_object("B::CV", find_context_cv(aTHX));
61  
62 12 PUTBACK;
63 12 call_sv((SV*)get_cv("Devel::Assert::assert_fail", 0), G_VOID);
64 0 SPAGAIN;
65  
66 0 XSRETURN_UNDEF;
67 }
68  
« blib/lib/Devel/Assert.pm ↑ Summary blib/lib/Devel/Assert/Global.pm »