File: 90-output.t

package info (click to toggle)
libsystem-command-perl 1.07-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 144 kB
  • sloc: perl: 170; makefile: 2
file content (38 lines) | stat: -rw-r--r-- 1,023 bytes parent folder | download
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
use warnings;
use strict;
use Test::More;

BEGIN {
    plan skip_all => 'Test::Output not available'
        if ! eval 'use Test::Output; 1;';
}

use System::Command;

sub print_implicit { print "STDOUT\n"; }
sub print_stdout   { print STDOUT "STDOUT\n"; }
sub print_stderr   { print STDERR "STDERR\n"; }

plan tests => 10;

# before
stdout_is( \&print_implicit, "STDOUT\n", 'print' );
stdout_is( \&print_stdout,   "STDOUT\n", 'print STDOUT' );
stderr_is( \&print_stderr, "STDERR\n", 'print STDERR' );

# during
{
    my $cmd = System::Command->new( $^X => qw( -le print+1 ) );
    stdout_is( \&print_implicit, "STDOUT\n", 'print' );
    stdout_is( \&print_stdout,   "STDOUT\n", 'print STDOUT' );
    stderr_is( \&print_stderr, "STDERR\n", 'print STDERR' );

    is( $cmd->stdout->getline, "1\n", 'expected command output' );
    $cmd->close;
}

# after
stdout_is( \&print_implicit, "STDOUT\n", 'print' );
stdout_is( \&print_stdout,   "STDOUT\n", 'print STDOUT' );
stderr_is( \&print_stderr, "STDERR\n", 'print STDERR' );