This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Skip obsolete skip in io_xs.t.
[perl5.git] / dist / IO / t / io_dup.t
CommitLineData
61f2b451 1#!./perl
2
7a4c00b4 3use Config;
4
5BEGIN {
d846159b
MS
6 if($ENV{PERL_CORE}) {
7 if ($Config{'extensions'} !~ /\bIO\b/) {
8 print "1..0 # Skip: IO extension not compiled\n";
7a4c00b4 9 exit 0;
10 }
61f2b451 11 }
12}
13
14use IO::Handle;
15use IO::File;
16
17select(STDERR); $| = 1;
18select(STDOUT); $| = 1;
19
20print "1..6\n";
21
22print "ok 1\n";
23
24$dupout = IO::Handle->new->fdopen( \*STDOUT ,"w");
25$duperr = IO::Handle->new->fdopen( \*STDERR ,"w");
26
27$stdout = \*STDOUT; bless $stdout, "IO::File"; # "IO::Handle";
28$stderr = \*STDERR; bless $stderr, "IO::Handle";
29
30$stdout->open( "Io.dup","w") || die "Can't open stdout";
31$stderr->fdopen($stdout,"w");
32
33print $stdout "ok 2\n";
34print $stderr "ok 3\n";
ba553610
MS
35
36# Since some systems don't have echo, we use Perl.
e69a2255 37$echo = qq{$^X -le "print q(ok %d)"};
ba553610
MS
38
39$cmd = sprintf $echo, 4;
40print `$cmd`;
41
e69a2255
JH
42$cmd = sprintf "$echo 1>&2", 5;
43$cmd = sprintf $echo, 5 if $^O eq 'MacOS';
ba553610 44print `$cmd`;
61f2b451 45
46$stderr->close;
47$stdout->close;
48
49$stdout->fdopen($dupout,"w");
50$stderr->fdopen($duperr,"w");
51
cda41bc1 52if ($^O eq 'MSWin32' || $^O eq 'NetWare' || $^O eq 'VMS') { print `type Io.dup` }
e69a2255
JH
53elsif ($^O eq 'MacOS') { system 'Catenate Io.dup' }
54else { system 'cat Io.dup' }
61f2b451 55unlink 'Io.dup';
56
57print STDOUT "ok 6\n";