5 # Check for %^H leaking across file boundries. Many thanks
6 # to chocolateboy for pointing out this can be a problem.
10 use Test::More 'no_plan';
12 use constant NO_SUCH_FILE => 'this_file_had_better_not_exist';
16 open(my $fh, '<', NO_SUCH_FILE);
19 ok($@, "basic autodie test");
21 use autodie_test_module;
23 # If things don't work as they should, then the file we've
24 # just loaded will still have an autodying main::open (although
25 # its own open should be unaffected).
28 leak_test(NO_SUCH_FILE);
31 is($@,"","autodying main::open should not leak to other files");
34 autodie_test_module::your_open(NO_SUCH_FILE);
37 is($@,"","Other package open should be unaffected");
39 # Due to odd filenames reported when doing string evals,
40 # older versions of autodie would not propogate into string evals.
43 open(my $fh, '<', NO_SUCH_FILE);
47 local $TODO = "No known way of propagating into string eval in 5.8"
50 ok($@, "Failing-open string eval should throw an exception");
51 isa_ok($@, 'autodie::exception');
57 open(my $fh, '<', NO_SUCH_FILE);
60 is("$@","","disabling autodie in string context should work");
63 open(my $fh, '<', NO_SUCH_FILE);
66 ok($@,"...but shouldn't disable it for the calling code.");
67 isa_ok($@, 'autodie::exception');
74 open(my $fh, '<', NO_SUCH_FILE);
77 ok($@,"Wacky flipping of autodie in string eval should work too!");
78 isa_ok($@, 'autodie::exception');