chiark / gitweb /
Move unused dependency to test deps
[nailing-cargo.git] / t / toml-test / valid / example.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                'best-day-ever' => bless( {
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                                                          my $exp = 'DateTime::Format::RFC3339'->parse_datetime('1987-07-05T17:45:00Z');
22                                                          my $got = 'DateTime::Format::RFC3339'->parse_datetime($_);
23                                                          $exp->set_time_zone('UTC');
24                                                          $got->set_time_zone('UTC');
25                                                          return 'DateTime'->compare($got, $exp) == 0;
26                                                      },
27                                            '_file' => '(eval 376)',
28                                            'name' => '<Custom Code>',
29                                            'operator' => 'CODE(...)',
30                                            '_lines' => [
31                                                          11
32                                                        ]
33                                          }, 'Test2::Compare::Custom' ),
34                'numtheory' => {
35                                 'boring' => 0,
36                                 'perfection' => [
37                                                   bless( {
38                                                            '_lines' => [
39                                                                          6
40                                                                        ],
41                                                            'operator' => 'CODE(...)',
42                                                            'name' => '<Custom Code>',
43                                                            'code' => sub {
44                                                                          BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"}
45                                                                          use strict;
46                                                                          no feature ':all';
47                                                                          use feature ':5.16';
48                                                                          require Math::BigInt;
49                                                                          'Math::BigInt'->new('6')->beq($_);
50                                                                      },
51                                                            '_file' => '(eval 373)'
52                                                          }, 'Test2::Compare::Custom' ),
53                                                   bless( {
54                                                            'code' => sub {
55                                                                          BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"}
56                                                                          use strict;
57                                                                          no feature ':all';
58                                                                          use feature ':5.16';
59                                                                          require Math::BigInt;
60                                                                          'Math::BigInt'->new('28')->beq($_);
61                                                                      },
62                                                            '_file' => '(eval 374)',
63                                                            'name' => '<Custom Code>',
64                                                            'operator' => 'CODE(...)',
65                                                            '_lines' => [
66                                                                          6
67                                                                        ]
68                                                          }, 'Test2::Compare::Custom' ),
69                                                   bless( {
70                                                            '_lines' => [
71                                                                          6
72                                                                        ],
73                                                            'name' => '<Custom Code>',
74                                                            'operator' => 'CODE(...)',
75                                                            '_file' => '(eval 375)',
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::BigInt;
82                                                                          'Math::BigInt'->new('496')->beq($_);
83                                                                      }
84                                                          }, 'Test2::Compare::Custom' )
85                                                 ]
86                               }
87              };
88
89
90 my $actual = from_toml(q{best-day-ever = 1987-07-05T17:45:00Z
91
92 [numtheory]
93 boring = false
94 perfection = [6, 28, 496]
95 });
96
97 is($actual, $expected1, 'example - from_toml') or do{
98   diag 'EXPECTED:';
99   diag Dumper($expected1);
100
101   diag 'ACTUAL:';
102   diag Dumper($actual);
103 };
104
105 is(eval{ from_toml(to_toml($actual)) }, $actual, 'example - to_toml') or do{
106   diag 'INPUT:';
107   diag Dumper($actual);
108
109   diag 'TOML OUTPUT:';
110   diag to_toml($actual);
111
112   diag 'REPARSED OUTPUT:';
113   diag Dumper(from_toml(to_toml($actual)));
114 };
115
116 done_testing;