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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
# !perl
#$Id: 01_stdout.t 1213 2008-02-09 23:40:34Z jimk $
# 01_stdout.t - basic tests of say()
use strict;
use warnings;
use Test::More tests => 8;
use lib ( qq{./t/lib} );
BEGIN {
use_ok('Perl6::Say');
use_ok('Carp');
use_ok('Perl6::Say::Auxiliary', qw| _validate capture_say $capture_fail_message |);
};
SKIP: {
eval qq{ require IO::Capture::Stdout; };;
skip "tests require IO::Capture::Stdout",
5 if $@;
my ($capture, $cat);
local $_ = qq{Hello World};
$capture = IO::Capture::Stdout->new();
$capture->start;
say();
$capture->stop;
$cat = join q{}, $capture->read();
is($cat, "$_\n",
"1 line correctly printed from \$_");
local $_ = qq{Hello World\n};
$capture = IO::Capture::Stdout->new();
$capture->start;
say();
$capture->stop;
$cat = join q{}, $capture->read();
is($cat, "$_\n",
"2 lines correctly printed from \$_");
local $_ = qq{};
$capture = IO::Capture::Stdout->new();
$capture->start;
say();
$capture->stop;
$cat = join q{}, $capture->read();
is($cat, "$_\n",
"1 line correctly printed from \$_");
$capture = IO::Capture::Stdout->new();
$capture->start;
say undef;
$capture->stop;
$cat = join q{}, $capture->read();
is($cat, "\n",
"1 line correctly printed where argument was 'undef'");
$capture = IO::Capture::Stdout->new();
$capture->start;
say;
$capture->stop;
$cat = join q{}, $capture->read();
is($cat, "\n",
"1 line correctly printed where there were 0 arguments and no parens");
}
|