line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::UniqueTestNames::Test; |
2
|
|
|
|
|
|
|
|
3
|
13
|
|
|
13
|
|
74627
|
use strict; |
|
13
|
|
|
|
|
25
|
|
|
13
|
|
|
|
|
417
|
|
4
|
13
|
|
|
13
|
|
201
|
use warnings; |
|
13
|
|
|
|
|
31
|
|
|
13
|
|
|
|
|
7678
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
my $unnamed_ok = 0; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
82
|
|
|
82
|
0
|
2394
|
my ( $class, $name, $line_number ) = @_; |
10
|
|
|
|
|
|
|
|
11
|
82
|
100
|
|
|
|
201
|
die 'tests must have a line number' unless defined $line_number; |
12
|
|
|
|
|
|
|
|
13
|
80
|
|
100
|
|
|
534
|
my $self = { |
14
|
|
|
|
|
|
|
name => $name || '', |
15
|
|
|
|
|
|
|
line_numbers => [ $line_number ], |
16
|
|
|
|
|
|
|
}; |
17
|
|
|
|
|
|
|
|
18
|
80
|
|
|
|
|
510
|
return bless( $self, $class ); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub name { |
22
|
217
|
|
|
217
|
0
|
269
|
my ( $self ) = @_; |
23
|
|
|
|
|
|
|
|
24
|
217
|
|
|
|
|
1274
|
return $self->{ name }; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub short_name { |
28
|
15
|
|
|
15
|
0
|
36
|
my ( $self ) = @_; |
29
|
|
|
|
|
|
|
|
30
|
15
|
|
|
|
|
35
|
my $name = $self->{ name }; |
31
|
15
|
100
|
|
|
|
87
|
return $name if length $name < 40; |
32
|
|
|
|
|
|
|
|
33
|
2
|
|
|
|
|
8
|
substr($name, 40) = '...'; |
34
|
2
|
|
|
|
|
9
|
return $name; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub line_numbers { |
38
|
30
|
|
|
30
|
0
|
50
|
my ( $self ) = @_; |
39
|
|
|
|
|
|
|
|
40
|
30
|
|
|
|
|
39
|
my %line_frequency; |
41
|
30
|
|
|
|
|
39
|
for( @{ $self->{ line_numbers } } ) { |
|
30
|
|
|
|
|
80
|
|
42
|
70
|
|
|
|
|
159
|
$line_frequency{ $_ }++; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
30
|
|
|
|
|
133
|
return \%line_frequency; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub lowest_line_number { |
49
|
220
|
|
|
220
|
0
|
265
|
my ( $self ) = @_; |
50
|
|
|
|
|
|
|
|
51
|
220
|
|
|
|
|
221
|
my @sorted_line_numbers = sort @{ $self->{ line_numbers } }; |
|
220
|
|
|
|
|
626
|
|
52
|
|
|
|
|
|
|
|
53
|
220
|
|
|
|
|
698
|
return $sorted_line_numbers[0]; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub add_line_number { |
57
|
26
|
|
|
26
|
0
|
81
|
my ( $self, $line_number ) = @_; |
58
|
|
|
|
|
|
|
|
59
|
26
|
100
|
|
|
|
84
|
die "add_line_number must be called on an instance" unless ref $self; |
60
|
|
|
|
|
|
|
|
61
|
25
|
|
|
|
|
32
|
push @{ $self->{ line_numbers } }, $line_number; |
|
25
|
|
|
|
|
142
|
|
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub fails { |
65
|
109
|
|
|
109
|
0
|
220
|
my ( $self ) = @_; |
66
|
|
|
|
|
|
|
|
67
|
109
|
100
|
|
|
|
263
|
die "fails must be called on an instance" unless ref $self; |
68
|
|
|
|
|
|
|
|
69
|
108
|
100
|
|
|
|
243
|
return 0 if $self->name =~ /^The object isa/; |
70
|
|
|
|
|
|
|
|
71
|
107
|
100
|
|
|
|
203
|
if( $self->name eq '' ) { |
72
|
12
|
100
|
|
|
|
72
|
return $unnamed_ok |
73
|
|
|
|
|
|
|
? 0 |
74
|
|
|
|
|
|
|
: 1; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
95
|
100
|
|
|
|
136
|
return 1 if @{ $self->{ line_numbers } } > 1; |
|
95
|
|
|
|
|
532
|
|
78
|
|
|
|
|
|
|
|
79
|
54
|
|
|
|
|
205
|
return 0; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub unnamed_ok { |
83
|
5
|
|
|
5
|
0
|
11
|
my ( $self, $value ) = @_; |
84
|
|
|
|
|
|
|
|
85
|
5
|
100
|
|
|
|
19
|
$unnamed_ok = $value if defined $value; |
86
|
|
|
|
|
|
|
|
87
|
5
|
|
|
|
|
28
|
return $unnamed_ok; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub occurrences { |
91
|
15
|
|
|
15
|
0
|
28
|
my ( $self ) = @_; |
92
|
|
|
|
|
|
|
|
93
|
15
|
|
|
|
|
27
|
my $occurrences = 0; |
94
|
|
|
|
|
|
|
|
95
|
15
|
|
|
|
|
24
|
$occurrences += $_ for values %{ $self->line_numbers }; |
|
15
|
|
|
|
|
33
|
|
96
|
|
|
|
|
|
|
|
97
|
15
|
|
|
|
|
144
|
return $occurrences; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1; |