Harness/Compatible/Point.pm

filter: Statementstmt 10.2% 8 / 78 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 8.7% 2 / 23 Podpod 100% 21 / 21 totaltotal 19.7% 31 / 157 CC 13 SCAR 22.1
CC
13
Cov
8%
from_test_line
30.0
pass
20.0
set_ok
6.0
CRAP 9.1
« Parser/YAML.pm ↑ Summary Parser.pm »
1 # -*- Mode: cperl; cperl-indent-level: 4 -*-
2 package TAPx::Harness::Compatible::Point;
3  
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 $VERSION = '0.50_07';
7  
8 =head1 NAME
9  
10 TAPx::Harness::Compatible::Point - object for tracking a single test point
11  
12 =head1 SYNOPSIS
13  
14 One TAPx::Harness::Compatible::Point object represents a single test point.
15  
16 =head1 CONSTRUCTION
17  
18 =head2 new()
19  
20 my $point = new TAPx::Harness::Compatible::Point;
21  
22 Create a test point object.
23  
24 =cut
25  
26 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
27 0 my $class = shift;
28 0 my $self = bless {}, $class;
29  
30 0 return $self;
31 }
32  
33 =head1 from_test_line( $line )
34  
35 Constructor from a TAP test line, or empty return if the test line
36 is not a test line.
37  
38 =cut
39  
40 0 ▶sub from_test_line {
Subroutine from_test_line: not called CC=5 SCAR=34.0
Pod documented
41 0 my $class = shift;
42 0 ▶ my $line = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $line = shift() or return 0 0 0
43  
44 # We pulverize the line down into pieces in three parts.
45 0 ▶ my ( $not, $number, $extra )
Branch: 1 branch
BranchTrueFalseTotal
() = $line =~ /^(not )?ok\b(?:\s+(\d+))?\s*(.*)/ or return 0 0 0
46 = ( $line =~ /^(not )?ok\b(?:\s+(\d+))?\s*(.*)/ )
47 or return;
48  
49 0 my $point = $class->new;
50 0 $point->set_number($number);
51 0 $point->set_ok( !$not );
52  
53 0 ▶ if ($extra) {
Branch: 1 branch
BranchTrueFalseTotal
if ($extra) 0 0 0
54 0 my ( $description, $directive ) = split( /(?:[^\\]|^)#/, $extra, 2 );
55 0 $description =~ s/^- //; # Test::More puts it in there
56 0 $point->set_description($description);
57 0 ▶ if ($directive) {
Branch: 1 branch
BranchTrueFalseTotal
if ($directive) 0 0 0
58 0 $point->set_directive($directive);
59 }
60 } # if $extra
61  
62 0 return $point;
63 } # from_test_line()
64  
65 =head1 ACCESSORS
66  
67 Each of the following fields has a getter and setter method.
68  
69 =over 4
70  
71 =item * ok
72  
73 =item * number
74  
75 =back
76  
77 =cut
78  
79 0 ▶sub ok { my $self = shift; $self->{ok} }
Subroutine ok: not called CC=1 SCAR=6.9
Pod documented
80  
81 0 ▶sub set_ok {
Subroutine set_ok: not called CC=2 SCAR=17.9
Pod documented
82 0 my $self = shift;
83 0 my $ok = shift;
84 0 ▶ $self->{ok} = $ok ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$ok ? : 0 0 0
85 }
86  
87 0 ▶sub pass {
Subroutine pass: not called CC=4 SCAR=30.0
Pod documented
88 0 my $self = shift;
89  
90 0 ▶ return ( $self->ok || $self->is_todo || $self->is_skip ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->ok || $self->is_todo || $self->is_skip ? : 0 0 0
Condition0%0/6
$self->ok or $self->is_todo or $self->is_skip
l!l&&r!l&&!r
000
$self->ok or $self->is_todo
l!l&&r!l&&!r
000
MC/DC0%0/3
$self->ok or $self->is_todo or $self->is_skip
$self->ok $self->is_todo $self->is_skip
Truth table0%0/4
A or B or C
A= $self->okB= $self->is_todoC= $self->is_skip
ABCresult
1XX1
01X1
0011
0000
91 }
92  
93 0 ▶sub number { my $self = shift; $self->{number} }
Subroutine number: not called CC=1 SCAR=6.9
Pod documented
94 0 ▶sub set_number { my $self = shift; $self->{number} = shift }
Subroutine set_number: not called CC=1 SCAR=6.9
Pod documented
95  
96 0 ▶sub description { my $self = shift; $self->{description} }
Subroutine description: not called CC=1 SCAR=6.9
Pod documented
97  
98 0 ▶sub set_description {
Subroutine set_description: not called CC=1 SCAR=6.9
Pod documented
99 0 my $self = shift;
100 0 $self->{description} = shift;
101 0 $self->{name} = $self->{description}; # history
102 }
103  
104 0 ▶sub directive { my $self = shift; $self->{directive} }
Subroutine directive: not called CC=1 SCAR=6.9
Pod documented
105  
106 0 ▶sub set_directive {
Subroutine set_directive: not called CC=2 SCAR=17.9
Pod documented
107 0 my $self = shift;
108 0 my $directive = shift;
109  
110 0 $directive =~ s/^\s+//;
111 0 $directive =~ s/\s+$//;
112 0 $self->{directive} = $directive;
113  
114 0 my ( $type, $reason ) = ( $directive =~ /^\s*(\S+)(?:\s+(.*))?$/ );
115 0 $self->set_directive_type($type);
116 0 ▶ $reason = "" unless defined $reason;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $reason 0 0 0
117 0 $self->{directive_reason} = $reason;
118 }
119  
120 0 ▶sub set_directive_type {
Subroutine set_directive_type: not called CC=1 SCAR=6.9
Pod documented
121 0 my $self = shift;
122 0 $self->{directive_type} = lc shift;
123 0 $self->{type} = $self->{directive_type}; # History
124 }
125  
126 0 ▶sub set_directive_reason {
Subroutine set_directive_reason: not called CC=1 SCAR=6.9
Pod documented
127 0 my $self = shift;
128 0 $self->{directive_reason} = shift;
129 }
130 0 ▶sub directive_type { my $self = shift; $self->{directive_type} }
Subroutine directive_type: not called CC=1 SCAR=6.9
Pod documented
131 0 ▶sub type { my $self = shift; $self->{directive_type} }
Subroutine type: not called CC=1 SCAR=6.9
Pod documented
132 0 ▶sub directive_reason { my $self = shift; $self->{directive_reason} }
Subroutine directive_reason: not called CC=1 SCAR=6.9
Pod documented
133 0 ▶sub reason { my $self = shift; $self->{directive_reason} }
Subroutine reason: not called CC=1 SCAR=6.9
Pod documented
134  
135 0 ▶sub is_todo {
Subroutine is_todo: not called CC=2 SCAR=17.9
Pod documented
136 0 my $self = shift;
137 0 my $type = $self->directive_type;
138 0 ▶ return $type && ( $type eq 'todo' );
Condition0%0/3
$type && $type eq 'todo'
!ll&&!rl&&r
000
MC/DC0%0/2
$type && $type eq 'todo'
$type $type eq 'todo'
Truth table0%0/3
A && B
A= $typeB= $type eq 'todo'
ABresult
0X0
100
111
139 }
140  
141 0 ▶sub is_skip {
Subroutine is_skip: not called CC=2 SCAR=17.9
Pod documented
142 0 my $self = shift;
143 0 my $type = $self->directive_type;
144 0 ▶ return $type && ( $type eq 'skip' );
Condition0%0/3
$type && $type eq 'skip'
!ll&&!rl&&r
000
MC/DC0%0/2
$type && $type eq 'skip'
$type $type eq 'skip'
Truth table0%0/3
A && B
A= $typeB= $type eq 'skip'
ABresult
0X0
100
111
145 }
146  
147 0 ▶sub diagnostics {
Subroutine diagnostics: not called CC=2 SCAR=17.9
Pod documented
148 0 my $self = shift;
149 0 ▶ return @{ $self->{diagnostics} } if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
150 0 return join( "\n", @{ $self->{diagnostics} } );
151 }
152 0 ▶sub add_diagnostic { my $self = shift; push @{ $self->{diagnostics} }, @_ }
Subroutine add_diagnostic: not called CC=1 SCAR=6.9
Pod documented
153  
154 1 1;
155  
156 =head1 TO DOCUMENT
157  
158 =over
159  
160 =item add_diagnostic
161  
162 TODO: Document add_diagnostic
163  
164 =item description
165  
166 TODO: Document description
167  
168 =item diagnostics
169  
170 TODO: Document diagnostics
171  
172 =item directive
173  
174 TODO: Document directive
175  
176 =item directive_reason
177  
178 TODO: Document directive_reason
179  
180 =item directive_type
181  
182 TODO: Document directive_type
183  
184 =item from_test_line
185  
186 TODO: Document from_test_line
187  
188 =item is_skip
189  
190 TODO: Document is_skip
191  
192 =item is_todo
193  
194 TODO: Document is_todo
195  
196 =item pass
197  
198 TODO: Document pass
199  
200 =item reason
201  
202 TODO: Document reason
203  
204 =item set_description
205  
206 TODO: Document set_description
207  
208 =item set_directive
209  
210 TODO: Document set_directive
211  
212 =item set_directive_reason
213  
214 TODO: Document set_directive_reason
215  
216 =item set_directive_type
217  
218 TODO: Document set_directive_type
219  
220 =item set_number
221  
222 TODO: Document set_number
223  
224 =item set_ok
225  
226 TODO: Document set_ok
227  
228 =item type
229  
230 TODO: Document type
231  
232 =back
« Parser/YAML.pm ↑ Summary Parser.pm »