1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
use strict;
use lib -e 't' ? 't' : 'test';
use TestYAML tests => 7;
# testing trailing comments which were errors before
run {
my $block = shift;
my @result = eval {
Load($block->yaml)
};
my $error1 = $@ || '';
if ( $error1 ) {
# $error1 =~ s{line: (\d+)}{"line: $1 ($0:".($1+$test->{lines}{yaml}-1).")"}e;
}
my @expect = eval $block->perl;
my $error2 = $@ || '';
if (my $errors = $error1 . $error2) {
fail($block->description
. $errors);
next;
}
is_deeply(
\@result,
\@expect,
$block->description,
) or do {
require Data::Dumper;
diag("Wanted: ".Data::Dumper::Dumper(\@expect));
diag("Got: ".Data::Dumper::Dumper(\@result));
}
};
__DATA__
=== Comment after inline seq
+++ yaml
---
seq: [314] #comment
+++ perl
{ seq => [314] }
=== Comment after inline map
+++ yaml
---
map: {x: y} #comment
+++ perl
{ map => { x => 'y' }, }
=== Comment after literal block scalar indicator
+++ yaml
---
- |- #comment
+++ perl
['']
=== Comment after folded block scalar indicator
+++ yaml
---
- >- #comment
+++ perl
['']
=== Comment after top level literal block scalar indicator
+++ yaml
--- |- #comment
+++ perl
''
=== Comment after double quoted string
+++ yaml
---
quoted: "string" #comment
+++ perl
{ quoted => 'string' }
=== Comment after single quoted string
+++ yaml
---
quoted: 'string' #comment
+++ perl
{ quoted => 'string' }
|