Al-HUWAITI Shell
Al-huwaiti


Server : Apache
System : Linux dedi-14684855.grupobig.com 5.14.0-611.49.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Apr 21 16:39:08 EDT 2026 x86_64
User : grupo692 ( 1004)
PHP Version : 8.2.31
Disable Function : NONE
Directory :  /home/.cpan/build/YAML-LibYAML-v0.902.0-0/t/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/.cpan/build/YAML-LibYAML-v0.902.0-0/t/boolean.t
use FindBin '$Bin';
use lib $Bin;
use constant HAVE_BOOLEANS => ($^V ge v5.36);
use TestYAMLTests tests => 5 + (HAVE_BOOLEANS ? 4 : 0);

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";

if( HAVE_BOOLEANS ) {
    no if HAVE_BOOLEANS, warnings => "experimental::builtin";

    is Dump({ true => builtin::true, false => builtin::false }),
        <<'...',
---
'false': false
'true': true
...
        'core booleans dump as booleans';

    ok builtin::is_bool(Load(<<'...',)->{false}),
---
'false': false
'true': true
...
        'booleans loaded as core booleans';

    eval { $hash->{a} = 'something else' };
    is $@, '', "core boolean element in hash is not readonly";
    is $hash->{a}, 'something else', "core boolean element is changed";
}

Al-HUWAITI Shell