[ PATCH ] mymalloc on HP-UX
[p5sagit/p5-mst-13.2.git] / lib / Carp.t
CommitLineData
0e25c5fd 1BEGIN {
2 chdir 't' if -d 't';
3 @INC = '../lib';
4}
5
6use Carp qw(carp cluck croak confess);
7
b5777b26 8print "1..9\n";
0e25c5fd 9
10print "ok 1\n";
11
1115139d 12$SIG{__WARN__} = sub {
13 print "ok $1\n"
14 if $_[0] =~ m!ok (\d+)$! };
0e25c5fd 15
1115139d 16carp "ok 2\n";
17
18$SIG{__WARN__} = sub {
19 print "ok $1\n"
20 if $_[0] =~ m!(\d+) at .+\b(?i:carp\.t) line \d+$! };
0e25c5fd 21
22carp 3;
23
24sub sub_4 {
25
1115139d 26$SIG{__WARN__} = sub {
27 print "ok $1\n"
28 if $_[0] =~ m!^(\d+) at .+\b(?i:carp\.t) line \d+\n\tmain::sub_4\(\) called at .+\b(?i:carp\.t) line \d+$! };
0e25c5fd 29
30cluck 4;
31
32}
33
34sub_4;
35
1115139d 36$SIG{__DIE__} = sub {
37 print "ok $1\n"
38 if $_[0] =~ m!^(\d+) at .+\b(?i:carp\.t) line \d+\n\teval \Q{...}\E called at .+\b(?i:carp\.t) line \d+$! };
0e25c5fd 39
40eval { croak 5 };
41
42sub sub_6 {
1115139d 43 $SIG{__DIE__} = sub {
44 print "ok $1\n"
45 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+$! };
0e25c5fd 46
47 eval { confess 6 };
48}
49
50sub_6;
51
52print "ok 7\n";
53
976ea96e 54# test for caller_info API
55my $eval = "use Carp::Heavy; return Carp::caller_info(0);";
56my %info = eval($eval);
57print "not " if ($info{sub_name} ne "eval '$eval'");
58print "ok 8\n";
b5777b26 59
60# test for '...::CARP_NOT used only once' warning from Carp::Heavy
61my $warning;
62eval {
63 BEGIN {
64 $^W = 1;
65 $SIG{__WARN__} =
66 sub { if( defined $^S ){ warn $_[0] } else { $warning = $_[0] } }
67 }
68 package Z;
69 BEGIN { eval { Carp::croak() } }
70};
71print $warning ? "not ok 9\n#$warning" : "ok 9\n";