Fix installation of 'autodie'
[p5sagit/p5-mst-13.2.git] / t / lib / autodie / scope_leak.t
CommitLineData
0b09a93a 1#!/usr/bin/perl -w
2use strict;
3use FindBin;
4
5# Check for %^H leaking across file boundries. Many thanks
6# to chocolateboy for pointing out this can be a problem.
7
8use lib $FindBin::Bin;
9
10use Test::More 'no_plan';
11
12use constant NO_SUCH_FILE => 'this_file_had_better_not_exist';
13use autodie qw(open);
14
15eval {
16 open(my $fh, '<', NO_SUCH_FILE);
17};
18
19ok($@, "basic autodie test");
20
21use autodie_test_module;
22
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).
26
27eval {
28 leak_test(NO_SUCH_FILE);
29};
30
31is($@,"","autodying main::open should not leak to other files");
32
33eval {
34 autodie_test_module::your_open(NO_SUCH_FILE);
35};
36
37is($@,"","Other package open should be unaffected");