Subject: | YAML bug for PIO Scalar handle w/ tests. |
YAML warns if any key or value is a PIO Handle to a scalar, because it
tries to seek and tell which isn't permitted in this type of PIO handle.
Test attached.
Subject: | YAML_PIO_HANDLE.t |
use strict;
use warnings;
use Test::More tests => 4;
use YAML;
BEGIN{
our $warn = '';
$SIG{__WARN__} = sub { $warn .= $_[0] };
}
eval {
my $file = '';
open ( my $fh, '>', $file );
my $pio_handle_hash = { $fh => 'fh' };
YAML::Dump $pio_handle_hash;
};
unlike ( $main::warn, qr/closed filehandle/, 'YAML HashRef value is PIO handle compatable' );
$main::warn = '';
eval {
my $file = '';
open ( my $fh, '>', $file );
my $pio_handle_hash = { fh => $fh };
YAML::Dump $pio_handle_hash;
};
unlike ( $main::warn, qr/closed filehandle/, 'YAML HashRef key is PIO handle compatable' );
$main::warn = '';
eval {
my $file = '';
open ( my $fh, '>', $file );
my $pio_handle_arr = [ $fh ] ;
YAML::Dump $pio_handle_arr;
};
unlike ( $main::warn, qr/closed filehandle/, 'YAML ArrayRef is PIO handle compatable' );
$main::warn = '';
eval {
my $file = '';
open ( my $fh, '>', $file );
my $pio_handle_scalar = $fh ;
YAML::Dump $pio_handle_scalar;
};
unlike ( $main::warn, qr/closed filehandle/, 'YAML Scalar is PIO handle compatable' );
$main::warn = '';