line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::LocalFunctions::Fast; |
2
|
|
|
|
|
|
|
|
3
|
34
|
|
|
34
|
|
545890
|
use strict; |
|
34
|
|
|
|
|
94
|
|
|
34
|
|
|
|
|
1381
|
|
4
|
34
|
|
|
34
|
|
202
|
use warnings; |
|
34
|
|
|
|
|
65
|
|
|
34
|
|
|
|
|
1050
|
|
5
|
34
|
|
|
34
|
|
18157
|
use Test::LocalFunctions::Util; |
|
34
|
|
|
|
|
95
|
|
|
34
|
|
|
|
|
1174
|
|
6
|
34
|
|
|
34
|
|
8249
|
use Test::LocalFunctions::Receptor; |
|
34
|
|
|
|
|
88
|
|
|
34
|
|
|
|
|
4311
|
|
7
|
34
|
|
|
34
|
|
13710
|
use parent qw/Test::Builder::Module/; |
|
34
|
|
|
|
|
4617
|
|
|
34
|
|
|
|
|
290
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
BEGIN { |
10
|
34
|
|
|
34
|
|
3543
|
eval { require Compiler::Lexer }; |
|
34
|
|
|
|
|
1232
|
|
11
|
34
|
50
|
|
|
|
13323
|
if ($@) { |
12
|
0
|
0
|
|
|
|
0
|
$ENV{TEST_LOCALFUNCTIONS_TEST_PHASE} or die $@; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our @EXPORT = qw/all_local_functions_ok local_functions_ok/; |
17
|
|
|
|
|
|
|
|
18
|
34
|
|
50
|
34
|
|
172
|
use constant _VERBOSE => ( $ENV{TEST_VERBOSE} || 0 ); |
|
34
|
|
|
|
|
60
|
|
|
34
|
|
|
|
|
37251
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub all_local_functions_ok { |
21
|
6
|
|
|
6
|
1
|
48
|
my ($args) = @_; |
22
|
6
|
|
|
|
|
48
|
return Test::LocalFunctions::Receptor::all_local_functions_ok( __PACKAGE__, $args ); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub local_functions_ok { |
26
|
13
|
|
|
13
|
1
|
32857
|
my ( $lib, $args ) = @_; |
27
|
13
|
|
|
|
|
90
|
return Test::LocalFunctions::Receptor::local_functions_ok( __PACKAGE__, $lib, $args ); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub is_in_use { |
31
|
20
|
|
|
20
|
0
|
1101
|
my ( undef, $builder, $file, $args ) = @_; |
32
|
|
|
|
|
|
|
|
33
|
20
|
|
|
|
|
356
|
my $ignore_functions = $args->{ignore_functions}; |
34
|
20
|
|
|
|
|
1614
|
my $module = Test::LocalFunctions::Util::extract_module_name($file); |
35
|
20
|
|
|
|
|
792
|
my @local_functions = Test::LocalFunctions::Util::list_local_functions($module); |
36
|
20
|
|
|
|
|
215
|
my @tokens = _fetch_tokens($file); |
37
|
|
|
|
|
|
|
|
38
|
20
|
|
|
|
|
64
|
my $fail = 0; |
39
|
20
|
|
|
|
|
214
|
LOCAL_FUNCTION: for my $local_function (@local_functions) { |
40
|
37
|
|
|
|
|
77
|
for my $token (@tokens) { |
41
|
99
|
100
|
|
|
|
447
|
next LOCAL_FUNCTION if ( $token->{data} eq $local_function ); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
12
|
100
|
|
|
|
107
|
unless ( grep { $local_function =~ $_ } @$ignore_functions ) { |
|
9
|
|
|
|
|
184
|
|
45
|
9
|
|
|
|
|
357
|
$builder->diag("Test::LocalFunctions failed: '$local_function' is not used."); |
46
|
9
|
|
|
|
|
5481
|
$fail++; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
20
|
|
|
|
|
6838
|
return $fail; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub _fetch_tokens { |
54
|
20
|
|
|
20
|
|
98
|
my $file = shift; |
55
|
|
|
|
|
|
|
|
56
|
20
|
50
|
|
|
|
4078
|
open( my $fh, '<', $file ) or die("Can not open the file: $!"); |
57
|
20
|
|
|
|
|
1344
|
my $code = do { local $/; <$fh> }; |
|
20
|
|
|
|
|
656
|
|
|
20
|
|
|
|
|
16590
|
|
58
|
20
|
|
|
|
|
1018
|
my $lexer = Compiler::Lexer->new($file); |
59
|
20
|
|
|
|
|
2224
|
my @tokens = grep { _remove_tokens($_) } @{$lexer->tokenize($code)}; |
|
3105
|
|
|
|
|
7899
|
|
|
20
|
|
|
|
|
24971
|
|
60
|
20
|
|
|
|
|
4213
|
close($fh); |
61
|
|
|
|
|
|
|
|
62
|
20
|
|
|
|
|
807
|
return @tokens; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub _remove_tokens { |
66
|
3105
|
|
|
3105
|
|
5226
|
my $token = shift; |
67
|
|
|
|
|
|
|
|
68
|
3105
|
100
|
100
|
|
|
15989
|
return 1 if ( $token->{name} eq 'Key' || $token->{name} eq 'Call' ); |
69
|
3032
|
|
|
|
|
7336
|
return 0; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
__END__ |