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
|
# vim600: set syn=perl :
use Test::More tests => 7;
BEGIN { use_ok('IO::Capture::Stdout') };
# These will generate some warnings -> preventing from printing
open STDERR_SAV, ">&STDERR"; open STDERR, ">/dev/null";
# Now test creating two captures of the same type and starting both
my $capture1 = IO::Capture::Stdout->new();
my $capture2 = IO::Capture::Stdout->new();
my $rv1 = $capture1->start();
#Test 2
ok(!$capture1->start,"Two starts");
#Test 3
ok(!$capture2->start(), "Two captures");
$capture2->stop();
#Test 4
ok(!$capture1->start(), "Two starts");
#Test 5
ok(!$capture1->read(), "Read before stop");
$capture1->stop();
my $capture3 = IO::Capture::Stdout->new();
#Test 6
ok(!$capture3->stop(), "Stop before Start");
$capture3->start();
$capture3->stop();
#Test 7
ok(!$capture3->stop(), "Two Stops");
# restore STDERR
close STDERR; open STDERR, ">&STDERR_SAV"; close STDERR_SAV;
|