xref: /openbsd-src/gnu/usr.bin/perl/cpan/autodie/t/internal.t (revision f2da64fbbbf1b03f09f390ab01267c93dfd77c4c)
1#!/usr/bin/perl -w
2use strict;
3
4use constant NO_SUCH_FILE => "this_file_or_dir_had_better_not_exist_XYZZY";
5
6use Test::More tests => 6;
7
8# Lexical tests using the internal interface.
9
10eval { Fatal->import(qw(:lexical :void)) };
11like($@, qr{:void cannot be used with lexical}, ":void can't be used with :lexical");
12
13eval { Fatal->import(qw(open close :lexical)) };
14like($@, 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
29eval { chdir(NO_SUCH_FILE); };
30is($@, "", "Lexical chdir becomes non-fatal out of scope.");
31
32eval { Fatal->import('2+2'); };
33like($@,qr{Bad subroutine name},"Can't use fatal with invalid sub names");
34