File: 05_2_regression.t

package info (click to toggle)
libio-capture-perl 0.05-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, sid
  • size: 212 kB
  • sloc: perl: 207; makefile: 2
file content (53 lines) | stat: -rw-r--r-- 1,010 bytes parent folder | download | duplicates (4)
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
# vim600: set syn=perl :
use strict;
use Test::More tests => 3;

use IO::Capture::Stdout;
use IO::Capture::Stderr;

my $out_capture = IO::Capture::Stdout->new();
my $err_capture = IO::Capture::Stderr->new();

# Test for bug number 1
$err_capture->start();
$out_capture->start();
$out_capture->stop();
$err_capture->stop();

ok(!$err_capture->read(), "Test for no error if empty");

# Test for bug number 3
# A read() in scalar context, followed by one in list context
#

our $module;
for $module (qw/Stderr Stdout/) {
	no strict 'refs';
	my $module_name = "IO::Capture::$module";
    my $capture = $module_name->new();
	use strict 'refs';
	$capture->start;

	if ($module eq "Stdout") {
		print "Line 1";
	}
	else {
		print STDERR "Line 1";
	}

	$capture->stop();
	my $read_one = $capture->read();

	$capture->start();
	if ($module eq "Stdout") {
		print "Line 2";
	}
	else {
		print STDERR "Line 2";
	}
	$capture->stop();

	my @read_two = $capture->read();

	ok($read_two[0] eq "Line 2", "Bug 3 - $module");
}