This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update autodie to CPAN version 2.19
[perl5.git] / cpan / autodie / t / autodie_test_module.pm
1 package main;
2 use strict;
3 use warnings;
4
5 use constant NOFILE1 => 'this_file_had_better_not_exist';
6 use constant NOFILE2 => NOFILE1 . '2';
7 use constant NOFILE3 => NOFILE1 . '3';
8
9 # Calls open, while still in the main package.  This shouldn't
10 # be autodying.
11 sub leak_test {
12     return open(my $fh, '<', $_[0]);
13 }
14
15 # This rename shouldn't be autodying, either.
16 sub leak_test_rename {
17     return rename($_[0], $_[1]);
18 }
19
20 # These are used by core-trampoline-slurp.t
21 sub slurp_leak_unlink {
22     unlink(NOFILE1, NOFILE2, NOFILE3);
23 }
24
25 sub slurp_leak_open {
26     open(1,2,3,4,5);
27 }
28
29 package autodie_test_module;
30
31 # This should be calling CORE::open
32 sub your_open {
33     return open(my $fh, '<', $_[0]);
34 }
35
36 # This should be calling CORE::rename
37 sub your_rename {
38     return rename($_[0], $_[1]);
39 }
40
41 sub your_dying_rename {
42     use autodie qw(rename);
43     return rename($_[0], $_[1]);
44 }
45
46 1;