| 1 | package Test::UniqueTestNames::Test; | ||||||||||||
| 2 | |||||||||||||
| 3 | 13 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 13 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | |||||||||||||
| 6 | 13 | my $unnamed_ok = 0; | |||||||||||
| 7 | |||||||||||||
| 8 | 82 | ▶ | sub new { | ||||||||||
|
Subroutine
new: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||
| 9 | 82 | my ( $class, $name, $line_number ) = @_; | |||||||||||
| 10 | |||||||||||||
| 11 | 82 | ▶ | die 'tests must have a line number' unless defined $line_number; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 12 | |||||||||||||
| 13 | 80 | ▶ | my $self = { | ||||||||||
|
Condition100%2/2
$name || '<no test name>'
MC/DC100%1/1
$name || '<no test name>'
$name
Truth table100%2/2
A
A= $name
| |||||||||||||
| 14 | name => $name || '<no test name>', | ||||||||||||
| 15 | line_numbers => [ $line_number ], | ||||||||||||
| 16 | }; | ||||||||||||
| 17 | |||||||||||||
| 18 | 80 | return bless( $self, $class ); | |||||||||||
| 19 | } | ||||||||||||
| 20 | |||||||||||||
| 21 | 217 | ▶ | sub name { | ||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 22 | 217 | my ( $self ) = @_; | |||||||||||
| 23 | |||||||||||||
| 24 | 217 | return $self->{ name }; | |||||||||||
| 25 | } | ||||||||||||
| 26 | |||||||||||||
| 27 | 15 | ▶ | sub short_name { | ||||||||||
|
Subroutine
short_name: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 28 | 15 | my ( $self ) = @_; | |||||||||||
| 29 | |||||||||||||
| 30 | 15 | my $name = $self->{ name }; | |||||||||||
| 31 | 15 | ▶ | return $name if length $name < 40; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 32 | |||||||||||||
| 33 | 2 | substr($name, 40) = '...'; | |||||||||||
| 34 | 2 | return $name; | |||||||||||
| 35 | } | ||||||||||||
| 36 | |||||||||||||
| 37 | 30 | ▶ | sub line_numbers { | ||||||||||
|
Subroutine
line_numbers: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 38 | 30 | my ( $self ) = @_; | |||||||||||
| 39 | |||||||||||||
| 40 | 30 | my %line_frequency; | |||||||||||
| 41 | 30 | for( @{ $self->{ line_numbers } } ) { | |||||||||||
| 42 | 70 | $line_frequency{ $_ }++; | |||||||||||
| 43 | } | ||||||||||||
| 44 | |||||||||||||
| 45 | 30 | return \%line_frequency; | |||||||||||
| 46 | } | ||||||||||||
| 47 | |||||||||||||
| 48 | 220 | ▶ | sub lowest_line_number { | ||||||||||
|
Subroutine
lowest_line_number: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 49 | 220 | my ( $self ) = @_; | |||||||||||
| 50 | |||||||||||||
| 51 | 220 | my @sorted_line_numbers = sort @{ $self->{ line_numbers } }; | |||||||||||
| 52 | |||||||||||||
| 53 | 220 | return $sorted_line_numbers[0]; | |||||||||||
| 54 | } | ||||||||||||
| 55 | |||||||||||||
| 56 | 26 | ▶ | sub add_line_number { | ||||||||||
|
Subroutine
add_line_number: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 57 | 26 | my ( $self, $line_number ) = @_; | |||||||||||
| 58 | |||||||||||||
| 59 | 26 | ▶ | die "add_line_number must be called on an instance" unless ref $self; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 60 | |||||||||||||
| 61 | 25 | push @{ $self->{ line_numbers } }, $line_number; | |||||||||||
| 62 | } | ||||||||||||
| 63 | |||||||||||||
| 64 | 109 | ▶ | sub fails { | ||||||||||
|
Subroutine
fails: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||
| 65 | 109 | my ( $self ) = @_; | |||||||||||
| 66 | |||||||||||||
| 67 | 109 | ▶ | die "fails must be called on an instance" unless ref $self; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 68 | |||||||||||||
| 69 | 108 | ▶ | return 0 if $self->name =~ /^The object isa/; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 70 | |||||||||||||
| 71 | 107 | ▶ | if( $self->name eq '<no test name>' ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 72 | 12 | ▶ | return $unnamed_ok | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 73 | ? 0 | ||||||||||||
| 74 | : 1; | ||||||||||||
| 75 | } | ||||||||||||
| 76 | |||||||||||||
| 77 | 95 | ▶ | return 1 if @{ $self->{ line_numbers } } > 1; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 78 | |||||||||||||
| 79 | 54 | return 0; | |||||||||||
| 80 | } | ||||||||||||
| 81 | |||||||||||||
| 82 | 5 | ▶ | sub unnamed_ok { | ||||||||||
|
Subroutine
unnamed_ok: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 83 | 5 | my ( $self, $value ) = @_; | |||||||||||
| 84 | |||||||||||||
| 85 | 5 | ▶ | $unnamed_ok = $value if defined $value; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 86 | |||||||||||||
| 87 | 5 | return $unnamed_ok; | |||||||||||
| 88 | } | ||||||||||||
| 89 | |||||||||||||
| 90 | 15 | ▶ | sub occurrences { | ||||||||||
|
Subroutine
occurrences: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 91 | 15 | my ( $self ) = @_; | |||||||||||
| 92 | |||||||||||||
| 93 | 15 | my $occurrences = 0; | |||||||||||
| 94 | |||||||||||||
| 95 | 15 | $occurrences += $_ for values %{ $self->line_numbers }; | |||||||||||
| 96 | |||||||||||||
| 97 | 15 | return $occurrences; | |||||||||||
| 98 | } | ||||||||||||
| 99 | |||||||||||||
| 100 | 13 | 1; | |||||||||||