diff options
author | Tony Cook <tony@develop-help.com> | 2018-11-20 16:43:43 +1100 |
---|---|---|
committer | Tony Cook <tony@develop-help.com> | 2018-11-26 13:48:36 +1100 |
commit | 640e129d0fc499d24a759cacae9240a32c66fa51 (patch) | |
tree | f3c620d8b62cad9f497b0398b53eac82bb959bf3 | |
parent | 404395d24bc87890c7d978622296b9925a347aa0 (diff) | |
download | perl-640e129d0fc499d24a759cacae9240a32c66fa51.tar.gz |
(perl #133659) tests for global destruction handling of inplace editing
-rw-r--r-- | t/io/inplace.t | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/t/io/inplace.t b/t/io/inplace.t index 98159e06bf..ac50f1ab77 100644 --- a/t/io/inplace.t +++ b/t/io/inplace.t @@ -5,7 +5,7 @@ require './test.pl'; $^I = $^O eq 'VMS' ? '_bak' : '.bak'; -plan( tests => 6 ); +plan( tests => 8 ); my @tfiles = (tempfile(), tempfile(), tempfile()); my @tfiles_bak = map "$_$^I", @tfiles; @@ -91,3 +91,29 @@ SKIP: END { unlink_all(@ifiles); } } + +{ + my @tests = + ( # opts, code, result, name, $TODO + [ "-n", "die", "bar\n", "die shouldn't touch file" ], + [ "-n", "last", "", "last should update file", "not implemented yet" ], + ); + our $file = tempfile() ; + + for my $test (@tests) { + (my ($opts, $code, $result, $name), our $TODO) = @$test; + open my $fh, ">", $file or die; + print $fh "bar\n"; + close $fh; + + runperl( prog => $code, + switches => [ grep length, "-i", $opts ], + args => [ $file ], + stderr => 1, # discarded + ); + open $fh, "<", $file or die; + my $data = do { local $/; <$fh>; }; + close $fh; + is($data, $result, $name); + } +} |