This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add a test for carp et alia.
[perl5.git] / t / lib / carp.t
CommitLineData
0e25c5fd
JH
1BEGIN {
2 chdir 't' if -d 't';
3 @INC = '../lib';
4}
5
6use Carp qw(carp cluck croak confess);
7
8print "1..7\n";
9
10print "ok 1\n";
11
12carp "ok 2\n";
13
14$SIG{__WARN__} = sub { print "ok $1\n"
15 if $_[0] =~ m!(\d+) at .+\b(?i:carp\.t) line \d+$! };
16
17carp 3;
18
19sub sub_4 {
20
21$SIG{__WARN__} = sub { print "ok $1\n"
22 if $_[0] =~ m!^(\d+) at .+\b(?i:carp\.t) line \d+\n\tmain::sub_4\(\) called at .+\b(?i:carp\.t) line \d+$! };
23
24cluck 4;
25
26}
27
28sub_4;
29
30$SIG{__DIE__} = sub { print "ok $1\n"
31 if $_[0] =~ m!^(\d+) at .+\b(?i:carp\.t) line \d+\n\teval \Q{...}\E called at .+\b(?i:carp\.t) line \d+$! };
32
33eval { croak 5 };
34
35sub sub_6 {
36 $SIG{__DIE__} = sub { print "ok $1\n"
37 if $_[0] =~ m!^(\d+) at .+\b(?i:carp\.t) line \d+\n\teval \Q{...}\E called at .+\b(?i:carp\.t) line \d+\n\tmain::sub_6\(\) called at .+\b(?i:carp\.t) line \d+$! };
38
39 eval { confess 6 };
40}
41
42sub_6;
43
44print "ok 7\n";
45