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