chiark / gitweb /
4019c15c2f82adeea2481304e2413ee52ba7d7d5
[nailing-cargo.git] / t / toml-test / valid / inline-table.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                'name' => {
12                            'first' => 'Tom',
13                            'last' => 'Preston-Werner'
14                          },
15                'point' => {
16                             'y' => bless( {
17                                             '_file' => '(eval 399)',
18                                             'code' => sub {
19                                                           BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"}
20                                                           use strict;
21                                                           no feature ':all';
22                                                           use feature ':5.16';
23                                                           require Math::BigInt;
24                                                           'Math::BigInt'->new('2')->beq($_);
25                                                       },
26                                             '_lines' => [
27                                                           6
28                                                         ],
29                                             'operator' => 'CODE(...)',
30                                             'name' => '<Custom Code>'
31                                           }, 'Test2::Compare::Custom' ),
32                             'x' => bless( {
33                                             'name' => '<Custom Code>',
34                                             'operator' => 'CODE(...)',
35                                             'code' => sub {
36                                                           BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"}
37                                                           use strict;
38                                                           no feature ':all';
39                                                           use feature ':5.16';
40                                                           require Math::BigInt;
41                                                           'Math::BigInt'->new('1')->beq($_);
42                                                       },
43                                             '_lines' => [
44                                                           6
45                                                         ],
46                                             '_file' => '(eval 400)'
47                                           }, 'Test2::Compare::Custom' )
48                           },
49                'simple' => {
50                              'a' => bless( {
51                                              '_file' => '(eval 401)',
52                                              '_lines' => [
53                                                            6
54                                                          ],
55                                              'code' => sub {
56                                                            BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"}
57                                                            use strict;
58                                                            no feature ':all';
59                                                            use feature ':5.16';
60                                                            require Math::BigInt;
61                                                            'Math::BigInt'->new('1')->beq($_);
62                                                        },
63                                              'operator' => 'CODE(...)',
64                                              'name' => '<Custom Code>'
65                                            }, 'Test2::Compare::Custom' )
66                            },
67                'str-key' => {
68                               'a' => bless( {
69                                               'name' => '<Custom Code>',
70                                               'operator' => 'CODE(...)',
71                                               '_lines' => [
72                                                             6
73                                                           ],
74                                               'code' => sub {
75                                                             BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"}
76                                                             use strict;
77                                                             no feature ':all';
78                                                             use feature ':5.16';
79                                                             require Math::BigInt;
80                                                             'Math::BigInt'->new('1')->beq($_);
81                                                         },
82                                               '_file' => '(eval 404)'
83                                             }, 'Test2::Compare::Custom' )
84                             },
85                'table-array' => [
86                                   {
87                                     'a' => bless( {
88                                                     'operator' => 'CODE(...)',
89                                                     'name' => '<Custom Code>',
90                                                     '_lines' => [
91                                                                   6
92                                                                 ],
93                                                     'code' => sub {
94                                                                   BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"}
95                                                                   use strict;
96                                                                   no feature ':all';
97                                                                   use feature ':5.16';
98                                                                   require Math::BigInt;
99                                                                   'Math::BigInt'->new('1')->beq($_);
100                                                               },
101                                                     '_file' => '(eval 402)'
102                                                   }, 'Test2::Compare::Custom' )
103                                   },
104                                   {
105                                     'b' => bless( {
106                                                     '_file' => '(eval 403)',
107                                                     'operator' => 'CODE(...)',
108                                                     'name' => '<Custom Code>',
109                                                     '_lines' => [
110                                                                   6
111                                                                 ],
112                                                     'code' => sub {
113                                                                   BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"}
114                                                                   use strict;
115                                                                   no feature ':all';
116                                                                   use feature ':5.16';
117                                                                   require Math::BigInt;
118                                                                   'Math::BigInt'->new('2')->beq($_);
119                                                               }
120                                                   }, 'Test2::Compare::Custom' )
121                                   }
122                                 ]
123              };
124
125
126 my $actual = from_toml(q{name = { first = "Tom", last = "Preston-Werner" }
127 point = { x = 1, y = 2 }
128 simple = { a = 1 }
129 str-key = { "a" = 1 }
130 table-array = [{ "a" = 1 }, { "b" = 2 }]
131 });
132
133 is($actual, $expected1, 'inline-table - from_toml') or do{
134   diag 'EXPECTED:';
135   diag Dumper($expected1);
136
137   diag 'ACTUAL:';
138   diag Dumper($actual);
139 };
140
141 is(eval{ from_toml(to_toml($actual)) }, $actual, 'inline-table - to_toml') or do{
142   diag 'INPUT:';
143   diag Dumper($actual);
144
145   diag 'TOML OUTPUT:';
146   diag to_toml($actual);
147
148   diag 'REPARSED OUTPUT:';
149   diag Dumper(from_toml(to_toml($actual)));
150 };
151
152 done_testing;