line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Fennec::Util; |
2
|
140
|
|
|
140
|
|
742
|
use strict; |
|
140
|
|
|
|
|
163
|
|
|
140
|
|
|
|
|
2952
|
|
3
|
140
|
|
|
140
|
|
548
|
use warnings; |
|
140
|
|
|
|
|
169
|
|
|
140
|
|
|
|
|
3382
|
|
4
|
140
|
|
|
140
|
|
54041
|
use Exporter::Declare; |
|
140
|
|
|
|
|
2367254
|
|
|
140
|
|
|
|
|
18453
|
|
5
|
140
|
|
|
140
|
|
177197
|
use Carp qw/croak/; |
|
140
|
|
|
|
|
11608
|
|
|
140
|
|
|
|
|
5022
|
|
6
|
140
|
|
|
140
|
|
627
|
use Scalar::Util qw/blessed/; |
|
140
|
|
|
|
|
351
|
|
|
140
|
|
|
|
|
28513
|
|
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
|
14285
|
my ( $package, $name, $code ) = @_; |
14
|
9218
|
50
|
33
|
|
|
45359
|
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
|
|
4674
|
no strict 'refs'; |
|
140
|
|
|
|
|
5470
|
|
|
140
|
|
|
|
|
190121
|
|
21
|
9218
|
|
|
|
|
10759
|
*{"$package\::$name"} = $code; |
|
9218
|
|
|
|
|
43228
|
|
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub accessors { |
25
|
1428
|
|
|
1428
|
1
|
5852
|
my $caller = caller; |
26
|
1428
|
|
|
|
|
5218
|
_accessor( $caller, $_ ) for @_; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub require_module { |
30
|
1094
|
|
|
1094
|
1
|
2077
|
my $module = shift; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Is it defined? |
33
|
1094
|
50
|
|
|
|
2284
|
croak "No module specified" |
34
|
|
|
|
|
|
|
unless defined $module; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# Is the caller using utf8? |
37
|
1094
|
|
|
|
|
73937
|
require utf8; |
38
|
1094
|
|
|
|
|
9643
|
my $with_utf8 = ( caller(0) )[8] & $utf8::hint_bits; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Are Unicode package names ok? |
41
|
1094
|
50
|
|
|
|
5779
|
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
|
|
|
|
8557
|
croak "Invalid Module '$module'" |
48
|
|
|
|
|
|
|
unless $module =~ $check; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Transform to a pm file path |
51
|
1092
|
|
|
|
|
2066
|
my $file = $module; |
52
|
1092
|
|
|
|
|
1744
|
$file .= ".pm"; |
53
|
1092
|
|
|
|
|
3200
|
$file =~ s{::}{/}g; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# What were we doing again? |
56
|
1092
|
|
|
|
|
276924
|
return require $file; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub _accessor { |
60
|
9031
|
|
|
9031
|
|
15035
|
my ( $caller, $attribute ) = @_; |
61
|
|
|
|
|
|
|
inject_sub( |
62
|
|
|
|
|
|
|
$caller, |
63
|
|
|
|
|
|
|
$attribute, |
64
|
|
|
|
|
|
|
sub { |
65
|
99947
|
|
|
99947
|
|
153281
|
my $self = shift; |
66
|
99947
|
50
|
|
|
|
285807
|
croak "$attribute() called on '$self' instead of an instance" |
67
|
|
|
|
|
|
|
unless blessed($self); |
68
|
99947
|
100
|
|
|
|
207664
|
( $self->{$attribute} ) = @_ if @_; |
69
|
99947
|
|
|
|
|
444659
|
return $self->{$attribute}; |
70
|
|
|
|
|
|
|
} |
71
|
9031
|
|
|
|
|
26937
|
); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub get_test_call { |
75
|
704
|
|
|
704
|
1
|
1724
|
my $runner; |
76
|
704
|
|
|
|
|
1211
|
my $i = 1; |
77
|
|
|
|
|
|
|
|
78
|
704
|
|
|
|
|
6167
|
while ( my @call = caller( $i++ ) ) { |
79
|
7113
|
100
|
100
|
|
|
40678
|
$runner = \@call if !$runner && $call[0]->isa('Fennec::Runner'); |
80
|
7113
|
100
|
|
|
|
73908
|
return @call if $call[0]->can('FENNEC'); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
124
|
100
|
|
|
|
1097
|
return ( $runner ? @$runner : ( "UNKNOWN", "UNKNOWN", 0 ) ); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub verbose_message { |
87
|
|
|
|
|
|
|
return |
88
|
|
|
|
|
|
|
if $ENV{HARNESS_ACTIVE} |
89
|
690
|
50
|
33
|
690
|
0
|
140601
|
&& !$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
|
1375
|
sub tb_ok { Test::Builder->new->ok(@_) } |
98
|
0
|
|
|
0
|
0
|
0
|
sub tb_diag { Test::Builder->new->diag(@_) } |
99
|
4
|
|
|
4
|
0
|
300
|
sub tb_skip { Test::Builder->new->skip(@_) } |
100
|
30
|
|
|
30
|
0
|
551
|
sub tb_todo_start { Test::Builder->new->todo_start(@_) } |
101
|
30
|
|
|
30
|
0
|
123
|
sub tb_todo_end { Test::Builder->new->todo_end } |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
1; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
__END__ |