| 1 |
#!/usr/bin/perl -w |
| 2 |
use strict; |
| 3 |
use warnings; |
| 4 |
use Test::More tests => 10; |
| 5 |
use constant NO_SUCH_FILE => 'THIS_FILE_HAD_BETTER_NOT_EXIST'; |
| 6 |
|
| 7 |
eval { |
| 8 |
use autodie qw(:1.994); |
| 9 |
|
| 10 |
open(my $fh, '<', 'this_file_had_better_not_exist.txt'); |
| 11 |
}; |
| 12 |
|
| 13 |
isa_ok($@, 'autodie::exception', "Basic version tags work"); |
| 14 |
|
| 15 |
# Expanding :1.00 should fail, there was no autodie :1.00 |
| 16 |
eval { my $foo = autodie->_expand_tag(":1.00"); }; |
| 17 |
|
| 18 |
isnt($@,"","Expanding :1.00 should fail"); |
| 19 |
|
| 20 |
my $version = $autodie::VERSION; |
| 21 |
|
| 22 |
SKIP: { |
| 23 |
|
| 24 |
if (not defined($version) or $version =~ /_/) { |
| 25 |
skip "Tag test skipped on dev release", 1; |
| 26 |
} |
| 27 |
|
| 28 |
# Expanding our current version should work! |
| 29 |
eval { my $foo = autodie->_expand_tag(":$version"); }; |
| 30 |
|
| 31 |
is($@,"","Expanding :$version should succeed"); |
| 32 |
} |
| 33 |
|
| 34 |
eval { |
| 35 |
use autodie qw(:2.07); |
| 36 |
|
| 37 |
# 2.07 didn't support chmod. This shouldn't throw an |
| 38 |
# exception. |
| 39 |
|
| 40 |
chmod(0644,NO_SUCH_FILE); |
| 41 |
}; |
| 42 |
|
| 43 |
is($@,"","chmod wasn't supported in 2.07"); |
| 44 |
|
| 45 |
eval { |
| 46 |
use autodie; |
| 47 |
|
| 48 |
chmod(0644,NO_SUCH_FILE); |
| 49 |
}; |
| 50 |
|
| 51 |
isa_ok($@, 'autodie::exception', 'Our current version supports chmod'); |
| 52 |
|
| 53 |
eval { |
| 54 |
use autodie qw(:2.13); |
| 55 |
|
| 56 |
# 2.13 didn't support chown. This shouldn't throw an |
| 57 |
# exception. |
| 58 |
|
| 59 |
chown(12345, 12345, NO_SUCH_FILE); |
| 60 |
}; |
| 61 |
|
| 62 |
is($@,"","chown wasn't supported in 2.13"); |
| 63 |
|
| 64 |
SKIP: { |
| 65 |
|
| 66 |
if ($^O eq "MSWin32") { skip("chown() on Windows always succeeds.", 1) } |
| 67 |
|
| 68 |
eval { |
| 69 |
use autodie; |
| 70 |
|
| 71 |
chown(12345, 12345, NO_SUCH_FILE); |
| 72 |
}; |
| 73 |
|
| 74 |
isa_ok($@, 'autodie::exception', 'Our current version supports chown'); |
| 75 |
} |
| 76 |
|
| 77 |
# The patch in RT 46984 would have utime being set even if an |
| 78 |
# older version of autodie semantics was requested. Let's see if |
| 79 |
# it's coming from outside the eval context below. |
| 80 |
|
| 81 |
eval { utime undef, undef, NO_SUCH_FILE; }; |
| 82 |
is($@,"","utime is not autodying outside of any autodie context."); |
| 83 |
|
| 84 |
# Now do our regular versioning checks for utime. |
| 85 |
|
| 86 |
eval { |
| 87 |
use autodie qw(:2.13); |
| 88 |
|
| 89 |
utime undef, undef, NO_SUCH_FILE; |
| 90 |
}; |
| 91 |
|
| 92 |
is($@,"","utime wasn't supported in 2.13"); |
| 93 |
|
| 94 |
eval { |
| 95 |
use autodie; |
| 96 |
|
| 97 |
utime undef, undef, NO_SUCH_FILE; |
| 98 |
}; |
| 99 |
|
| 100 |
isa_ok($@, 'autodie::exception', 'Our current version supports utime'); |