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