| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Fennec::Util; |
|
2
|
140
|
|
|
140
|
|
681
|
use strict; |
|
|
140
|
|
|
|
|
235
|
|
|
|
140
|
|
|
|
|
6642
|
|
|
3
|
140
|
|
|
140
|
|
646
|
use warnings; |
|
|
140
|
|
|
|
|
272
|
|
|
|
140
|
|
|
|
|
2955
|
|
|
4
|
140
|
|
|
140
|
|
144312
|
use Exporter::Declare; |
|
|
140
|
|
|
|
|
5006163
|
|
|
|
140
|
|
|
|
|
816
|
|
|
5
|
140
|
|
|
140
|
|
224307
|
use Carp qw/croak/; |
|
|
140
|
|
|
|
|
331
|
|
|
|
140
|
|
|
|
|
8917
|
|
|
6
|
140
|
|
|
140
|
|
862
|
use Scalar::Util qw/blessed/; |
|
|
140
|
|
|
|
|
1214
|
|
|
|
140
|
|
|
|
|
19723
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
exports qw{ |
|
9
|
|
|
|
|
|
|
inject_sub accessors get_test_call require_module verbose_message |
|
10
|
|
|
|
|
|
|
}; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub inject_sub { |
|
13
|
9218
|
|
|
9218
|
1
|
15829
|
my ( $package, $name, $code ) = @_; |
|
14
|
9218
|
50
|
33
|
|
|
110069
|
croak "inject_sub() takes a package, a name, and a coderef" |
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
15
|
|
|
|
|
|
|
unless $package |
|
16
|
|
|
|
|
|
|
&& $name |
|
17
|
|
|
|
|
|
|
&& $code |
|
18
|
|
|
|
|
|
|
&& $code =~ /CODE/; |
|
19
|
|
|
|
|
|
|
|
|
20
|
140
|
|
|
140
|
|
1208
|
no strict 'refs'; |
|
|
140
|
|
|
|
|
215
|
|
|
|
140
|
|
|
|
|
118727
|
|
|
21
|
9218
|
|
|
|
|
16669
|
*{"$package\::$name"} = $code; |
|
|
9218
|
|
|
|
|
89151
|
|
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub accessors { |
|
25
|
1428
|
|
|
1428
|
1
|
11661
|
my $caller = caller; |
|
26
|
1428
|
|
|
|
|
8731
|
_accessor( $caller, $_ ) for @_; |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub require_module { |
|
30
|
1094
|
|
|
1094
|
1
|
2553
|
my $module = shift; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Is it defined? |
|
33
|
1094
|
50
|
|
|
|
3253
|
croak "No module specified" |
|
34
|
|
|
|
|
|
|
unless defined $module; |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# Is the caller using utf8? |
|
37
|
1094
|
|
|
|
|
185271
|
require utf8; |
|
38
|
1094
|
|
|
|
|
13713
|
my $with_utf8 = ( caller(0) )[8] & $utf8::hint_bits; |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Are Unicode package names ok? |
|
41
|
1094
|
50
|
|
|
|
10527
|
my $check = |
|
42
|
|
|
|
|
|
|
$with_utf8 |
|
43
|
|
|
|
|
|
|
? qr{\A [[:alpha:]_] [[:word:]]* (?: :: [[:word:]]+ )* \z}x |
|
44
|
|
|
|
|
|
|
: qr{\A [A-Z_a-z] [0-9A-Z_a-z]* (?: :: [0-9A-Z_a-z]+ )* \z}x; |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# Is it a syntactically valid module name? |
|
47
|
1094
|
100
|
|
|
|
13596
|
croak "Invalid Module '$module'" |
|
48
|
|
|
|
|
|
|
unless $module =~ $check; |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Transform to a pm file path |
|
51
|
1092
|
|
|
|
|
2121
|
my $file = $module; |
|
52
|
1092
|
|
|
|
|
1967
|
$file .= ".pm"; |
|
53
|
1092
|
|
|
|
|
4925
|
$file =~ s{::}{/}g; |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# What were we doing again? |
|
56
|
1092
|
|
|
|
|
787267
|
return require $file; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub _accessor { |
|
60
|
9031
|
|
|
9031
|
|
17504
|
my ( $caller, $attribute ) = @_; |
|
61
|
|
|
|
|
|
|
inject_sub( |
|
62
|
|
|
|
|
|
|
$caller, |
|
63
|
|
|
|
|
|
|
$attribute, |
|
64
|
|
|
|
|
|
|
sub { |
|
65
|
183633
|
|
|
183633
|
|
803079
|
my $self = shift; |
|
66
|
183633
|
50
|
|
|
|
1252860
|
croak "$attribute() called on '$self' instead of an instance" |
|
67
|
|
|
|
|
|
|
unless blessed($self); |
|
68
|
183633
|
100
|
|
|
|
734800
|
( $self->{$attribute} ) = @_ if @_; |
|
69
|
183633
|
|
|
|
|
1400019
|
return $self->{$attribute}; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
9031
|
|
|
|
|
45301
|
); |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub get_test_call { |
|
75
|
700
|
|
|
700
|
1
|
1434
|
my $runner; |
|
76
|
700
|
|
|
|
|
1458
|
my $i = 1; |
|
77
|
|
|
|
|
|
|
|
|
78
|
700
|
|
|
|
|
9173
|
while ( my @call = caller( $i++ ) ) { |
|
79
|
6225
|
100
|
100
|
|
|
71135
|
$runner = \@call if !$runner && $call[0]->isa('Fennec::Runner'); |
|
80
|
6225
|
100
|
|
|
|
161312
|
return @call if $call[0]->can('FENNEC'); |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
124
|
100
|
|
|
|
1764
|
return ( $runner ? @$runner : ( "UNKNOWN", "UNKNOWN", 0 ) ); |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub verbose_message { |
|
87
|
|
|
|
|
|
|
return |
|
88
|
690
|
50
|
33
|
690
|
0
|
295408
|
if $ENV{HARNESS_ACTIVE} |
|
89
|
|
|
|
|
|
|
&& !$ENV{HARNESS_IS_VERBOSE}; |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# Do not print the messages on syntax check |
|
92
|
0
|
0
|
|
|
|
0
|
return if $^C; |
|
93
|
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
0
|
print @_; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
172
|
|
|
172
|
0
|
1737
|
sub tb_ok { Test::Builder->new->ok(@_) } |
|
98
|
0
|
|
|
0
|
0
|
0
|
sub tb_diag { Test::Builder->new->diag(@_) } |
|
99
|
4
|
|
|
4
|
0
|
255
|
sub tb_skip { Test::Builder->new->skip(@_) } |
|
100
|
30
|
|
|
30
|
0
|
687
|
sub tb_todo_start { Test::Builder->new->todo_start(@_) } |
|
101
|
30
|
|
|
30
|
0
|
158
|
sub tb_todo_end { Test::Builder->new->todo_end } |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
1; |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
__END__ |