chiark / gitweb /
4ed1f2100c66d3b1c7bbf580b946ab74fc7bf47c
[nailing-cargo.git] / t / toml-test / valid / table-array-nest.t
1 # File automatically generated from BurntSushi/toml-test
2 use utf8;
3 use Test2::V0;
4 use Data::Dumper;
5 use TOML::Tiny;
6
7 binmode STDIN,  ':encoding(UTF-8)';
8 binmode STDOUT, ':encoding(UTF-8)';
9
10 my $expected1 = {
11                'albums' => [
12                              {
13                                'name' => 'Born to Run',
14                                'songs' => [
15                                             {
16                                               'name' => 'Jungleland'
17                                             },
18                                             {
19                                               'name' => 'Meeting Across the River'
20                                             }
21                                           ]
22                              },
23                              {
24                                'songs' => [
25                                             {
26                                               'name' => 'Glory Days'
27                                             },
28                                             {
29                                               'name' => 'Dancing in the Dark'
30                                             }
31                                           ],
32                                'name' => 'Born in the USA'
33                              }
34                            ]
35              };
36
37
38 my $actual = from_toml(q{[[albums]]
39 name = "Born to Run"
40
41   [[albums.songs]]
42   name = "Jungleland"
43
44   [[albums.songs]]
45   name = "Meeting Across the River"
46
47 [[albums]]
48 name = "Born in the USA"
49   
50   [[albums.songs]]
51   name = "Glory Days"
52
53   [[albums.songs]]
54   name = "Dancing in the Dark"
55 });
56
57 is($actual, $expected1, 'table-array-nest - from_toml') or do{
58   diag 'EXPECTED:';
59   diag Dumper($expected1);
60
61   diag 'ACTUAL:';
62   diag Dumper($actual);
63 };
64
65 is(eval{ from_toml(to_toml($actual)) }, $actual, 'table-array-nest - to_toml') or do{
66   diag 'INPUT:';
67   diag Dumper($actual);
68
69   diag 'TOML OUTPUT:';
70   diag to_toml($actual);
71
72   diag 'REPARSED OUTPUT:';
73   diag Dumper(from_toml(to_toml($actual)));
74 };
75
76 done_testing;