Subject: | Say and Print behave identically with stdout_is |
Recently I have tried using 'Say' in stdout_is , and it appears to
function identically to 'print', that is, the trailing \n say puts on
never turns up in the test.
use strict;
use warnings;
use 5.010;
use Test::More;
use Test::Output;
my $expected = "Hello\nWorld\n";
stdout_is( sub { say "Hello"; say "World"; }, $expected, "say
works" );
# not ok 1 - say works
# Failed test 'say works'
# at Stdout.t line 7.
# STDOUT is:
# HelloWorld
# not:
# Hello
# World
#
# as expected
stdout_is( sub { print "Hello\n"; print "World\n"; }, $expected,
"print\\n works" );
# ok 2 - print\n works
stdout_is( sub { say "Hello\nWorld" }, $expected, "say aggregate
works" );
# not ok 3 - say aggregate works
# Failed test 'say aggregate works'
# at Stdout.t line 9.
# STDOUT is:
# Hello
# World
# not:
# Hello
# World
#
# as expected
stdout_is( sub { print "Hello\nWorld\n" }, $expected, "print aggregate
works" );
# ok 4 - print aggregate works