GX/Exception/StackTrace/Frame.pm

filter: Statementstmt 75.4% 40 / 53 Branchbran 66.6% 4 / 6 Conditioncond 50.0% 8 / 16 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 52.1% 12 / 23 Podpod 100% 4 / 4 totaltotal 61.8% 68 / 110 CC 12 SCAR 16.3
CC
12
Cov
69%
as_string
13.7
new
3.1
__ANON__
2.0
CRAP 5.1
« GX/Callback/Hook.pm ↑ Summary GX/Meta/Attribute/Bool.pm »
1 # ----------------------------------------------------------------------------------------------------------------------
2 # GX Framework (c) 2009-2011 Jörg A. Uzarek <uzarek@runlevelnull.de>
3 # File: GX/Exception/StackTrace/Frame.pm
4 # ----------------------------------------------------------------------------------------------------------------------
5  
6 package GX::Exception::StackTrace::Frame;
7  
8 306 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 306 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11  
12 # ----------------------------------------------------------------------------------------------------------------------
13 # Constants
14 # ----------------------------------------------------------------------------------------------------------------------
15  
16 306 ▶use constant FIELDS => qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
17 package
18 filename
19 line
20 subroutine
21 hasargs
22 wantarray
23 evaltext
24 is_require
25 hints
26 bitmask
27 hinthash
28 306 );
29  
30  
31 # ----------------------------------------------------------------------------------------------------------------------
32 # Overloading
33 # ----------------------------------------------------------------------------------------------------------------------
34  
35 use overload
36 13 ▶ 'bool' => sub { 1 },
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine __ANON__: called CC=1 SCAR=0.0
37 0 ▶ '0+' => sub { $_[0] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
38 0 ▶ '""' => sub { $_[0]->as_string },
Subroutine __ANON__: not called CC=1 SCAR=6.9
39 306 'fallback' => 1;
40  
41  
42 # ----------------------------------------------------------------------------------------------------------------------
43 # Constructor
44 # ----------------------------------------------------------------------------------------------------------------------
45  
46 4463 ▶sub new {
Subroutine new: called CC=3 SCAR=11.4
Pod documented
47  
48 4463 my $class = shift;
49  
50 4463 my $self = bless {}, $class;
51  
52 4463 ▶ if ( @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 4463 0 4463
53  
54 4463 ▶ if ( @_ != 12 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ != 12) 0 4463 4463
55 0 warn "Invalid number of arguments";
56 }
57  
58 4463 $self->{'level'} = shift;
59 4463 $self->{'info'} = [ @_ ];
60  
61 }
62  
63 4463 return $self;
64  
65 }
66  
67  
68 # ----------------------------------------------------------------------------------------------------------------------
69 # Caller info accessors
70 # ----------------------------------------------------------------------------------------------------------------------
71  
72 {
73  
74 306 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
75  
76 306 my $i = 0;
77  
78 306 for ( FIELDS ) {
79 0 ▶ *{ __PACKAGE__ . '::' . $_ } = eval "sub { \$_[0]->{'info'}[$i] }";
Subroutine __ANON__: not called CC=1 SCAR=2.1
Subroutine __ANON__: called CC=1 SCAR=2.1
Subroutine __ANON__: called CC=1 SCAR=2.1
Subroutine __ANON__: called CC=1 SCAR=2.1
Subroutine __ANON__: not called CC=1 SCAR=2.1
Subroutine __ANON__: not called CC=1 SCAR=2.1
Subroutine __ANON__: not called CC=1 SCAR=2.1
Subroutine __ANON__: not called CC=1 SCAR=2.1
Subroutine __ANON__: not called CC=1 SCAR=2.1
Subroutine __ANON__: not called CC=1 SCAR=2.1
Subroutine __ANON__: not called CC=1 SCAR=2.1
80 3366 $i++;
81 }
82  
83 }
84  
85  
86 # ----------------------------------------------------------------------------------------------------------------------
87 # Public methods
88 # ----------------------------------------------------------------------------------------------------------------------
89  
90 8 ▶sub as_string {
Subroutine as_string: called CC=10 SCAR=26.2
Pod documented
91  
92 8 my $self = shift;
93  
94 8 my $string;
95  
96 8 ▶ if ( $self->subroutine eq '(eval)' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->subroutine eq '(eval)') { } 2 6 8
97  
98 2 ▶ $string = sprintf(
Condition50%4/8
$self->level // "?"
l!l
20
$self->subroutine // "?"
l!l
20
$self->filename // "?"
l!l
20
$self->line // "?"
l!l
20
MC/DC0%0/1
$self->level // "?"
$self->level
MC/DC0%0/1
$self->subroutine // "?"
$self->subroutine
MC/DC0%0/1
$self->filename // "?"
$self->filename
MC/DC0%0/1
$self->line // "?"
$self->line
Truth table50%1/2
A
A= $self->level
Aresult
11
00
Truth table50%1/2
A
A= $self->subroutine
Aresult
11
00
Truth table50%1/2
A
A= $self->filename
Aresult
11
00
Truth table50%1/2
A
A= $self->line
Aresult
11
00
99 "[%s] %s at %s line %s",
100 $self->level // '?',
101 $self->subroutine // '?',
102 $self->filename // '?',
103 $self->line // '?'
104 );
105  
106 }
107 else {
108  
109 6 ▶ $string = sprintf(
Condition50%4/8
$self->level // "?"
l!l
60
$self->subroutine // "?"
l!l
60
$self->filename // "?"
l!l
60
$self->line // "?"
l!l
60
MC/DC0%0/1
$self->level // "?"
$self->level
MC/DC0%0/1
$self->subroutine // "?"
$self->subroutine
MC/DC0%0/1
$self->filename // "?"
$self->filename
MC/DC0%0/1
$self->line // "?"
$self->line
Truth table50%1/2
A
A= $self->level
Aresult
11
00
Truth table50%1/2
A
A= $self->subroutine
Aresult
11
00
Truth table50%1/2
A
A= $self->filename
Aresult
11
00
Truth table50%1/2
A
A= $self->line
Aresult
11
00
110 "[%s] %s called at %s line %s",
111 $self->level // '?',
112 $self->subroutine // '?',
113 $self->filename // '?',
114 $self->line // '?'
115 );
116  
117 }
118  
119 8 return $string;
120  
121 }
122  
123 0 ▶sub info {
Subroutine info: not called CC=1 SCAR=6.9
Pod documented
124  
125 0 return @{$_[0]->{'info'}};
126  
127 }
128  
129 8 ▶sub level {
Subroutine level: called CC=1 SCAR=0.0
Pod documented
130  
131 8 return $_[0]->{'level'};
132  
133 }
134  
135  
136 306 1;
137  
138 __END__
« GX/Callback/Hook.pm ↑ Summary GX/Meta/Attribute/Bool.pm »