Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[io grant] Test IO::Path.copy/move when source/target are same
  • Loading branch information
zoffixznet committed May 2, 2017
1 parent 7be8339 commit 4fdb850
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
12 changes: 11 additions & 1 deletion S32-io/copy.t
@@ -1,7 +1,9 @@
use v6;
use lib <t/spec/packages>;
use Test;
use Test::Util;

plan 41;
plan 42;

my $existing-file = "tempfile-copy";
my $non-existent-file = "non-existent-copy";
Expand Down Expand Up @@ -88,4 +90,12 @@ nok $non-existent-file.IO.e, "It doesn't";
ok unlink($existing-file), 'file has been removed';
ok unlink($zero-length-file), 'file has been removed';

# RT#131242
subtest 'copying when target and source are same file' => {
plan 2;
my $file = make-temp-file :content<foo>;
fails-like { $file.copy: $file }, X::IO::Copy, 'copying fails';
is-deeply $file.slurp, 'foo', 'file contents are untouched';
}

# vim: ft=perl6
12 changes: 11 additions & 1 deletion S32-io/move.t
@@ -1,7 +1,9 @@
use v6;
use lib <t/spec/packages>;
use Test;
use Test::Util;

plan 29;
plan 30;

my $existing-file1 = "tempfile-move1";
my $existing-file2 = "tempfile-move2";
Expand Down Expand Up @@ -78,4 +80,12 @@ nok $non-existent-file.IO.e, "sanity check 2";
ok unlink($existing-file1), 'clean-up 3';
ok unlink($existing-file2), 'clean-up 4';

# RT#131242
subtest 'moving when target and source are same file' => {
plan 2;
my $file = make-temp-file :content<foo>;
fails-like { $file.move: $file }, X::IO::Move, 'moving fails';
is-deeply $file.slurp, 'foo', 'file contents are untouched';
}

# vim: ft=perl6

0 comments on commit 4fdb850

Please sign in to comment.