Commit | Line | Data |
---|---|---|
2d259d92 | 1 | #!./perl |
99ec4a7e | 2 | use strict; |
b5efbd1f | 3 | chdir 't' if -d 't'; |
99ec4a7e | 4 | require './test.pl'; |
2d259d92 | 5 | |
62a28c97 | 6 | $^I = 'bak.*'; |
2d259d92 CK |
7 | |
8 | # Modified from the original inplace.t to test adding prefixes | |
9 | ||
99ec4a7e | 10 | plan( tests => 2 ); |
2d259d92 | 11 | |
62a28c97 NC |
12 | my @tfiles = (tempfile(), tempfile(), tempfile()); |
13 | my @tfiles_bak = map "bak.$_", @tfiles; | |
99ec4a7e | 14 | |
62a28c97 | 15 | END { unlink_all(@tfiles_bak); } |
99ec4a7e CB |
16 | |
17 | for my $file (@tfiles) { | |
18 | runperl( prog => 'print qq(foo\n);', | |
19 | args => ['>', $file] ); | |
2d259d92 | 20 | } |
99ec4a7e CB |
21 | |
22 | @ARGV = @tfiles; | |
23 | ||
2d259d92 CK |
24 | while (<>) { |
25 | s/foo/bar/; | |
26 | } | |
27 | continue { | |
28 | print; | |
29 | } | |
30 | ||
99ec4a7e CB |
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" ); | |
2d259d92 | 38 |