4 use constant NO_SUCH_FILE => "this_file_or_dir_had_better_not_exist_XYZZY";
6 use Test::More tests => 17;
8 use Fatal qw(open close :void opendir);
10 eval { open FOO, "<".NO_SUCH_FILE }; # Two arg open
11 like($@, qr/^Can't open/, q{Package Fatal::open});
12 is(ref $@, "", "Regular fatal throws a string");
15 for ('$foo', "'$foo'", "*$foo", "\\*$foo") {
16 eval qq{ open $_, '<$0' };
18 is($@,"", "Open using filehandle named - $_");
20 like(scalar(<$foo>), qr{^#!.*/perl}, "File contents using - $_");
23 is($@,"", "Close filehandle using - $_");
26 eval { opendir FOO, NO_SUCH_FILE };
27 like($@, qr{^Can't open}, "Package :void Fatal::opendir");
29 eval { my $a = opendir FOO, NO_SUCH_FILE };
30 is($@, "", "Package :void Fatal::opendir in scalar context");
32 eval { Fatal->import(qw(print)) };
34 $@, qr{Cannot make the non-overridable builtin print fatal},
35 "Can't override print"