xref: /openbsd-src/gnu/usr.bin/perl/cpan/autodie/t/lethal.t (revision b39c515898423c8d899e35282f4b395f7cad3298)
1*b39c5158Smillert#!/usr/bin/perl -w
2*b39c5158Smillertuse strict;
3*b39c5158Smillertuse FindBin;
4*b39c5158Smillertuse Test::More tests => 4;
5*b39c5158Smillertuse lib "$FindBin::Bin/lib";
6*b39c5158Smillertuse lethal qw(open);
7*b39c5158Smillert
8*b39c5158Smillertuse constant NO_SUCH_FILE => "this_file_had_better_not_exist";
9*b39c5158Smillert
10*b39c5158Smillerteval {
11*b39c5158Smillert    open(my $fh, '<', NO_SUCH_FILE);
12*b39c5158Smillert};
13*b39c5158Smillert
14*b39c5158Smillertok($@, "lethal throws an exception");
15*b39c5158Smillertisa_ok($@, 'autodie::exception','...which is the correct class');
16*b39c5158Smillertok($@->matches('open'),         "...which matches open");
17*b39c5158Smillertis($@->file,__FILE__,           "...which reports the correct file");
18