| 1 |
#!/usr/bin/perl -w |
| 2 |
use strict; |
| 3 |
use Test::More tests => 4; |
| 4 |
use constant NO_SUCH_FILE => "this_file_had_better_not_exist"; |
| 5 |
use FindBin qw($Bin); |
| 6 |
use File::Spec; |
| 7 |
use autodie; |
| 8 |
use File::Temp qw(tempfile); |
| 9 |
|
| 10 |
my ($fh, $filename) = tempfile; |
| 11 |
|
| 12 |
eval { utime(undef, undef, NO_SUCH_FILE); }; |
| 13 |
isa_ok($@, 'autodie::exception', 'exception thrown for utime'); |
| 14 |
|
| 15 |
my($atime, $mtime) = (stat $filename)[8, 9]; |
| 16 |
|
| 17 |
eval { utime(undef, undef, $filename); }; |
| 18 |
ok(! $@, "We can utime a file just fine.") or diag $@; |
| 19 |
|
| 20 |
eval { utime(undef, undef, NO_SUCH_FILE, $filename); }; |
| 21 |
isa_ok($@, 'autodie::exception', 'utime exception on single failure.'); |
| 22 |
is($@->return, 1, "utime fails correctly on a 'true' failure."); |