File: version_tag.t

package info (click to toggle)
perl 5.42.0-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 128,392 kB
  • sloc: perl: 534,963; ansic: 240,563; sh: 72,042; pascal: 6,934; xml: 2,428; yacc: 1,360; makefile: 1,197; cpp: 208; lisp: 1
file content (100 lines) | stat: -rw-r--r-- 2,139 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/perl -w
use strict;
use warnings;
use Test::More tests => 10;
use constant NO_SUCH_FILE => 'THIS_FILE_HAD_BETTER_NOT_EXIST';

eval {
    use autodie qw(:1.994);

    open(my $fh, '<', 'this_file_had_better_not_exist.txt');
};

isa_ok($@, 'autodie::exception', "Basic version tags work");

# Expanding :1.00 should fail, there was no autodie :1.00
eval { my $foo = autodie->_expand_tag(":1.00"); };

isnt($@,"","Expanding :1.00 should fail");

my $version = $autodie::VERSION;

SKIP: {

    if (not defined($version) or $version =~ /_/) {
	skip "Tag test skipped on dev release", 1;
    }

    # Expanding our current version should work!
    eval { my $foo = autodie->_expand_tag(":$version"); };

    is($@,"","Expanding :$version should succeed");
}

eval {
    use autodie qw(:2.07);

    # 2.07 didn't support chmod.  This shouldn't throw an
    # exception.

    chmod(0644,NO_SUCH_FILE);
};

is($@,"","chmod wasn't supported in 2.07");

eval {
    use autodie;

    chmod(0644,NO_SUCH_FILE);
};

isa_ok($@, 'autodie::exception', 'Our current version supports chmod');

eval {
    use autodie qw(:2.13);

    # 2.13 didn't support chown.  This shouldn't throw an
    # exception.

    chown(12345, 12345, NO_SUCH_FILE);
};

is($@,"","chown wasn't supported in 2.13");

SKIP: {

    if ($^O eq "MSWin32") { skip("chown() on Windows always succeeds.", 1) }

    eval {
        use autodie;

        chown(12345, 12345, NO_SUCH_FILE);
    };

    isa_ok($@, 'autodie::exception', 'Our current version supports chown');
}

# The patch in RT 46984 would have utime being set even if an
# older version of autodie semantics was requested. Let's see if
# it's coming from outside the eval context below.

eval { utime undef, undef, NO_SUCH_FILE; };
is($@,"","utime is not autodying outside of any autodie context.");

# Now do our regular versioning checks for utime.

eval {
    use autodie qw(:2.13);

    utime undef, undef, NO_SUCH_FILE;
};

is($@,"","utime wasn't supported in 2.13");

eval {
    use autodie;

    utime undef, undef, NO_SUCH_FILE;
};

isa_ok($@, 'autodie::exception', 'Our current version supports utime');