4 use Test::More 'no_plan';
6 use constant NO_SUCH_FILE => 'this_file_had_better_not_exist';
7 use constant EXCEPTION => 'autodie::exception';
9 # http://perlmonks.org/?node_id=744246 describes a situation where
10 # using autodie on user-defined functions can fail, depending upon
11 # their context. These tests attempt to detect this bug.
15 copy(NO_SUCH_FILE, 'xyzzy');
18 isa_ok($@,EXCEPTION,"Copying a non-existent file should throw an error");
22 my $x = copy(NO_SUCH_FILE, 'xyzzy');
25 isa_ok($@,EXCEPTION,"This shouldn't change with scalar context");
29 my @x = copy(NO_SUCH_FILE, 'xyzzy');
32 isa_ok($@,EXCEPTION,"This shouldn't change with array context");
34 # For good measure, test with built-ins.
38 open(my $fh, '<', 'xyzzy');
41 isa_ok($@,EXCEPTION,"Opening a non-existent file should throw an error");
45 my $x = open(my $fh, '<', 'xyzzy');
48 isa_ok($@,EXCEPTION,"This shouldn't change with scalar context");
52 my @x = open(my $fh, '<', 'xyzzy');
55 isa_ok($@,EXCEPTION,"This shouldn't change with array context");