chiark / gitweb /
v0.06
[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 DateTime;
6 use DateTime::Format::RFC3339;
7 use Math::BigInt;
8 use Math::BigFloat;
9 use TOML::Tiny;
10
11 binmode STDIN,  ':encoding(UTF-8)';
12 binmode STDOUT, ':encoding(UTF-8)';
13
14 my $expected1 = {
15                'albums' => [
16                              {
17                                'songs' => [
18                                             {
19                                               'name' => 'Jungleland'
20                                             },
21                                             {
22                                               'name' => 'Meeting Across the River'
23                                             }
24                                           ],
25                                'name' => 'Born to Run'
26                              },
27                              {
28                                'name' => 'Born in the USA',
29                                'songs' => [
30                                             {
31                                               'name' => 'Glory Days'
32                                             },
33                                             {
34                                               'name' => 'Dancing in the Dark'
35                                             }
36                                           ]
37                              }
38                            ]
39              };
40
41
42 my $actual = from_toml(q{[[albums]]
43 name = "Born to Run"
44
45   [[albums.songs]]
46   name = "Jungleland"
47
48   [[albums.songs]]
49   name = "Meeting Across the River"
50
51 [[albums]]
52 name = "Born in the USA"
53   
54   [[albums.songs]]
55   name = "Glory Days"
56
57   [[albums.songs]]
58   name = "Dancing in the Dark"
59 });
60
61 is($actual, $expected1, 'table-array-nest - from_toml') or do{
62   diag 'EXPECTED:';
63   diag Dumper($expected1);
64
65   diag 'ACTUAL:';
66   diag Dumper($actual);
67 };
68
69 is(eval{ from_toml(to_toml($actual)) }, $actual, 'table-array-nest - to_toml') or do{
70   diag 'INPUT:';
71   diag Dumper($actual);
72
73   diag 'TOML OUTPUT:';
74   diag to_toml($actual);
75
76   diag 'REPARSED OUTPUT:';
77   diag Dumper(from_toml(to_toml($actual)));
78 };
79
80 done_testing;