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 FindBin '$Bin';
use lib $Bin;
use TestYAMLTests tests => 5;
my $yaml = <<'...';
---
a: true
b: 1
c: false
d: ''
...
my $hash = Load $yaml;
cmp_ok $hash->{a}, '==', $hash->{b},
"true is loaded as a scalar whose numeric value is 1";
is "$hash->{a}", "$hash->{b}",
"true is loaded as a scalar whose string value is '1'";
is "$hash->{c}", "$hash->{d}",
"false is loaded as a scalar whose string value is ''";
my $yaml2 = Dump($hash);
is $yaml2, $yaml,
"Booleans YNY roundtrip";
my $yaml3 = <<'...';
---
- true
- false
- 'true'
- 'false'
- 1
- 0
- ''
...
my $yaml4 = Dump Load $yaml3;
is $yaml4, $yaml3,
"Everything related to boolean YNY roundtrips";
|