line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
4
|
|
|
4
|
|
161108
|
use strict; use warnings; |
|
4
|
|
|
4
|
|
26
|
|
|
4
|
|
|
|
|
126
|
|
|
4
|
|
|
|
|
22
|
|
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
215
|
|
2
|
|
|
|
|
|
|
package XXX; |
3
|
|
|
|
|
|
|
our $VERSION = '0.37'; |
4
|
4
|
|
|
4
|
|
24
|
use base 'Exporter'; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
2335
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our @EXPORT = qw( WWW XXX YYY ZZZ ); |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $DumpModule = 'YAML::PP'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
if ($ENV{PERL_XXX_DUMPER}) { |
11
|
|
|
|
|
|
|
_set_dump_module($ENV{PERL_XXX_DUMPER}); |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub import { |
15
|
3
|
|
|
3
|
|
30
|
my ($package, @args) = @_; |
16
|
3
|
|
|
|
|
15
|
for (my $i = 0; $i < @args; $i++) { |
17
|
1
|
|
|
|
|
3
|
my $arg = $args[$i]; |
18
|
1
|
50
|
|
|
|
4
|
if ($arg eq '-with') { |
19
|
1
|
50
|
|
|
|
4
|
die "-with requires another argument" |
20
|
|
|
|
|
|
|
unless $i++ < @args; |
21
|
1
|
|
|
|
|
2
|
_set_dump_module($args[ $i ]); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
else { |
24
|
0
|
|
|
|
|
0
|
next; |
25
|
|
|
|
|
|
|
} |
26
|
1
|
|
|
|
|
2
|
last; |
27
|
|
|
|
|
|
|
} |
28
|
3
|
50
|
|
|
|
13
|
if (grep /^-?global$/, @args) { |
29
|
0
|
|
|
|
|
0
|
*main::WWW = \&WWW; |
30
|
0
|
|
|
|
|
0
|
*main::XXX = \&XXX; |
31
|
0
|
|
|
|
|
0
|
*main::YYY = \&YYY; |
32
|
0
|
|
|
|
|
0
|
*main::ZZZ = \&ZZZ; |
33
|
0
|
|
|
|
|
0
|
$main::WWW = \&WWW; |
34
|
0
|
|
|
|
|
0
|
$main::XXX = \&XXX; |
35
|
0
|
|
|
|
|
0
|
$main::YYY = \&YYY; |
36
|
0
|
|
|
|
|
0
|
$main::ZZZ = \&ZZZ; |
37
|
|
|
|
|
|
|
} |
38
|
3
|
|
|
|
|
8
|
@_ = ($package); |
39
|
3
|
|
|
|
|
3280
|
goto &Exporter::import; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub _set_dump_module { |
43
|
1
|
|
|
1
|
|
2
|
my ($module) = @_; |
44
|
1
|
|
|
|
|
2
|
$DumpModule = $module; |
45
|
1
|
50
|
|
|
|
12
|
die "Don't know how to use XXX -with '$DumpModule'" |
46
|
|
|
|
|
|
|
unless $DumpModule =~ /^( |
47
|
|
|
|
|
|
|
(?:YAML|JSON)(?:::.*)?| |
48
|
|
|
|
|
|
|
Data::Dumper| |
49
|
|
|
|
|
|
|
Data::Dump(?:::Color)? |
50
|
|
|
|
|
|
|
)$/x; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub _xxx_dump { |
54
|
4
|
|
|
4
|
|
47
|
no strict 'refs'; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
138
|
|
55
|
4
|
|
|
4
|
|
18
|
no warnings; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
1714
|
|
56
|
3
|
|
50
|
3
|
|
11
|
$DumpModule ||= 'YAML::PP'; |
57
|
3
|
0
|
|
|
|
21
|
my $dump_type = |
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
58
|
|
|
|
|
|
|
(substr($DumpModule, 0, 4) eq 'YAML') ? 'yaml' : |
59
|
|
|
|
|
|
|
(substr($DumpModule, 0, 4) eq 'JSON') ? 'json' : |
60
|
|
|
|
|
|
|
($DumpModule eq 'Data::Dumper') ? 'dumper' : |
61
|
|
|
|
|
|
|
($DumpModule eq 'Data::Dump') ? 'dump' : |
62
|
|
|
|
|
|
|
($DumpModule eq 'Data::Dump::Color') ? 'dumpcolor' : |
63
|
|
|
|
|
|
|
die 'Invalid dump module in $DumpModule'; |
64
|
3
|
100
|
|
|
|
6
|
if (not defined ${"$DumpModule\::VERSION"}) { |
|
3
|
|
|
|
|
18
|
|
65
|
2
|
50
|
|
|
|
172
|
eval "require $DumpModule; 1" or die $@; |
66
|
|
|
|
|
|
|
} |
67
|
3
|
100
|
|
|
|
42
|
if ($DumpModule eq 'YAML::PP') { |
68
|
2
|
|
|
|
|
50
|
return YAML::PP->new(schema => ['Core', 'Perl'])->dump_string(@_) . "...\n"; |
69
|
|
|
|
|
|
|
} |
70
|
1
|
50
|
|
|
|
3
|
if ($dump_type eq 'yaml') { |
71
|
0
|
|
|
|
|
0
|
return &{"$DumpModule\::Dump"}(@_) . "...\n"; |
|
0
|
|
|
|
|
0
|
|
72
|
|
|
|
|
|
|
} |
73
|
1
|
50
|
|
|
|
4
|
if ($dump_type eq 'json') { |
74
|
0
|
|
|
|
|
0
|
return &{"$DumpModule\::encode_json"}(@_); |
|
0
|
|
|
|
|
0
|
|
75
|
|
|
|
|
|
|
} |
76
|
1
|
50
|
|
|
|
3
|
if ($dump_type eq 'dumper') { |
77
|
1
|
|
|
|
|
2
|
local $Data::Dumper::Sortkeys = 1; |
78
|
1
|
|
|
|
|
2
|
local $Data::Dumper::Indent = 2; |
79
|
1
|
|
|
|
|
6
|
return Data::Dumper::Dumper(@_); |
80
|
|
|
|
|
|
|
} |
81
|
0
|
0
|
|
|
|
0
|
if ($dump_type eq 'dump') { |
82
|
0
|
|
|
|
|
0
|
return Data::Dump::dump(@_) . "\n"; |
83
|
|
|
|
|
|
|
} |
84
|
0
|
0
|
|
|
|
0
|
if ($dump_type eq 'dumpcolor') { |
85
|
0
|
|
|
|
|
0
|
return Data::Dump::Color::dump(@_) . "\n"; |
86
|
|
|
|
|
|
|
} |
87
|
0
|
|
|
|
|
0
|
die "XXX had an internal error"; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub _at_line_number { |
91
|
3
|
|
|
3
|
|
21718
|
my ($file_path, $line_number); |
92
|
3
|
|
|
|
|
8
|
my $caller = 0; |
93
|
3
|
|
|
|
|
13
|
while (++$caller) { |
94
|
4
|
|
|
4
|
|
30
|
no strict 'refs'; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
1464
|
|
95
|
3
|
|
|
|
|
58
|
my $skipper = (caller($caller))[0] . "::XXX_skip"; |
96
|
3
|
50
|
33
|
|
|
33
|
next if defined &$skipper and &$skipper(); |
97
|
3
|
|
|
|
|
18
|
($file_path, $line_number) = (caller($caller))[1,2]; |
98
|
3
|
|
|
|
|
9
|
last; |
99
|
|
|
|
|
|
|
} |
100
|
3
|
|
|
|
|
28
|
" at $file_path line $line_number\n"; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub WWW { |
104
|
0
|
|
|
0
|
1
|
0
|
my $dump = _xxx_dump(@_) . _at_line_number(); |
105
|
0
|
0
|
0
|
|
|
0
|
if (defined &main::diag and |
|
|
|
0
|
|
|
|
|
106
|
|
|
|
|
|
|
defined &Test::More::diag and |
107
|
|
|
|
|
|
|
\&main::diag eq \&Test::More::diag |
108
|
|
|
|
|
|
|
) { |
109
|
0
|
|
|
|
|
0
|
main::diag($dump); |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
else { |
112
|
0
|
|
|
|
|
0
|
warn($dump); |
113
|
|
|
|
|
|
|
} |
114
|
0
|
0
|
|
|
|
0
|
return wantarray ? @_ : $_[0]; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub XXX { |
118
|
3
|
|
|
3
|
1
|
977
|
die _xxx_dump(@_) . _at_line_number(); |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub YYY { |
122
|
0
|
|
|
0
|
1
|
|
my $dump = _xxx_dump(@_) . _at_line_number(); |
123
|
0
|
0
|
0
|
|
|
|
if (defined &main::note and |
|
|
|
0
|
|
|
|
|
124
|
|
|
|
|
|
|
defined &Test::More::note and |
125
|
|
|
|
|
|
|
\&main::note eq \&Test::More::note |
126
|
|
|
|
|
|
|
) { |
127
|
0
|
|
|
|
|
|
main::note($dump); |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
else { |
130
|
0
|
|
|
|
|
|
print($dump); |
131
|
|
|
|
|
|
|
} |
132
|
0
|
0
|
|
|
|
|
return wantarray ? @_ : $_[0]; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub ZZZ { |
136
|
0
|
|
|
0
|
1
|
|
require Carp; |
137
|
0
|
|
|
|
|
|
Carp::confess(_xxx_dump(@_)); |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
1; |