support/Test/Harness/Point.pm

filter: Statementstmt 79.4% 62 / 78 Branchbran 62.5% 10 / 16 Conditioncond 50.0% 6 / 12 MC/DCmcdc 14.2% 1 / 7 Subroutinesub 73.9% 17 / 23 Podpod 14.2% 3 / 21 totaltotal 63.0% 99 / 157 CC 13 SCAR 10.3
CC
13
Cov
74%
pass
6.0
diagnostics
6.0
from_test_line
5.0
CRAP 2.8
« support/Test/Harness/Assert.pm ↑ Summary examples/memmap.pl »
1 # -*- Mode: cperl; cperl-indent-level: 4 -*-
2 package Test::Harness::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.01';
7  
8 =head1 NAME
9  
10 Test::Harness::Point - object for tracking a single test point
11  
12 =head1 SYNOPSIS
13  
14 One Test::Harness::Point object represents a single test point.
15  
16 =head1 CONSTRUCTION
17  
18 =head2 new()
19  
20 my $point = Test::Harness::Point->new;
21  
22 Create a test point object.
23  
24 =cut
25  
26 sub new {
27 48545 ▶ my $class = shift;
Subroutine new: called CC=1 SCAR=0.0
Pod documented
28 48545 my $self = bless {}, $class;
29  
30 48545 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 sub from_test_line {
41 64823 ▶ my $class = shift;
Subroutine from_test_line: called CC=5 SCAR=16.1
Pod undocumented
42 64823 ▶ my $line = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $line = shift() or return 0 64823 64823
43  
44 # We pulverize the line down into pieces in three parts.
45 64823 ▶ my ($not, $number, $extra) = ($line =~ /^(not )?ok\b(?:\s+(\d+))?\s*(.*)/) or return;
Branch: 1 branch
BranchTrueFalseTotal
() = $line =~ /^(not )?ok\b(?:\s+(\d+))?\s*(.*)/ or return 16278 48545 64823
46  
47 48545 my $point = $class->new;
48 48545 $point->set_number( $number );
49 48545 $point->set_ok( !$not );
50  
51 48545 ▶ if ( $extra ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($extra) 20792 27753 48545
52 20792 my ($description,$directive) = split( /(?:[^\\]|^)#/, $extra, 2 );
53 20792 $description =~ s/^- //; # Test::More puts it in there
54 20792 $point->set_description( $description );
55 20792 ▶ if ( $directive ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($directive) 556 20236 20792
56 556 $point->set_directive( $directive );
57 }
58 } # if $extra
59  
60 48545 return $point;
61 } # from_test_line()
62  
63 =head1 ACCESSORS
64  
65 Each of the following fields has a getter and setter method.
66  
67 =over 4
68  
69 =item * ok
70  
71 =item * number
72  
73 =back
74  
75 =cut
76  
77 145635 ▶sub ok { my $self = shift; $self->{ok} }
Subroutine ok: called CC=1 SCAR=0.0
Pod documented
78 sub set_ok {
79 48545 ▶ my $self = shift;
Subroutine set_ok: called CC=2 SCAR=7.1
Pod undocumented
80 48545 my $ok = shift;
81 48545 ▶ $self->{ok} = $ok ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$ok ? : 48545 0 48545
82 }
83 sub pass {
84 97090 ▶ my $self = shift;
Subroutine pass: called CC=4 SCAR=17.9
Pod undocumented
85  
86 97090 ▶ return ($self->ok || $self->is_todo || $self->is_skip) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->ok || $self->is_todo || $self->is_skip ? : 97090 0 97090
Condition33%2/6
$self->ok or $self->is_todo or $self->is_skip
l!l&&r!l&&!r
9709000
$self->ok or $self->is_todo
l!l&&r!l&&!r
9709000
MC/DC0%0/3
$self->ok or $self->is_todo or $self->is_skip
$self->ok $self->is_todo $self->is_skip
Truth table25%1/4
A or B or C
A= $self->okB= $self->is_todoC= $self->is_skip
ABCresult
1XX1
01X1
0011
0000
87 }
88  
89 242725 ▶sub number { my $self = shift; $self->{number} }
Subroutine number: called CC=1 SCAR=0.0
Pod documented
90 48545 ▶sub set_number { my $self = shift; $self->{number} = shift }
Subroutine set_number: called CC=1 SCAR=0.0
Pod undocumented
91  
92 48545 ▶sub description { my $self = shift; $self->{description} }
Subroutine description: called CC=1 SCAR=0.0
Pod undocumented
93 sub set_description {
94 20792 ▶ my $self = shift;
Subroutine set_description: called CC=1 SCAR=0.0
Pod undocumented
95 20792 $self->{description} = shift;
96 20792 $self->{name} = $self->{description}; # history
97 }
98  
99 0 ▶sub directive { my $self = shift; $self->{directive} }
Subroutine directive: not called CC=1 SCAR=6.9
Pod undocumented
100 sub set_directive {
101 556 ▶ my $self = shift;
Subroutine set_directive: called CC=2 SCAR=6.9
Pod undocumented
102 556 my $directive = shift;
103  
104 556 $directive =~ s/^\s+//;
105 556 $directive =~ s/\s+$//;
106 556 $self->{directive} = $directive;
107  
108 556 my ($type,$reason) = ($directive =~ /^\s*(\S+)(?:\s+(.*))?$/);
109 556 $self->set_directive_type( $type );
110 556 ▶ $reason = "" unless defined $reason;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $reason 0 556 556
111 556 $self->{directive_reason} = $reason;
112 }
113 sub set_directive_type {
114 556 ▶ my $self = shift;
Subroutine set_directive_type: called CC=1 SCAR=0.0
Pod undocumented
115 556 $self->{directive_type} = lc shift;
116 556 $self->{type} = $self->{directive_type}; # History
117 }
118 sub set_directive_reason {
119 0 ▶ my $self = shift;
Subroutine set_directive_reason: not called CC=1 SCAR=6.9
Pod undocumented
120 0 $self->{directive_reason} = shift;
121 }
122 145635 ▶sub directive_type { my $self = shift; $self->{directive_type} }
Subroutine directive_type: called CC=1 SCAR=0.0
Pod undocumented
123 0 ▶sub type { my $self = shift; $self->{directive_type} }
Subroutine type: not called CC=1 SCAR=6.9
Pod undocumented
124 48545 ▶sub directive_reason{ my $self = shift; $self->{directive_reason} }
Subroutine directive_reason: called CC=1 SCAR=0.0
Pod undocumented
125 0 ▶sub reason { my $self = shift; $self->{directive_reason} }
Subroutine reason: not called CC=1 SCAR=6.9
Pod undocumented
126 sub is_todo {
127 48545 ▶ my $self = shift;
Subroutine is_todo: called CC=2 SCAR=7.0
Pod undocumented
128 48545 my $type = $self->directive_type;
129 48545 ▶ return $type && ( $type eq 'todo' );
Condition66%2/3
$type && $type eq 'todo'
!ll&&!rl&&r
479895560
MC/DC0%0/2
$type && $type eq 'todo'
$type $type eq 'todo'
Truth table66%2/3
A && B
A= $typeB= $type eq 'todo'
ABresult
0X0
100
111
130 }
131 sub is_skip {
132 48545 ▶ my $self = shift;
Subroutine is_skip: called CC=2 SCAR=7.0
Pod undocumented
133 48545 my $type = $self->directive_type;
134 48545 ▶ return $type && ( $type eq 'skip' );
Condition66%2/3
$type && $type eq 'skip'
!ll&&!rl&&r
479890556
MC/DC50%1/2
$type && $type eq 'skip'
$type $type eq 'skip'
Truth table66%2/3
A && B
A= $typeB= $type eq 'skip'
ABresult
0X0
100
111
135 }
136  
137 sub diagnostics {
138 0 ▶ my $self = shift;
Subroutine diagnostics: not called CC=2 SCAR=17.9
Pod undocumented
139 0 ▶ return @{$self->{diagnostics}} if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
140 0 return join( "\n", @{$self->{diagnostics}} );
141 }
142 0 ▶sub add_diagnostic { my $self = shift; push @{$self->{diagnostics}}, @_ }
Subroutine add_diagnostic: not called CC=1 SCAR=6.9
Pod undocumented
143  
144  
145 1 1;
« support/Test/Harness/Assert.pm ↑ Summary examples/memmap.pl »