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