line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
42
|
|
|
42
|
|
738043
|
use strict; |
|
42
|
|
|
|
|
176
|
|
|
42
|
|
|
|
|
1257
|
|
2
|
42
|
|
|
42
|
|
219
|
use warnings; |
|
42
|
|
|
|
|
77
|
|
|
42
|
|
|
|
|
2007
|
|
3
|
|
|
|
|
|
|
package YAML::PP::Common; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.036_001'; # TRIAL VERSION |
6
|
|
|
|
|
|
|
|
7
|
42
|
|
|
42
|
|
277
|
use base 'Exporter'; |
|
42
|
|
|
|
|
80
|
|
|
42
|
|
|
|
|
10881
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my @p = qw/ |
10
|
|
|
|
|
|
|
PRESERVE_ALL PRESERVE_ORDER PRESERVE_SCALAR_STYLE PRESERVE_FLOW_STYLE |
11
|
|
|
|
|
|
|
PRESERVE_ALIAS |
12
|
|
|
|
|
|
|
/; |
13
|
|
|
|
|
|
|
my @s = qw/ |
14
|
|
|
|
|
|
|
YAML_ANY_SCALAR_STYLE YAML_PLAIN_SCALAR_STYLE |
15
|
|
|
|
|
|
|
YAML_SINGLE_QUOTED_SCALAR_STYLE YAML_DOUBLE_QUOTED_SCALAR_STYLE |
16
|
|
|
|
|
|
|
YAML_LITERAL_SCALAR_STYLE YAML_FOLDED_SCALAR_STYLE |
17
|
|
|
|
|
|
|
YAML_QUOTED_SCALAR_STYLE |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
YAML_ANY_SEQUENCE_STYLE |
20
|
|
|
|
|
|
|
YAML_BLOCK_SEQUENCE_STYLE YAML_FLOW_SEQUENCE_STYLE |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
YAML_ANY_MAPPING_STYLE |
23
|
|
|
|
|
|
|
YAML_BLOCK_MAPPING_STYLE YAML_FLOW_MAPPING_STYLE |
24
|
|
|
|
|
|
|
/; |
25
|
|
|
|
|
|
|
our @EXPORT_OK = (@s, @p); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
28
|
|
|
|
|
|
|
PRESERVE => [@p], |
29
|
|
|
|
|
|
|
STYLES => [@s], |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
use constant { |
33
|
42
|
|
|
|
|
52483
|
YAML_ANY_SCALAR_STYLE => 0, |
34
|
|
|
|
|
|
|
YAML_PLAIN_SCALAR_STYLE => 1, |
35
|
|
|
|
|
|
|
YAML_SINGLE_QUOTED_SCALAR_STYLE => 2, |
36
|
|
|
|
|
|
|
YAML_DOUBLE_QUOTED_SCALAR_STYLE => 3, |
37
|
|
|
|
|
|
|
YAML_LITERAL_SCALAR_STYLE => 4, |
38
|
|
|
|
|
|
|
YAML_FOLDED_SCALAR_STYLE => 5, |
39
|
|
|
|
|
|
|
YAML_QUOTED_SCALAR_STYLE => 'Q', # deprecated |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
YAML_ANY_SEQUENCE_STYLE => 0, |
42
|
|
|
|
|
|
|
YAML_BLOCK_SEQUENCE_STYLE => 1, |
43
|
|
|
|
|
|
|
YAML_FLOW_SEQUENCE_STYLE => 2, |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
YAML_ANY_MAPPING_STYLE => 0, |
46
|
|
|
|
|
|
|
YAML_BLOCK_MAPPING_STYLE => 1, |
47
|
|
|
|
|
|
|
YAML_FLOW_MAPPING_STYLE => 2, |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
PRESERVE_ORDER => 2, |
50
|
|
|
|
|
|
|
PRESERVE_SCALAR_STYLE => 4, |
51
|
|
|
|
|
|
|
PRESERVE_FLOW_STYLE => 8, |
52
|
|
|
|
|
|
|
PRESERVE_ALIAS => 16, |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
PRESERVE_ALL => 31, |
55
|
42
|
|
|
42
|
|
392
|
}; |
|
42
|
|
|
|
|
101
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my %scalar_style_to_string = ( |
58
|
|
|
|
|
|
|
YAML_PLAIN_SCALAR_STYLE() => ':', |
59
|
|
|
|
|
|
|
YAML_SINGLE_QUOTED_SCALAR_STYLE() => "'", |
60
|
|
|
|
|
|
|
YAML_DOUBLE_QUOTED_SCALAR_STYLE() => '"', |
61
|
|
|
|
|
|
|
YAML_LITERAL_SCALAR_STYLE() => '|', |
62
|
|
|
|
|
|
|
YAML_FOLDED_SCALAR_STYLE() => '>', |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub event_to_test_suite { |
67
|
48327
|
|
|
48327
|
1
|
368189
|
my ($event, $args) = @_; |
68
|
48327
|
|
|
|
|
73908
|
my $ev = $event->{name}; |
69
|
48327
|
|
|
|
|
59965
|
my $string; |
70
|
48327
|
|
|
|
|
71916
|
my $content = $event->{value}; |
71
|
|
|
|
|
|
|
|
72
|
48327
|
|
|
|
|
64967
|
my $properties = ''; |
73
|
48327
|
100
|
|
|
|
94346
|
$properties .= " &$event->{anchor}" if defined $event->{anchor}; |
74
|
48327
|
100
|
|
|
|
87979
|
$properties .= " <$event->{tag}>" if defined $event->{tag}; |
75
|
|
|
|
|
|
|
|
76
|
48327
|
100
|
|
|
|
180272
|
if ($ev eq 'document_start_event') { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
77
|
4610
|
|
|
|
|
6704
|
$string = "+DOC"; |
78
|
4610
|
100
|
|
|
|
10879
|
$string .= " ---" unless $event->{implicit}; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
elsif ($ev eq 'document_end_event') { |
81
|
4524
|
|
|
|
|
6472
|
$string = "-DOC"; |
82
|
4524
|
100
|
|
|
|
8836
|
$string .= " ..." unless $event->{implicit}; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
elsif ($ev eq 'stream_start_event') { |
85
|
4198
|
|
|
|
|
6283
|
$string = "+STR"; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
elsif ($ev eq 'stream_end_event') { |
88
|
4102
|
|
|
|
|
5773
|
$string = "-STR"; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
elsif ($ev eq 'mapping_start_event') { |
91
|
4049
|
|
|
|
|
5772
|
$string = "+MAP"; |
92
|
4049
|
100
|
66
|
|
|
10433
|
if ($event->{style} and $event->{style} eq YAML_FLOW_MAPPING_STYLE) { |
93
|
1029
|
100
|
|
|
|
2197
|
$string .= ' {}' if $args->{flow}; |
94
|
|
|
|
|
|
|
} |
95
|
4049
|
|
|
|
|
6425
|
$string .= $properties; |
96
|
4049
|
|
|
|
|
5171
|
if (0) { |
97
|
|
|
|
|
|
|
# doesn't match yaml-test-suite format |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
elsif ($ev eq 'sequence_start_event') { |
101
|
2628
|
|
|
|
|
3694
|
$string = "+SEQ"; |
102
|
2628
|
100
|
66
|
|
|
7039
|
if ($event->{style} and $event->{style} eq YAML_FLOW_SEQUENCE_STYLE) { |
103
|
734
|
100
|
|
|
|
1792
|
$string .= ' []' if $args->{flow}; |
104
|
|
|
|
|
|
|
} |
105
|
2628
|
|
|
|
|
4359
|
$string .= $properties; |
106
|
2628
|
|
|
|
|
3526
|
if (0) { |
107
|
|
|
|
|
|
|
# doesn't match yaml-test-suite format |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
elsif ($ev eq 'mapping_end_event') { |
111
|
3998
|
|
|
|
|
5981
|
$string = "-MAP"; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
elsif ($ev eq 'sequence_end_event') { |
114
|
2604
|
|
|
|
|
3839
|
$string = "-SEQ"; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
elsif ($ev eq 'scalar_event') { |
117
|
17303
|
|
|
|
|
24732
|
$string = '=VAL'; |
118
|
17303
|
|
|
|
|
28806
|
$string .= $properties; |
119
|
|
|
|
|
|
|
|
120
|
17303
|
|
|
|
|
37771
|
$content =~ s/\\/\\\\/g; |
121
|
17303
|
|
|
|
|
26352
|
$content =~ s/\t/\\t/g; |
122
|
17303
|
|
|
|
|
24447
|
$content =~ s/\r/\\r/g; |
123
|
17303
|
|
|
|
|
26573
|
$content =~ s/\n/\\n/g; |
124
|
17303
|
|
|
|
|
24013
|
$content =~ s/[\b]/\\b/g; |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
$string .= ' ' |
127
|
|
|
|
|
|
|
. $scalar_style_to_string{ $event->{style} } |
128
|
17303
|
|
|
|
|
43484
|
. $content; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
elsif ($ev eq 'alias_event') { |
131
|
311
|
|
|
|
|
614
|
$string = "=ALI *$content"; |
132
|
|
|
|
|
|
|
} |
133
|
48327
|
|
|
|
|
139765
|
return $string; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub test_suite_to_event { |
137
|
30
|
|
|
30
|
1
|
127
|
my ($str) = @_; |
138
|
30
|
|
|
|
|
45
|
my $event = {}; |
139
|
30
|
100
|
|
|
|
227
|
if ($str =~ s/^\+STR//) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
140
|
1
|
|
|
|
|
3
|
$event->{name} = 'stream_start_event'; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
elsif ($str =~ s/^\-STR//) { |
143
|
1
|
|
|
|
|
4
|
$event->{name} = 'stream_end_event'; |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
elsif ($str =~ s/^\+DOC//) { |
146
|
1
|
|
|
|
|
3
|
$event->{name} = 'document_start_event'; |
147
|
1
|
50
|
|
|
|
4
|
if ($str =~ s/^ ---//) { |
148
|
1
|
|
|
|
|
2
|
$event->{implicit} = 0; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
else { |
151
|
0
|
|
|
|
|
0
|
$event->{implicit} = 1; |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
elsif ($str =~ s/^\-DOC//) { |
155
|
1
|
|
|
|
|
2
|
$event->{name} = 'document_end_event'; |
156
|
1
|
50
|
|
|
|
4
|
if ($str =~ s/^ \.\.\.//) { |
157
|
0
|
|
|
|
|
0
|
$event->{implicit} = 0; |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
else { |
160
|
1
|
|
|
|
|
3
|
$event->{implicit} = 1; |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
elsif ($str =~ s/^\+SEQ//) { |
164
|
3
|
|
|
|
|
6
|
$event->{name} = 'sequence_start_event'; |
165
|
3
|
50
|
|
|
|
9
|
if ($str =~ s/^ \&(\S+)//) { |
166
|
0
|
|
|
|
|
0
|
$event->{anchor} = $1; |
167
|
|
|
|
|
|
|
} |
168
|
3
|
100
|
|
|
|
17
|
if ($str =~ s/^ <(\S+)>//) { |
169
|
1
|
|
|
|
|
5
|
$event->{tag} = $1; |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
elsif ($str =~ s/^\-SEQ//) { |
173
|
3
|
|
|
|
|
6
|
$event->{name} = 'sequence_end_event'; |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
elsif ($str =~ s/^\+MAP//) { |
176
|
5
|
|
|
|
|
10
|
$event->{name} = 'mapping_start_event'; |
177
|
5
|
100
|
|
|
|
15
|
if ($str =~ s/^ \&(\S+)//) { |
178
|
1
|
|
|
|
|
5
|
$event->{anchor} = $1; |
179
|
|
|
|
|
|
|
} |
180
|
5
|
100
|
|
|
|
16
|
if ($str =~ s/^ <(\S+)>//) { |
181
|
2
|
|
|
|
|
7
|
$event->{tag} = $1; |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
elsif ($str =~ s/^\-MAP//) { |
185
|
5
|
|
|
|
|
11
|
$event->{name} = 'mapping_end_event'; |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
elsif ($str =~ s/^=VAL//) { |
188
|
4
|
|
|
|
|
11
|
$event->{name} = 'scalar_event'; |
189
|
4
|
100
|
|
|
|
42
|
if ($str =~ s/^ <(\S+)>//) { |
190
|
1
|
|
|
|
|
4
|
$event->{tag} = $1; |
191
|
|
|
|
|
|
|
} |
192
|
4
|
50
|
|
|
|
16
|
if ($str =~ s/^ [:'">|]//) { |
193
|
4
|
|
|
|
|
11
|
$event->{style} = $1; |
194
|
|
|
|
|
|
|
} |
195
|
4
|
50
|
|
|
|
14
|
if ($str =~ s/^(.*)//) { |
196
|
4
|
|
|
|
|
11
|
$event->{value} = $1; |
197
|
|
|
|
|
|
|
} |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
elsif ($str =~ s/^=ALI//) { |
200
|
6
|
|
|
|
|
13
|
$event->{name} = 'alias_event'; |
201
|
6
|
50
|
|
|
|
22
|
if ($str =~ s/^ \*(.*)//) { |
202
|
6
|
|
|
|
|
17
|
$event->{value} = $1; |
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
} |
205
|
|
|
|
|
|
|
else { |
206
|
0
|
|
|
|
|
0
|
die "Could not parse event '$str'"; |
207
|
|
|
|
|
|
|
} |
208
|
30
|
|
|
|
|
61
|
return $event; |
209
|
|
|
|
|
|
|
} |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
1; |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
__END__ |