chiark / gitweb /
f2fbb4c33a8ae502772b812e8688641cd3509b10
[nailing-cargo.git] / t / toml-test / valid / arrays.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                'dates' => [
12                             bless( {
13                                      '_file' => '(eval 139)',
14                                      'name' => '<Custom Code>',
15                                      'operator' => 'CODE(...)',
16                                      '_lines' => [
17                                                    11
18                                                  ],
19                                      'code' => sub {
20                                                    BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"}
21                                                    use strict;
22                                                    no feature ':all';
23                                                    use feature ':5.16';
24                                                    my $exp = 'DateTime::Format::RFC3339'->parse_datetime('1987-07-05T17:45:00Z');
25                                                    my $got = 'DateTime::Format::RFC3339'->parse_datetime($_);
26                                                    $exp->set_time_zone('UTC');
27                                                    $got->set_time_zone('UTC');
28                                                    return 'DateTime'->compare($got, $exp) == 0;
29                                                }
30                                    }, 'Test2::Compare::Custom' ),
31                             bless( {
32                                      'name' => '<Custom Code>',
33                                      'operator' => 'CODE(...)',
34                                      'code' => sub {
35                                                    BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"}
36                                                    use strict;
37                                                    no feature ':all';
38                                                    use feature ':5.16';
39                                                    my $exp = 'DateTime::Format::RFC3339'->parse_datetime('1979-05-27T07:32:00Z');
40                                                    my $got = 'DateTime::Format::RFC3339'->parse_datetime($_);
41                                                    $exp->set_time_zone('UTC');
42                                                    $got->set_time_zone('UTC');
43                                                    return 'DateTime'->compare($got, $exp) == 0;
44                                                },
45                                      '_lines' => [
46                                                    11
47                                                  ],
48                                      '_file' => '(eval 360)'
49                                    }, 'Test2::Compare::Custom' ),
50                             bless( {
51                                      'code' => sub {
52                                                    BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"}
53                                                    use strict;
54                                                    no feature ':all';
55                                                    use feature ':5.16';
56                                                    my $exp = 'DateTime::Format::RFC3339'->parse_datetime('2006-06-01T11:00:00Z');
57                                                    my $got = 'DateTime::Format::RFC3339'->parse_datetime($_);
58                                                    $exp->set_time_zone('UTC');
59                                                    $got->set_time_zone('UTC');
60                                                    return 'DateTime'->compare($got, $exp) == 0;
61                                                },
62                                      '_lines' => [
63                                                    11
64                                                  ],
65                                      'name' => '<Custom Code>',
66                                      'operator' => 'CODE(...)',
67                                      '_file' => '(eval 361)'
68                                    }, 'Test2::Compare::Custom' )
69                           ],
70                'floats' => [
71                              bless( {
72                                       '_file' => '(eval 136)',
73                                       'code' => sub {
74                                                     BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"}
75                                                     use strict;
76                                                     no feature ':all';
77                                                     use feature ':5.16';
78                                                     require Math::BigFloat;
79                                                     'Math::BigFloat'->new('1.1')->beq($_);
80                                                 },
81                                       '_lines' => [
82                                                     6
83                                                   ],
84                                       'operator' => 'CODE(...)',
85                                       'name' => '<Custom Code>'
86                                     }, 'Test2::Compare::Custom' ),
87                              bless( {
88                                       'code' => sub {
89                                                     BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"}
90                                                     use strict;
91                                                     no feature ':all';
92                                                     use feature ':5.16';
93                                                     require Math::BigFloat;
94                                                     'Math::BigFloat'->new('2.1')->beq($_);
95                                                 },
96                                       '_lines' => [
97                                                     6
98                                                   ],
99                                       'name' => '<Custom Code>',
100                                       'operator' => 'CODE(...)',
101                                       '_file' => '(eval 137)'
102                                     }, 'Test2::Compare::Custom' ),
103                              bless( {
104                                       '_file' => '(eval 138)',
105                                       'operator' => 'CODE(...)',
106                                       'name' => '<Custom Code>',
107                                       'code' => sub {
108                                                     BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"}
109                                                     use strict;
110                                                     no feature ':all';
111                                                     use feature ':5.16';
112                                                     require Math::BigFloat;
113                                                     'Math::BigFloat'->new('3.1')->beq($_);
114                                                 },
115                                       '_lines' => [
116                                                     6
117                                                   ]
118                                     }, 'Test2::Compare::Custom' )
119                            ],
120                'strings' => [
121                               'a',
122                               'b',
123                               'c'
124                             ],
125                'comments' => [
126                                bless( {
127                                         '_file' => '(eval 134)',
128                                         'code' => sub {
129                                                       BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"}
130                                                       use strict;
131                                                       no feature ':all';
132                                                       use feature ':5.16';
133                                                       require Math::BigInt;
134                                                       'Math::BigInt'->new('1')->beq($_);
135                                                   },
136                                         '_lines' => [
137                                                       6
138                                                     ],
139                                         'name' => '<Custom Code>',
140                                         'operator' => 'CODE(...)'
141                                       }, 'Test2::Compare::Custom' ),
142                                bless( {
143                                         '_file' => '(eval 135)',
144                                         'operator' => 'CODE(...)',
145                                         'name' => '<Custom Code>',
146                                         'code' => sub {
147                                                       BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"}
148                                                       use strict;
149                                                       no feature ':all';
150                                                       use feature ':5.16';
151                                                       require Math::BigInt;
152                                                       'Math::BigInt'->new('2')->beq($_);
153                                                   },
154                                         '_lines' => [
155                                                       6
156                                                     ]
157                                       }, 'Test2::Compare::Custom' )
158                              ],
159                'ints' => [
160                            bless( {
161                                     'name' => '<Custom Code>',
162                                     'operator' => 'CODE(...)',
163                                     '_lines' => [
164                                                   6
165                                                 ],
166                                     'code' => sub {
167                                                   BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"}
168                                                   use strict;
169                                                   no feature ':all';
170                                                   use feature ':5.16';
171                                                   require Math::BigInt;
172                                                   'Math::BigInt'->new('1')->beq($_);
173                                               },
174                                     '_file' => '(eval 131)'
175                                   }, 'Test2::Compare::Custom' ),
176                            bless( {
177                                     'code' => sub {
178                                                   BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"}
179                                                   use strict;
180                                                   no feature ':all';
181                                                   use feature ':5.16';
182                                                   require Math::BigInt;
183                                                   'Math::BigInt'->new('2')->beq($_);
184                                               },
185                                     '_lines' => [
186                                                   6
187                                                 ],
188                                     'operator' => 'CODE(...)',
189                                     'name' => '<Custom Code>',
190                                     '_file' => '(eval 132)'
191                                   }, 'Test2::Compare::Custom' ),
192                            bless( {
193                                     '_file' => '(eval 133)',
194                                     'code' => sub {
195                                                   BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"}
196                                                   use strict;
197                                                   no feature ':all';
198                                                   use feature ':5.16';
199                                                   require Math::BigInt;
200                                                   'Math::BigInt'->new('3')->beq($_);
201                                               },
202                                     '_lines' => [
203                                                   6
204                                                 ],
205                                     'name' => '<Custom Code>',
206                                     'operator' => 'CODE(...)'
207                                   }, 'Test2::Compare::Custom' )
208                          ]
209              };
210
211
212 my $actual = from_toml(q{ints = [1, 2, 3]
213 floats = [1.1, 2.1, 3.1]
214 strings = ["a", "b", "c"]
215 dates = [
216   1987-07-05T17:45:00Z,
217   1979-05-27T07:32:00Z,
218   2006-06-01T11:00:00Z,
219 ]
220 comments = [
221          1,
222          2, #this is ok
223 ]
224 });
225
226 is($actual, $expected1, 'arrays - from_toml') or do{
227   diag 'EXPECTED:';
228   diag Dumper($expected1);
229
230   diag 'ACTUAL:';
231   diag Dumper($actual);
232 };
233
234 is(eval{ from_toml(to_toml($actual)) }, $actual, 'arrays - to_toml') or do{
235   diag 'INPUT:';
236   diag Dumper($actual);
237
238   diag 'TOML OUTPUT:';
239   diag to_toml($actual);
240
241   diag 'REPARSED OUTPUT:';
242   diag Dumper(from_toml(to_toml($actual)));
243 };
244
245 done_testing;