| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Test::YAML; |
|
2
|
|
|
|
|
|
|
our $VERSION = '1.07'; |
|
3
|
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
1075
|
use Test::Base -Base; |
|
|
1
|
|
|
|
|
25284
|
|
|
|
1
|
|
|
|
|
5
|
|
|
5
|
1
|
|
|
1
|
|
2795
|
|
|
|
1
|
|
|
1
|
|
3
|
|
|
|
1
|
|
|
1
|
|
22
|
|
|
|
1
|
|
|
1
|
|
5
|
|
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
27
|
|
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
13
|
|
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
825
|
|
|
6
|
|
|
|
|
|
|
our $YAML = 'YAML'; |
|
7
|
|
|
|
|
|
|
our @EXPORT = qw( |
|
8
|
|
|
|
|
|
|
no_diff |
|
9
|
|
|
|
|
|
|
run_yaml_tests |
|
10
|
|
|
|
|
|
|
run_roundtrip_nyn roundtrip_nyn |
|
11
|
|
|
|
|
|
|
run_load_passes load_passes |
|
12
|
|
|
|
|
|
|
dumper Load Dump LoadFile DumpFile |
|
13
|
|
|
|
|
|
|
XXX |
|
14
|
|
|
|
|
|
|
); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
delimiters('===', '+++'); |
|
17
|
|
|
|
|
|
|
|
|
18
|
0
|
|
|
0
|
0
|
|
sub Dump () { YAML(Dump => @_) } |
|
19
|
0
|
|
|
0
|
0
|
|
sub Load () { YAML(Load => @_) } |
|
20
|
0
|
|
|
0
|
0
|
|
sub DumpFile () { YAML(DumpFile => @_) } |
|
21
|
0
|
|
|
0
|
0
|
|
sub LoadFile () { YAML(LoadFile => @_) } |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub YAML () { |
|
24
|
0
|
|
|
0
|
0
|
|
load_yaml_pm(); |
|
25
|
0
|
|
|
|
|
|
my $meth = shift; |
|
26
|
0
|
0
|
|
|
|
|
my $code = $YAML->can($meth) or die "$YAML cannot do $meth"; |
|
27
|
0
|
|
|
|
|
|
goto &$code; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
0
|
|
|
0
|
0
|
|
sub load_yaml_pm { |
|
31
|
0
|
|
|
|
|
|
my $file = "$YAML.pm"; |
|
32
|
0
|
|
|
|
|
|
$file =~ s{::}{/}g; |
|
33
|
0
|
|
|
|
|
|
require $file; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub run_yaml_tests() { |
|
37
|
|
|
|
|
|
|
run { |
|
38
|
0
|
|
|
0
|
|
|
my $block = shift; |
|
39
|
0
|
0
|
0
|
|
|
|
&{_get_function($block)}($block) unless |
|
|
0
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
_skip_tests_for_now($block) or |
|
41
|
|
|
|
|
|
|
_skip_yaml_tests($block); |
|
42
|
0
|
|
|
0
|
0
|
|
}; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub run_roundtrip_nyn() { |
|
46
|
0
|
|
|
0
|
0
|
|
my @options = @_; |
|
47
|
|
|
|
|
|
|
run { |
|
48
|
0
|
|
|
0
|
|
|
my $block = shift; |
|
49
|
0
|
|
|
|
|
|
roundtrip_nyn($block, @options); |
|
50
|
0
|
|
|
|
|
|
}; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub roundtrip_nyn() { |
|
54
|
0
|
|
|
0
|
0
|
|
my $block = shift; |
|
55
|
0
|
|
0
|
|
|
|
my $option = shift || ''; |
|
56
|
|
|
|
|
|
|
die "'perl' data section required" |
|
57
|
0
|
0
|
|
|
|
|
unless exists $block->{perl}; |
|
58
|
0
|
|
|
|
|
|
my @values = eval $block->perl; |
|
59
|
0
|
0
|
|
|
|
|
die "roundtrip_nyn eval perl error: $@" if $@; |
|
60
|
0
|
|
0
|
|
|
|
my $config = $block->config || ''; |
|
61
|
0
|
|
|
|
|
|
my $result = eval "$config; Dump(\@values)"; |
|
62
|
0
|
0
|
|
|
|
|
die "roundtrip_nyn YAML::Dump error: $@" if $@; |
|
63
|
0
|
0
|
|
|
|
|
if (exists $block->{yaml}) { |
|
64
|
0
|
|
|
|
|
|
is $result, $block->yaml, |
|
65
|
|
|
|
|
|
|
$block->description . ' (n->y)'; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
else { |
|
68
|
0
|
|
|
|
|
|
pass $block->description . ' (n->y)'; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
return if exists $block->{no_round_trip} or |
|
72
|
0
|
0
|
0
|
|
|
|
not exists $block->{yaml}; |
|
73
|
|
|
|
|
|
|
|
|
74
|
0
|
0
|
|
|
|
|
if ($option eq 'dumper') { |
|
75
|
0
|
|
|
|
|
|
is dumper(Load($block->yaml)), dumper(@values), |
|
76
|
|
|
|
|
|
|
$block->description . ' (y->n)'; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
else { |
|
79
|
0
|
|
|
|
|
|
is_deeply [Load($block->yaml)], [@values], |
|
80
|
|
|
|
|
|
|
$block->description . ' (y->n)'; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub count_roundtrip_nyn() { |
|
85
|
0
|
0
|
|
0
|
0
|
|
my $block = shift or die "Bad call to count_roundtrip_nyn"; |
|
86
|
0
|
0
|
|
|
|
|
return 1 if exists $block->{skip_this_for_now}; |
|
87
|
0
|
|
|
|
|
|
my $count = 0; |
|
88
|
0
|
0
|
|
|
|
|
$count++ if exists $block->{perl}; |
|
89
|
|
|
|
|
|
|
$count++ unless exists $block->{no_round_trip} or |
|
90
|
0
|
0
|
0
|
|
|
|
not exists $block->{yaml}; |
|
91
|
0
|
0
|
|
|
|
|
die "Invalid test definition" unless $count; |
|
92
|
0
|
|
|
|
|
|
return $count; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub run_load_passes() { |
|
96
|
|
|
|
|
|
|
run { |
|
97
|
0
|
|
|
0
|
|
|
my $block = shift; |
|
98
|
0
|
|
|
|
|
|
my $yaml = $block->yaml; |
|
99
|
0
|
|
|
|
|
|
eval { YAML(Load => $yaml) }; |
|
|
0
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
is("$@", ""); |
|
101
|
0
|
|
|
0
|
0
|
|
}; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub load_passes() { |
|
105
|
0
|
|
|
0
|
0
|
|
my $block = shift; |
|
106
|
0
|
|
|
|
|
|
my $yaml = $block->yaml; |
|
107
|
0
|
|
|
|
|
|
eval { YAML(Load => $yaml) }; |
|
|
0
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
is "$@", "", $block->description; |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
0
|
|
|
0
|
0
|
|
sub count_load_passes() {1} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub dumper() { |
|
114
|
0
|
|
|
0
|
0
|
|
require Data::Dumper; |
|
115
|
0
|
|
|
|
|
|
$Data::Dumper::Sortkeys = 1; |
|
116
|
0
|
|
|
|
|
|
$Data::Dumper::Terse = 1; |
|
117
|
0
|
|
|
|
|
|
$Data::Dumper::Indent = 1; |
|
118
|
0
|
|
|
|
|
|
return Data::Dumper::Dumper(@_); |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub _count_tests() { |
|
122
|
0
|
0
|
|
0
|
|
|
my $block = shift or die "Bad call to _count_tests"; |
|
123
|
1
|
|
|
1
|
|
7
|
no strict 'refs'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
103
|
|
|
124
|
0
|
|
|
|
|
|
&{'count_' . _get_function_name($block)}($block); |
|
|
0
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub _get_function_name() { |
|
128
|
0
|
|
|
0
|
|
|
my $block = shift; |
|
129
|
0
|
|
0
|
|
|
|
return $block->function || 'roundtrip_nyn'; |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub _get_function() { |
|
133
|
0
|
|
|
0
|
|
|
my $block = shift; |
|
134
|
1
|
|
|
1
|
|
6
|
no strict 'refs'; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
263
|
|
|
135
|
0
|
|
|
|
|
|
\ &{_get_function_name($block)}; |
|
|
0
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
} |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub _skip_tests_for_now() { |
|
139
|
0
|
|
|
0
|
|
|
my $block = shift; |
|
140
|
0
|
0
|
|
|
|
|
if (exists $block->{skip_this_for_now}) { |
|
141
|
0
|
|
|
|
|
|
_skip_test( |
|
142
|
|
|
|
|
|
|
$block->description, |
|
143
|
|
|
|
|
|
|
_count_tests($block), |
|
144
|
|
|
|
|
|
|
); |
|
145
|
0
|
|
|
|
|
|
return 1; |
|
146
|
|
|
|
|
|
|
} |
|
147
|
0
|
|
|
|
|
|
return 0; |
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub _skip_yaml_tests() { |
|
151
|
0
|
|
|
0
|
|
|
my $block = shift; |
|
152
|
0
|
0
|
|
|
|
|
if ($block->skip_unless_modules) { |
|
153
|
0
|
|
|
|
|
|
my @modules = split /[\s\,]+/, $block->skip_unless_modules; |
|
154
|
0
|
|
|
|
|
|
for my $module (@modules) { |
|
155
|
0
|
|
|
|
|
|
eval "require $module"; |
|
156
|
0
|
0
|
|
|
|
|
if ($@) { |
|
157
|
0
|
|
|
|
|
|
_skip_test( |
|
158
|
|
|
|
|
|
|
"This test requires the '$module' module", |
|
159
|
|
|
|
|
|
|
_count_tests($block), |
|
160
|
|
|
|
|
|
|
); |
|
161
|
0
|
|
|
|
|
|
return 1; |
|
162
|
|
|
|
|
|
|
} |
|
163
|
|
|
|
|
|
|
} |
|
164
|
|
|
|
|
|
|
} |
|
165
|
0
|
|
|
|
|
|
return 0; |
|
166
|
|
|
|
|
|
|
} |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
sub _skip_test() { |
|
169
|
0
|
|
|
0
|
|
|
my ($message, $count) = @_; |
|
170
|
|
|
|
|
|
|
SKIP: { |
|
171
|
0
|
|
|
|
|
|
skip($message, $count); |
|
|
0
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
} |
|
173
|
|
|
|
|
|
|
} |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
|
176
|
|
|
|
|
|
|
package Test::YAML::Filter; |
|
177
|
|
|
|
|
|
|
|
|
178
|
1
|
|
|
1
|
|
537
|
use Test::Base::Filter (); |
|
|
1
|
|
|
|
|
4835
|
|
|
|
1
|
|
|
|
|
388
|
|
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
our @ISA = 'Test::Base::Filter'; |
|
181
|
|
|
|
|
|
|
|
|
182
|
0
|
|
|
0
|
|
|
sub yaml_dump { |
|
183
|
0
|
|
|
|
|
|
Test::YAML::Dump(@_); |
|
184
|
|
|
|
|
|
|
} |
|
185
|
|
|
|
|
|
|
|
|
186
|
0
|
|
|
0
|
|
|
sub yaml_load { |
|
187
|
0
|
|
|
|
|
|
Test::YAML::Load(@_); |
|
188
|
|
|
|
|
|
|
} |
|
189
|
|
|
|
|
|
|
|
|
190
|
0
|
|
|
0
|
|
|
sub Dump { goto &Test::YAML::Dump } |
|
|
0
|
|
|
|
|
|
|
|
191
|
0
|
|
|
0
|
|
|
sub Load { goto &Test::YAML::Load } |
|
|
0
|
|
|
|
|
|
|
|
192
|
0
|
|
|
0
|
|
|
sub DumpFile { goto &Test::YAML::DumpFile } |
|
|
0
|
|
|
|
|
|
|
|
193
|
0
|
|
|
0
|
|
|
sub LoadFile { goto &Test::YAML::LoadFile } |
|
|
0
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
|
|
195
|
0
|
|
|
0
|
|
|
sub yaml_load_or_fail { |
|
196
|
0
|
|
|
|
|
|
my ($result, $error, $warning) = |
|
197
|
|
|
|
|
|
|
$self->_yaml_load_result_error_warning(@_); |
|
198
|
0
|
|
0
|
|
|
|
return $error || $result; |
|
199
|
|
|
|
|
|
|
} |
|
200
|
|
|
|
|
|
|
|
|
201
|
0
|
|
|
0
|
|
|
sub yaml_load_error_or_warning { |
|
202
|
0
|
|
|
|
|
|
my ($result, $error, $warning) = |
|
203
|
|
|
|
|
|
|
$self->_yaml_load_result_error_warning(@_); |
|
204
|
0
|
|
0
|
|
|
|
return $error || $warning || ''; |
|
205
|
|
|
|
|
|
|
} |
|
206
|
|
|
|
|
|
|
|
|
207
|
0
|
|
|
0
|
|
|
sub perl_eval_error_or_warning { |
|
208
|
0
|
|
|
|
|
|
my ($result, $error, $warning) = |
|
209
|
|
|
|
|
|
|
$self->_perl_eval_result_error_warning(@_); |
|
210
|
0
|
|
0
|
|
|
|
return $error || $warning || ''; |
|
211
|
|
|
|
|
|
|
} |
|
212
|
|
|
|
|
|
|
|
|
213
|
0
|
|
|
0
|
|
|
sub _yaml_load_result_error_warning { |
|
214
|
0
|
|
|
|
|
|
$self->assert_scalar(@_); |
|
215
|
0
|
|
|
|
|
|
my $yaml = shift; |
|
216
|
0
|
|
|
|
|
|
my $warning = ''; |
|
217
|
0
|
|
|
0
|
|
|
local $SIG{__WARN__} = sub { $warning = join '', @_ }; |
|
|
0
|
|
|
|
|
|
|
|
218
|
0
|
|
|
|
|
|
my $result = eval { |
|
219
|
0
|
|
|
|
|
|
$self->yaml_load($yaml); |
|
220
|
|
|
|
|
|
|
}; |
|
221
|
0
|
|
|
|
|
|
return ($result, $@, $warning); |
|
222
|
|
|
|
|
|
|
} |
|
223
|
|
|
|
|
|
|
|
|
224
|
0
|
|
|
0
|
|
|
sub _perl_eval_result_error_warning { |
|
225
|
0
|
|
|
|
|
|
$self->assert_scalar(@_); |
|
226
|
0
|
|
|
|
|
|
my $perl = shift; |
|
227
|
0
|
|
|
|
|
|
my $warning = ''; |
|
228
|
0
|
|
|
0
|
|
|
local $SIG{__WARN__} = sub { $warning = join '', @_ }; |
|
|
0
|
|
|
|
|
|
|
|
229
|
0
|
|
|
|
|
|
my $result = eval $perl; |
|
230
|
0
|
|
|
|
|
|
return ($result, $@, $warning); |
|
231
|
|
|
|
|
|
|
} |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
1; |