[patch@34016] VMS passes these t/io/open.t tests now.
[p5sagit/p5-mst-13.2.git] / t / io / inplace.t
index 2652c8b..a7a21e4 100755 (executable)
@@ -1,22 +1,23 @@
 #!./perl
+use strict;
+require './test.pl';
 
-$^I = '.bak';
+$^I = $^O eq 'VMS' ? '_bak' : '.bak';
 
-# $RCSfile: inplace.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:29 $
+plan( tests => 2 );
 
-print "1..2\n";
+my @tfiles     = ('.a','.b','.c');
+my @tfiles_bak = (".a$^I", ".b$^I", ".c$^I");
 
-@ARGV = ('.a','.b','.c');
-if ($^O eq 'MSWin32') {
-  $CAT = '.\perl -e "print<>"';
-  `.\\perl -le "print 'foo'" > .a`;
-  `.\\perl -le "print 'foo'" > .b`;
-  `.\\perl -le "print 'foo'" > .c`;
-}
-else {
-  $CAT = 'cat';
-  `echo foo | tee .a .b .c`;
+END { unlink_all('.a','.b','.c',".a$^I", ".b$^I", ".c$^I"); }
+
+for my $file (@tfiles) {
+    runperl( prog => 'print qq(foo\n);', 
+             args => ['>', $file] );
 }
+
+@ARGV = @tfiles;
+
 while (<>) {
     s/foo/bar/;
 }
@@ -24,7 +25,11 @@ continue {
     print;
 }
 
-if (`$CAT .a .b .c` eq "bar\nbar\nbar\n") {print "ok 1\n";} else {print "not ok 1\n";}
-if (`$CAT .a.bak .b.bak .c.bak` eq "foo\nfoo\nfoo\n") {print "ok 2\n";} else {print "not ok 2\n";}
+is ( runperl( prog => 'print<>;', args => \@tfiles ), 
+     "bar\nbar\nbar\n", 
+     "file contents properly replaced" );
+
+is ( runperl( prog => 'print<>;', args => \@tfiles_bak ), 
+     "foo\nfoo\nfoo\n", 
+     "backup file contents stay the same" );
 
-unlink '.a', '.b', '.c', '.a.bak', '.b.bak', '.c.bak';