Integrate mainline 5.05_61
[p5sagit/p5-mst-13.2.git] / t / io / dup.t
CommitLineData
378cc40b 1#!./perl
2
79072805 3# $RCSfile: dup.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:27 $
378cc40b 4
9394203c 5print "1..7\n";
378cc40b 6
7print "ok 1\n";
8
a687059c 9open(dupout,">&STDOUT");
10open(duperr,">&STDERR");
378cc40b 11
a687059c 12open(STDOUT,">Io.dup") || die "Can't open stdout";
13open(STDERR,">&STDOUT") || die "Can't open stderr";
378cc40b 14
a687059c 15select(STDERR); $| = 1;
16select(STDOUT); $| = 1;
378cc40b 17
a687059c 18print STDOUT "ok 2\n";
19print STDERR "ok 3\n";
68dc0745 20if ($^O eq 'MSWin32') {
21 print `echo ok 4`;
22 print `echo ok 5 1>&2`; # does this work?
23}
24else {
25 system 'echo ok 4';
26 system 'echo ok 5 1>&2';
27}
378cc40b 28
a687059c 29close(STDOUT);
30close(STDERR);
378cc40b 31
a687059c 32open(STDOUT,">&dupout");
33open(STDERR,">&duperr");
378cc40b 34
68dc0745 35if ($^O eq 'MSWin32') { print `type Io.dup` }
36else { system 'cat Io.dup' }
378cc40b 37unlink 'Io.dup';
38
a687059c 39print STDOUT "ok 6\n";
9394203c 40
41# 7 # 19990811 mjd@plover.com
42my ($out1, $out2) = ("Line 1\n", "Line 2\n");
43open(W, "> Io.dup") || die "Can't open stdout";
44print W $out1, $out2;
45close W;
46open(R1, "< Io.dup") || die "Can't read temp file";
47$in1 = <R1>;
48open(R2, "<&R1") || die "Can't dup";
49$in2 = <R2>;
50print "not " unless $in1 eq $out1 && $in2 eq $out2;
51print "ok 7\n";
52
53unlink("Io.dup");