line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package # hide from PAUSE |
2
|
|
|
|
|
|
|
DBIx::Class::Schema::Loader::Utils; |
3
|
|
|
|
|
|
|
|
4
|
24
|
|
|
24
|
|
566448
|
use strict; |
|
24
|
|
|
|
|
147
|
|
|
24
|
|
|
|
|
735
|
|
5
|
24
|
|
|
24
|
|
139
|
use warnings; |
|
24
|
|
|
|
|
52
|
|
|
24
|
|
|
|
|
584
|
|
6
|
24
|
|
|
24
|
|
747
|
use Test::More; |
|
24
|
|
|
|
|
65228
|
|
|
24
|
|
|
|
|
285
|
|
7
|
24
|
|
|
24
|
|
18011
|
use String::CamelCase 'wordsplit'; |
|
24
|
|
|
|
|
19255
|
|
|
24
|
|
|
|
|
1880
|
|
8
|
24
|
|
|
24
|
|
4510
|
use Carp::Clan qw/^DBIx::Class/; |
|
24
|
|
|
|
|
36917
|
|
|
24
|
|
|
|
|
237
|
|
9
|
24
|
|
|
24
|
|
2904
|
use List::Util 'all'; |
|
24
|
|
|
|
|
65
|
|
|
24
|
|
|
|
|
2918
|
|
10
|
24
|
|
|
24
|
|
4926
|
use namespace::clean; |
|
24
|
|
|
|
|
158123
|
|
|
24
|
|
|
|
|
216
|
|
11
|
24
|
|
|
24
|
|
14653
|
use Exporter 'import'; |
|
24
|
|
|
|
|
79
|
|
|
24
|
|
|
|
|
703
|
|
12
|
24
|
|
|
24
|
|
15340
|
use Data::Dumper (); |
|
24
|
|
|
|
|
162646
|
|
|
24
|
|
|
|
|
6773
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our @EXPORT_OK = qw/split_name dumper dumper_squashed eval_package_without_redefine_warnings class_path no_warnings warnings_exist warnings_exist_silent slurp_file write_file array_eq sigwarn_silencer apply firstidx uniq/; |
15
|
|
|
|
|
|
|
|
16
|
24
|
|
|
|
|
2219
|
use constant BY_CASE_TRANSITION_V7 => |
17
|
24
|
|
|
24
|
|
218
|
qr/(?<=[[:lower:]\d])[\W_]*(?=[[:upper:]])|[\W_]+/; |
|
24
|
|
|
|
|
56
|
|
18
|
|
|
|
|
|
|
|
19
|
24
|
|
|
|
|
18485
|
use constant BY_NON_ALPHANUM => |
20
|
24
|
|
|
24
|
|
184
|
qr/[\W_]+/; |
|
24
|
|
|
|
|
68
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $LF = "\x0a"; |
23
|
|
|
|
|
|
|
my $CRLF = "\x0d\x0a"; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub split_name($;$) { |
26
|
5472
|
|
|
5472
|
0
|
18096
|
my ($name, $v) = @_; |
27
|
|
|
|
|
|
|
|
28
|
5472
|
|
100
|
|
|
15809
|
my $is_camel_case = $name =~ /[[:upper:]]/ && $name =~ /[[:lower:]]/; |
29
|
|
|
|
|
|
|
|
30
|
5472
|
100
|
66
|
|
|
21730
|
if ((not $v) || $v >= 8) { |
31
|
28
|
|
|
|
|
167
|
return map split(BY_NON_ALPHANUM, $_), wordsplit($name); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
5444
|
100
|
|
|
|
38219
|
return split $is_camel_case ? BY_CASE_TRANSITION_V7 : BY_NON_ALPHANUM, $name; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub dumper($) { |
38
|
0
|
|
|
0
|
0
|
0
|
my $val = shift; |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
0
|
my $dd = Data::Dumper->new([]); |
41
|
0
|
|
|
|
|
0
|
$dd->Terse(1)->Indent(1)->Useqq(1)->Deparse(1)->Quotekeys(0)->Sortkeys(1); |
42
|
0
|
|
|
|
|
0
|
return $dd->Values([ $val ])->Dump; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub dumper_squashed($) { |
46
|
131
|
|
|
131
|
0
|
75752
|
my $val = shift; |
47
|
|
|
|
|
|
|
|
48
|
131
|
|
|
|
|
1174
|
my $dd = Data::Dumper->new([]); |
49
|
131
|
|
|
|
|
6077
|
$dd->Terse(1)->Indent(1)->Useqq(1)->Deparse(1)->Quotekeys(0)->Sortkeys(1)->Indent(0); |
50
|
131
|
|
|
|
|
7146
|
return $dd->Values([ $val ])->Dump; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# copied from DBIx::Class::_Util, import from there once it's released |
54
|
|
|
|
|
|
|
sub sigwarn_silencer { |
55
|
11199
|
|
|
11199
|
0
|
1770960
|
my $pattern = shift; |
56
|
|
|
|
|
|
|
|
57
|
11199
|
50
|
|
|
|
31006
|
croak "Expecting a regexp" if ref $pattern ne 'Regexp'; |
58
|
|
|
|
|
|
|
|
59
|
11199
|
|
100
|
0
|
|
41008
|
my $orig_sig_warn = $SIG{__WARN__} || sub { CORE::warn(@_) }; |
|
0
|
|
|
|
|
0
|
|
60
|
|
|
|
|
|
|
|
61
|
11199
|
100
|
|
92
|
|
58948
|
return sub { &$orig_sig_warn unless $_[0] =~ $pattern }; |
|
92
|
|
|
|
|
15026
|
|
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# Copied with stylistic adjustments from List::MoreUtils::PP |
65
|
|
|
|
|
|
|
sub firstidx (&@) { |
66
|
1307
|
|
|
1307
|
0
|
2617
|
my $f = shift; |
67
|
1307
|
|
|
|
|
4306
|
foreach my $i (0..$#_) { |
68
|
1314
|
|
|
|
|
3491
|
local *_ = \$_[$i]; |
69
|
1314
|
100
|
|
|
|
3498
|
return $i if $f->(); |
70
|
|
|
|
|
|
|
} |
71
|
0
|
|
|
|
|
0
|
return -1; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub uniq (@) { |
75
|
126
|
|
|
126
|
0
|
336
|
my %seen = (); |
76
|
126
|
|
|
|
|
328
|
grep { not $seen{$_}++ } @_; |
|
294
|
|
|
|
|
1599
|
|
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub apply (&@) { |
80
|
1220
|
|
|
1220
|
0
|
15183
|
my $action = shift; |
81
|
1220
|
|
|
|
|
3914
|
$action->() foreach my @values = @_; |
82
|
1220
|
50
|
|
|
|
5332
|
wantarray ? @values : $values[-1]; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub eval_package_without_redefine_warnings { |
86
|
1550
|
|
|
1550
|
0
|
4164
|
my ($pkg, $code) = @_; |
87
|
|
|
|
|
|
|
|
88
|
1550
|
|
|
|
|
8560
|
local $SIG{__WARN__} = sigwarn_silencer(qr/^Subroutine \S+ redefined/); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# This hairiness is to handle people using "use warnings FATAL => 'all';" |
91
|
|
|
|
|
|
|
# in their custom or external content. |
92
|
1550
|
|
|
|
|
3688
|
my @delete_syms; |
93
|
1550
|
|
|
|
|
3099
|
my $try_again = 1; |
94
|
|
|
|
|
|
|
|
95
|
1550
|
|
|
|
|
4817
|
while ($try_again) { |
96
|
1558
|
|
|
3
|
|
124504
|
eval $code; |
|
3
|
|
|
3
|
|
27
|
|
|
3
|
|
|
2
|
|
19
|
|
|
3
|
|
|
1
|
|
112
|
|
|
3
|
|
|
1
|
|
21
|
|
|
3
|
|
|
1
|
|
8
|
|
|
3
|
|
|
|
|
169
|
|
|
2
|
|
|
|
|
703
|
|
|
2
|
|
|
|
|
980
|
|
|
2
|
|
|
|
|
17
|
|
|
2
|
|
|
|
|
18
|
|
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
64
|
|
|
2
|
|
|
|
|
14
|
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
103
|
|
|
2
|
|
|
|
|
15
|
|
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
18
|
|
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
34
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
51
|
|
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
12
|
|
97
|
|
|
|
|
|
|
|
98
|
1558
|
100
|
|
|
|
1573858
|
if (my ($sym) = $@ =~ /^Subroutine (\S+) redefined/) { |
|
|
50
|
|
|
|
|
|
99
|
8
|
|
|
|
|
45
|
delete $INC{ +class_path($pkg) }; |
100
|
8
|
|
|
|
|
31
|
push @delete_syms, $sym; |
101
|
|
|
|
|
|
|
|
102
|
8
|
|
|
|
|
27
|
foreach my $sym (@delete_syms) { |
103
|
24
|
|
|
24
|
|
211
|
no strict 'refs'; |
|
24
|
|
|
|
|
79
|
|
|
24
|
|
|
|
|
18664
|
|
104
|
11
|
|
|
|
|
21
|
undef *{"${pkg}::${sym}"}; |
|
11
|
|
|
|
|
165
|
|
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
elsif ($@) { |
108
|
0
|
0
|
|
|
|
0
|
die $@ if $@; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
else { |
111
|
1550
|
|
|
|
|
18220
|
$try_again = 0; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub class_path { |
117
|
2474
|
|
|
2474
|
0
|
5210
|
my $class = shift; |
118
|
|
|
|
|
|
|
|
119
|
2474
|
|
|
|
|
4977
|
my $class_path = $class; |
120
|
2474
|
|
|
|
|
13304
|
$class_path =~ s{::}{/}g; |
121
|
2474
|
|
|
|
|
6076
|
$class_path .= '.pm'; |
122
|
|
|
|
|
|
|
|
123
|
2474
|
|
|
|
|
11187
|
return $class_path; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub no_warnings(&;$) { |
127
|
0
|
|
|
0
|
0
|
0
|
my ($code, $test_name) = @_; |
128
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
0
|
my $failed = 0; |
130
|
|
|
|
|
|
|
|
131
|
0
|
|
0
|
0
|
|
0
|
my $warn_handler = $SIG{__WARN__} || sub { warn @_ }; |
|
0
|
|
|
|
|
0
|
|
132
|
|
|
|
|
|
|
local $SIG{__WARN__} = sub { |
133
|
0
|
|
|
0
|
|
0
|
$failed = 1; |
134
|
0
|
|
|
|
|
0
|
$warn_handler->(@_); |
135
|
0
|
|
|
|
|
0
|
}; |
136
|
|
|
|
|
|
|
|
137
|
0
|
|
|
|
|
0
|
$code->(); |
138
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
0
|
ok ((not $failed), $test_name); |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub warnings_exist(&$$) { |
143
|
0
|
|
|
0
|
0
|
0
|
my ($code, $re, $test_name) = @_; |
144
|
|
|
|
|
|
|
|
145
|
0
|
|
|
|
|
0
|
my $matched = 0; |
146
|
|
|
|
|
|
|
|
147
|
0
|
|
0
|
0
|
|
0
|
my $warn_handler = $SIG{__WARN__} || sub { warn @_ }; |
|
0
|
|
|
|
|
0
|
|
148
|
|
|
|
|
|
|
local $SIG{__WARN__} = sub { |
149
|
0
|
0
|
|
0
|
|
0
|
if ($_[0] =~ $re) { |
150
|
0
|
|
|
|
|
0
|
$matched = 1; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
else { |
153
|
0
|
|
|
|
|
0
|
$warn_handler->(@_) |
154
|
|
|
|
|
|
|
} |
155
|
0
|
|
|
|
|
0
|
}; |
156
|
|
|
|
|
|
|
|
157
|
0
|
|
|
|
|
0
|
$code->(); |
158
|
|
|
|
|
|
|
|
159
|
0
|
|
|
|
|
0
|
ok $matched, $test_name; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub warnings_exist_silent(&$$) { |
163
|
0
|
|
|
0
|
0
|
0
|
my ($code, $re, $test_name) = @_; |
164
|
|
|
|
|
|
|
|
165
|
0
|
|
|
|
|
0
|
my $matched = 0; |
166
|
|
|
|
|
|
|
|
167
|
0
|
0
|
|
0
|
|
0
|
local $SIG{__WARN__} = sub { $matched = 1 if $_[0] =~ $re; }; |
|
0
|
|
|
|
|
0
|
|
168
|
|
|
|
|
|
|
|
169
|
0
|
|
|
|
|
0
|
$code->(); |
170
|
|
|
|
|
|
|
|
171
|
0
|
|
|
|
|
0
|
ok $matched, $test_name; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
sub slurp_file($) { |
175
|
107
|
|
|
107
|
0
|
845730
|
my $file_name = shift; |
176
|
|
|
|
|
|
|
|
177
|
107
|
50
|
|
|
|
8061
|
open my $fh, '<:encoding(UTF-8)', $file_name, |
178
|
|
|
|
|
|
|
or croak "Can't open '$file_name' for reading: $!"; |
179
|
|
|
|
|
|
|
|
180
|
107
|
|
|
|
|
11312
|
my $data = do { local $/; <$fh> }; |
|
107
|
|
|
|
|
803
|
|
|
107
|
|
|
|
|
8156
|
|
181
|
|
|
|
|
|
|
|
182
|
107
|
|
|
|
|
5702
|
close $fh; |
183
|
|
|
|
|
|
|
|
184
|
107
|
|
|
|
|
12481
|
$data =~ s/$CRLF|$LF/\n/g; |
185
|
|
|
|
|
|
|
|
186
|
107
|
|
|
|
|
1191
|
return $data; |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
sub write_file($$) { |
190
|
1
|
|
|
1
|
0
|
154
|
my $file_name = shift; |
191
|
|
|
|
|
|
|
|
192
|
1
|
50
|
|
|
|
145
|
open my $fh, '>:encoding(UTF-8)', $file_name, |
193
|
|
|
|
|
|
|
or croak "Can't open '$file_name' for writing: $!"; |
194
|
|
|
|
|
|
|
|
195
|
1
|
|
|
|
|
200
|
print $fh shift; |
196
|
1
|
|
|
|
|
176
|
close $fh; |
197
|
|
|
|
|
|
|
} |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
sub array_eq($$) { |
200
|
24
|
|
|
24
|
|
213
|
no warnings 'uninitialized'; |
|
24
|
|
|
|
|
190
|
|
|
24
|
|
|
|
|
3443
|
|
201
|
968
|
|
|
968
|
0
|
8170
|
my ($l, $r) = @_; |
202
|
|
|
|
|
|
|
|
203
|
968
|
|
100
|
613
|
|
11275
|
return @$l == @$r && all { $l->[$_] eq $r->[$_] } 0..$#$l; |
|
613
|
|
|
|
|
7889
|
|
204
|
|
|
|
|
|
|
} |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
1; |
207
|
|
|
|
|
|
|
# vim:et sts=4 sw=4 tw=0: |