This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
More dup testing.
authorJarkko Hietaniemi <jhi@iki.fi>
Sun, 14 Sep 2003 07:35:28 +0000 (07:35 +0000)
committerJarkko Hietaniemi <jhi@iki.fi>
Sun, 14 Sep 2003 07:35:28 +0000 (07:35 +0000)
p4raw-id: //depot/perl@21222

t/io/dup.t

index 5f5653a..8f54799 100755 (executable)
@@ -2,13 +2,14 @@
 
 BEGIN {
     chdir 't' if -d 't';
-    @INC = '../lib';
+    @INC = qw(. ../lib);
+    require "./test.pl";
 }
 
 use Config;
 
 my $test = 1;
-print "1..12\n";
+print "1..25\n";
 print "ok 1\n";
 
 open(DUPOUT,">&STDOUT");
@@ -83,3 +84,46 @@ if ($Config{useperlio}) {
     close(F);
 }
 
+curr_test(13);
+
+SKIP: {
+    skip("need perlio", 13) unless $Config{useperlio};
+    
+    ok(open(F, ">&", STDOUT));
+    isnt(fileno(F), fileno(STDOUT));
+    close F;
+
+    ok(open(F, "<&=STDIN"));
+    is(fileno(F), fileno(STDIN));
+    close F;
+
+    ok(open(F, ">&=STDOUT"));
+    is(fileno(F), fileno(STDOUT));
+    close F;
+
+    ok(open(F, ">&=STDERR"));
+    is(fileno(F), fileno(STDERR));
+    close F;
+
+    open(G, ">dup$$") or die;
+    my $g = fileno(G);
+
+    ok(open(F, ">&=$g"));
+    is(fileno(F), $g);
+    close F;
+
+    ok(open(F, ">&=G"));
+    is(fileno(F), $g);
+
+    print G "ggg\n";
+    print F "fff\n";
+
+    close G; # flush first
+    close F; # flush second
+
+    open(G, "<dup$$") or die;
+    { local $/; is(<G>, "ggg\nfff\n") }
+    close G;
+
+    END { 1 while unlink "dup$$" }
+}