chiark / gitweb /
v0.06
[nailing-cargo.git] / t / toml-test / valid / arrays-hetergeneous.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                'mixed' => [
16                             [
17                               bless( {
18                                        'name' => '<Custom Code>',
19                                        'operator' => 'CODE(...)',
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('1')->beq($_);
27                                                  },
28                                        '_file' => '(eval 362)',
29                                        '_lines' => [
30                                                      6
31                                                    ]
32                                      }, 'Test2::Compare::Custom' ),
33                               bless( {
34                                        'name' => '<Custom Code>',
35                                        'operator' => 'CODE(...)',
36                                        'code' => sub {
37                                                      BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"}
38                                                      use strict;
39                                                      no feature ':all';
40                                                      use feature ':5.16';
41                                                      require Math::BigInt;
42                                                      'Math::BigInt'->new('2')->beq($_);
43                                                  },
44                                        '_file' => '(eval 363)',
45                                        '_lines' => [
46                                                      6
47                                                    ]
48                                      }, 'Test2::Compare::Custom' )
49                             ],
50                             [
51                               'a',
52                               'b'
53                             ],
54                             [
55                               bless( {
56                                        'name' => '<Custom Code>',
57                                        'operator' => 'CODE(...)',
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::BigFloat;
64                                                      'Math::BigFloat'->new('1.1')->beq($_);
65                                                  },
66                                        '_file' => '(eval 364)',
67                                        '_lines' => [
68                                                      6
69                                                    ]
70                                      }, 'Test2::Compare::Custom' ),
71                               bless( {
72                                        '_lines' => [
73                                                      6
74                                                    ],
75                                        '_file' => '(eval 365)',
76                                        'code' => sub {
77                                                      BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"}
78                                                      use strict;
79                                                      no feature ':all';
80                                                      use feature ':5.16';
81                                                      require Math::BigFloat;
82                                                      'Math::BigFloat'->new('2.1')->beq($_);
83                                                  },
84                                        'name' => '<Custom Code>',
85                                        'operator' => 'CODE(...)'
86                                      }, 'Test2::Compare::Custom' )
87                             ]
88                           ]
89              };
90
91
92 my $actual = from_toml(q{mixed = [[1, 2], ["a", "b"], [1.1, 2.1]]
93 });
94
95 is($actual, $expected1, 'arrays-hetergeneous - from_toml') or do{
96   diag 'EXPECTED:';
97   diag Dumper($expected1);
98
99   diag 'ACTUAL:';
100   diag Dumper($actual);
101 };
102
103 is(eval{ from_toml(to_toml($actual)) }, $actual, 'arrays-hetergeneous - to_toml') or do{
104   diag 'INPUT:';
105   diag Dumper($actual);
106
107   diag 'TOML OUTPUT:';
108   diag to_toml($actual);
109
110   diag 'REPARSED OUTPUT:';
111   diag Dumper(from_toml(to_toml($actual)));
112 };
113
114 done_testing;