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