Subject: | Cannot use a stdout IO::Handle directly, when Test::Output is in use |
Consider this code:
use strict;
use warnings;
use Test::More;
use Test::Fatal;
use Test::Output;
use IO::Handle;
my $stdout = IO::Handle->new_from_fd(fileno(STDOUT), 'w+');
print $stdout "1. this is output to stdout\n";
is(
exception {
output_is(
sub {
my $stdout = IO::Handle->new_from_fd(fileno(STDOUT),
'w+');
print $stdout "2. this is output to stdout\n";
},
'info message',
'info message is logged only to stdout',
);
},
undef,
'this code does not die',
);
done_testing;
When run, it produces:
1. this is output to stdout
not ok 1 - this code does not die
# Failed test 'this code does not die'
# at output.t line 24.
# got: 'Can't use an undefined value as a symbol reference
at output.t line 17.
# '
# expected: undef
1..1
# Looks like you failed 1 test of 1.
IO::Handle's constructor fails to get stdout. This appears to be because
of the use of tie() - is there an interface that is incomplete or missing?