chiark / gitweb /
v0.06
[nailing-cargo.git] / t / toml-test / valid / exponent-part-float.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                'minustenth' => bless( {
16                                         '_lines' => [
17                                                       6
18                                                     ],
19                                         'operator' => 'CODE(...)',
20                                         'name' => '<Custom Code>',
21                                         'code' => sub {
22                                                       BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"}
23                                                       use strict;
24                                                       no feature ':all';
25                                                       use feature ':5.16';
26                                                       require Math::BigFloat;
27                                                       'Math::BigFloat'->new('-0.1')->beq($_);
28                                                   },
29                                         '_file' => '(eval 377)'
30                                       }, 'Test2::Compare::Custom' ),
31                'million' => bless( {
32                                      '_lines' => [
33                                                    6
34                                                  ],
35                                      'operator' => 'CODE(...)',
36                                      'name' => '<Custom Code>',
37                                      '_file' => '(eval 379)',
38                                      'code' => sub {
39                                                    BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"}
40                                                    use strict;
41                                                    no feature ':all';
42                                                    use feature ':5.16';
43                                                    require Math::BigFloat;
44                                                    'Math::BigFloat'->new('1000000')->beq($_);
45                                                }
46                                    }, 'Test2::Compare::Custom' ),
47                'beast' => bless( {
48                                    '_lines' => [
49                                                  6
50                                                ],
51                                    'code' => sub {
52                                                  BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x05\x04\x54"}
53                                                  use strict;
54                                                  no feature ':all';
55                                                  use feature ':5.16';
56                                                  require Math::BigFloat;
57                                                  'Math::BigFloat'->new('666')->beq($_);
58                                              },
59                                    '_file' => '(eval 378)',
60                                    'name' => '<Custom Code>',
61                                    'operator' => 'CODE(...)'
62                                  }, 'Test2::Compare::Custom' )
63              };
64
65
66 my $actual = from_toml(q{million = 1e6
67 minustenth = -1E-1
68 beast = 6.66E2
69 });
70
71 is($actual, $expected1, 'exponent-part-float - from_toml') or do{
72   diag 'EXPECTED:';
73   diag Dumper($expected1);
74
75   diag 'ACTUAL:';
76   diag Dumper($actual);
77 };
78
79 is(eval{ from_toml(to_toml($actual)) }, $actual, 'exponent-part-float - to_toml') or do{
80   diag 'INPUT:';
81   diag Dumper($actual);
82
83   diag 'TOML OUTPUT:';
84   diag to_toml($actual);
85
86   diag 'REPARSED OUTPUT:';
87   diag Dumper(from_toml(to_toml($actual)));
88 };
89
90 done_testing;