File: trailing-comments-content.t

package info (click to toggle)
libyaml-perl 1.31-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 672 kB
  • sloc: perl: 2,294; makefile: 2
file content (76 lines) | stat: -rw-r--r-- 1,360 bytes parent folder | download | duplicates (4)
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
use strict;
use lib -e 't' ? 't' : 'test';
use TestYAML tests => 6;

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 simple mapping value
+++ yaml
---
foo: val #comment val
+++ perl
{ foo => "val" }

=== Comment after simple sequence value
+++ yaml
---
foo:
 - s2 #comment s2
+++ perl
{ foo => ['s2'] }

=== Comment after simple sequence value (2)
+++ yaml
---
- s2 #comment s1
+++ perl
['s2']

=== Comment after simple top level scalar
+++ yaml
--- abc # comment abc
+++ perl
'abc'

=== Comment after empty mapping value
+++ yaml
---
foo:  #comment foo
bar: #comment bar
+++ perl
{ foo => undef, bar => undef }

=== Comment after empty sequence value
+++ yaml
---
foo:
 - # empty sequence value
+++ perl
{ foo => [''] }