5 use constant TMPFILE => "$Bin/unlink_test_delete_me";
7 # Create a file to practice unlinking
8 open(my $fh, ">", TMPFILE)
9 or plan skip_all => "Unable to create test file: $!";
13 # Check that file now exists
14 -e TMPFILE or plan skip_all => "Failed to create test file";
20 if(-e TMPFILE) {plan skip_all => "Failed to delete test file: $!";}
23 open(my $fh2, ">", TMPFILE)
24 or plan skip_all => "Unable to create test file: $!";
25 print {$fh2} "Test\n";
28 # Check that file now exists
29 -e TMPFILE or plan skip_all => "Failed to create test file";
33 # Try to delete directory (this should succeed)
39 is($@, "", "Unlink appears to have been successful");
40 ok(! -e TMPFILE, "File does not exist");
42 # Try to delete file again (this should fail)
48 ok($@, "Re-unlinking file causes failure.");
49 isa_ok($@, "autodie::exception", "... errors are of the correct type");
50 ok($@->matches("unlink"), "... it's also a unlink object");
51 ok($@->matches(":filesys"), "... and a filesys object");