summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/perl/t/lib/io_dup.t
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1997-11-30 08:07:08 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1997-11-30 08:07:08 +0000
commitec01b9db009b90979fb9d6b514d483a54d3d5bdd (patch)
tree644294037f797fdbdcbe608141f083e078a41d46 /gnu/usr.bin/perl/t/lib/io_dup.t
parent0512af39306262113602b12265059e76c91427ff (diff)
perl5.005_03
Diffstat (limited to 'gnu/usr.bin/perl/t/lib/io_dup.t')
-rw-r--r--gnu/usr.bin/perl/t/lib/io_dup.t61
1 files changed, 61 insertions, 0 deletions
diff --git a/gnu/usr.bin/perl/t/lib/io_dup.t b/gnu/usr.bin/perl/t/lib/io_dup.t
new file mode 100644
index 00000000000..6b0caf14fad
--- /dev/null
+++ b/gnu/usr.bin/perl/t/lib/io_dup.t
@@ -0,0 +1,61 @@
+#!./perl
+
+BEGIN {
+ unless(grep /blib/, @INC) {
+ chdir 't' if -d 't';
+ @INC = '../lib' if -d '../lib';
+ }
+}
+
+use Config;
+
+BEGIN {
+ if(-d "lib" && -f "TEST") {
+ if ($Config{'extensions'} !~ /\bIO\b/ && $^O ne 'VMS') {
+ print "1..0\n";
+ exit 0;
+ }
+ }
+}
+
+use IO::Handle;
+use IO::File;
+
+select(STDERR); $| = 1;
+select(STDOUT); $| = 1;
+
+print "1..6\n";
+
+print "ok 1\n";
+
+$dupout = IO::Handle->new->fdopen( \*STDOUT ,"w");
+$duperr = IO::Handle->new->fdopen( \*STDERR ,"w");
+
+$stdout = \*STDOUT; bless $stdout, "IO::File"; # "IO::Handle";
+$stderr = \*STDERR; bless $stderr, "IO::Handle";
+
+$stdout->open( "Io.dup","w") || die "Can't open stdout";
+$stderr->fdopen($stdout,"w");
+
+print $stdout "ok 2\n";
+print $stderr "ok 3\n";
+if ($^O eq 'MSWin32') {
+ print `echo ok 4`;
+ print `echo ok 5 1>&2`; # does this *really* work?
+}
+else {
+ system 'echo ok 4';
+ system 'echo ok 5 1>&2';
+}
+
+$stderr->close;
+$stdout->close;
+
+$stdout->fdopen($dupout,"w");
+$stderr->fdopen($duperr,"w");
+
+if ($^O eq 'MSWin32') { print `type Io.dup` }
+else { system 'cat Io.dup' }
+unlink 'Io.dup';
+
+print STDOUT "ok 6\n";