5 use Test::More 'no_plan';
7 use lib "$FindBin::Bin/lib";
9 use constant NO_SUCH_FILE => "this_file_had_better_not_exist_xyzzy";
11 ### Tests with non-existent exception class.
13 my $open_success = eval {
14 use autodie::test::missing qw(open); # Uses non-existent exceptions
15 open(my $fh, '<', NO_SUCH_FILE);
19 is($open_success,undef,"Open should fail");
21 isnt($@,"",'$@ should not be empty');
23 is(ref($@),"",'$@ should not be a reference or object');
25 like($@, qr/Failed to load/, '$@ should contain bad exception class msg');
27 #### Tests with malformed exception class.
29 my $open_success2 = eval {
30 use autodie::test::badname qw(open);
31 open(my $fh, '<', NO_SUCH_FILE);
35 is($open_success2,undef,"Open should fail");
37 isnt($@,"",'$@ should not be empty');
39 is(ref($@),"",'$@ should not be a reference or object');
41 like($@, qr/Bad exception class/, '$@ should contain bad exception class msg');
43 ### Tests with well-formed exception class (in Klingon)
45 my $open_success3 = eval {
46 use pujHa'ghach qw(open); #' <-- this makes my editor happy
47 open(my $fh, '<', NO_SUCH_FILE);
51 is($open_success3,undef,"Open should fail");
53 isnt("$@","",'$@ should not be empty');
55 isa_ok($@, "pujHa'ghach::Dotlh", '$@ should be a Klingon exception');
57 like($@, qr/lujqu'/, '$@ should contain Klingon text');