1#!/usr/bin/perl -w 2use strict; 3use warnings; 4use Test::More tests => 10; 5use constant NO_SUCH_FILE => 'THIS_FILE_HAD_BETTER_NOT_EXIST'; 6 7eval { 8 use autodie qw(:1.994); 9 10 open(my $fh, '<', 'this_file_had_better_not_exist.txt'); 11}; 12 13isa_ok($@, 'autodie::exception', "Basic version tags work"); 14 15# Expanding :1.00 should fail, there was no autodie :1.00 16eval { my $foo = autodie->_expand_tag(":1.00"); }; 17 18isnt($@,"","Expanding :1.00 should fail"); 19 20my $version = $autodie::VERSION; 21 22SKIP: { 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 34eval { 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 43is($@,"","chmod wasn't supported in 2.07"); 44 45eval { 46 use autodie; 47 48 chmod(0644,NO_SUCH_FILE); 49}; 50 51isa_ok($@, 'autodie::exception', 'Our current version supports chmod'); 52 53eval { 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 62is($@,"","chown wasn't supported in 2.13"); 63 64SKIP: { 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 81eval { utime undef, undef, NO_SUCH_FILE; }; 82is($@,"","utime is not autodying outside of any autodie context."); 83 84# Now do our regular versioning checks for utime. 85 86eval { 87 use autodie qw(:2.13); 88 89 utime undef, undef, NO_SUCH_FILE; 90}; 91 92is($@,"","utime wasn't supported in 2.13"); 93 94eval { 95 use autodie; 96 97 utime undef, undef, NO_SUCH_FILE; 98}; 99 100isa_ok($@, 'autodie::exception', 'Our current version supports utime'); 101