summaryrefslogtreecommitdiff
path: root/t/dump-stringy-numbers.t
blob: ac4a625cc4260004801c411c51bfa2453d1ec72f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use strict;
use lib -e 't' ? 't' : 'test';
use TestYAML tests => 6;
use YAML ();
use YAML::Dumper;

$YAML::QuoteNumericStrings = 1;
filters { perl => [qw'eval yaml_dump'], };

ok( YAML::Dumper->is_literal_number(1),    '1 is a literal number' );
ok( !YAML::Dumper->is_literal_number("1"), '"1" is not a literal number' );
ok( YAML::Dumper->is_literal_number( "1" + 1 ), '"1" +1  is a literal number' );

run_is;

__DATA__
=== Mixed Literal and Stringy ints
+++ perl
+{ foo => '2', baz => 1 }
+++ yaml
---
baz: 1
foo: '2'

=== Mixed Literal and Stringy floats
+++ perl
+{ foo => '2.000', baz => 1.000 }
+++ yaml
---
baz: 1
foo: '2.000'

=== Numeric Keys
+++ perl
+{ 10 => '2.000', 20 => 1.000, '030' => 2.000 }
+++ yaml
---
'030': 2
'10': '2.000'
'20': 1