This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update Encode to CPAN version 2.78
[perl5.git] / t / io / iprefix.t
1 #!./perl
2 use strict;
3 chdir 't' if -d 't';
4 require './test.pl';
5
6 $^I = 'bak.*';
7
8 # Modified from the original inplace.t to test adding prefixes
9
10 plan( tests => 2 );
11
12 my @tfiles     = (tempfile(), tempfile(), tempfile());
13 my @tfiles_bak = map "bak.$_", @tfiles;
14
15 END { unlink_all(@tfiles_bak); }
16
17 for my $file (@tfiles) {
18     runperl( prog => 'print qq(foo\n);', 
19              args => ['>', $file] );
20 }
21
22 @ARGV = @tfiles;
23
24 while (<>) {
25     s/foo/bar/;
26 }
27 continue {
28     print;
29 }
30
31 is ( runperl( prog => 'print<>;', args => \@tfiles ),
32      "bar\nbar\nbar\n", 
33      "file contents properly replaced" );
34
35 is ( runperl( prog => 'print<>;', args => \@tfiles_bak ), 
36      "foo\nfoo\nfoo\n", 
37      "backup file contents stay the same" );
38