Commit | Line | Data |
---|---|---|
0b09a93a PF |
1 | #!/usr/bin/perl -w |
2 | use strict; | |
3 | ||
4 | use constant NO_SUCH_FILE => "this_file_or_dir_had_better_not_exist_XYZZY"; | |
5 | ||
6 | use Test::More tests => 6; | |
7 | ||
8 | # Lexical tests using the internal interface. | |
9 | ||
10 | eval { Fatal->import(qw(:lexical :void)) }; | |
11 | like($@, qr{:void cannot be used with lexical}, ":void can't be used with :lexical"); | |
12 | ||
13 | eval { Fatal->import(qw(open close :lexical)) }; | |
14 | like($@, qr{:lexical must be used as first}, ":lexical must come first"); | |
15 | ||
16 | { | |
17 | use Fatal qw(:lexical chdir); | |
18 | ||
19 | eval { chdir(NO_SUCH_FILE); }; | |
20 | like ($@, qr/^Can't chdir/, "Lexical fatal chdir"); | |
21 | ||
22 | no Fatal qw(:lexical chdir); | |
23 | ||
24 | eval { chdir(NO_SUCH_FILE); }; | |
25 | is ($@, "", "No lexical fatal chdir"); | |
26 | ||
27 | } | |
28 | ||
29 | eval { chdir(NO_SUCH_FILE); }; | |
30 | is($@, "", "Lexical chdir becomes non-fatal out of scope."); | |
31 | ||
32 | eval { Fatal->import('2+2'); }; | |
33 | like($@,qr{Bad subroutine name},"Can't use fatal with invalid sub names"); |