From: Tony Cook Date: Tue, 8 Dec 2009 11:48:59 +0000 (+0100) Subject: [perl #70802] -i'*' refuses to work X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=13290fcd82823e130109fca5199c99fb886e29eb;p=p5sagit%2Fp5-mst-13.2.git [perl #70802] -i'*' refuses to work Add regression tests (the bug was fixed by commit c9930541bfa04399c3b648e83c9b750cee1154fb) --- diff --git a/t/io/inplace.t b/t/io/inplace.t index a9664dc..ce09314 100644 --- a/t/io/inplace.t +++ b/t/io/inplace.t @@ -4,7 +4,7 @@ require './test.pl'; $^I = $^O eq 'VMS' ? '_bak' : '.bak'; -plan( tests => 2 ); +plan( tests => 6 ); my @tfiles = (tempfile(), tempfile(), tempfile()); my @tfiles_bak = map "$_$^I", @tfiles; @@ -33,3 +33,55 @@ is ( runperl( prog => 'print<>;', args => \@tfiles_bak ), "foo\nfoo\nfoo\n", "backup file contents stay the same" ); +SKIP: +{ + # based on code, dosish and epoc systems can't do no-backup inplace + # edits + $^O =~ /^(MSWin32|cygwin|uwin|dos|epoc)$/ + and skip("Can't inplace edit without backups on $^O", 4); + + our @ifiles = ( tempfile(), tempfile(), tempfile() ); + + { + for my $file (@ifiles) { + runperl( prog => 'print qq(bar\n);', + args => [ '>', $file ] ); + } + + local $^I = ''; + local @ARGV = @ifiles; + + while (<>) { + print "foo$_"; + } + + is(scalar(@ARGV), 0, "consumed ARGV"); + + is( runperl( prog => 'print<>;', args => \@ifiles ), + "foobar\nfoobar\nfoobar\n", + "normal inplace edit"); + } + + # test * equivalency RT #70802 + { + for my $file (@ifiles) { + runperl( prog => 'print qq(bar\n);', + args => [ '>', $file ] ); + } + + local $^I = '*'; + local @ARGV = @ifiles; + + while (<>) { + print "foo$_"; + } + + is(scalar(@ARGV), 0, "consumed ARGV"); + + is( runperl( prog => 'print<>;', args => \@ifiles ), + "foobar\nfoobar\nfoobar\n", + "normal inplace edit"); + } + + END { unlink_all(@ifiles); } +}