Line | |
---|
1 | #!./perl
|
---|
2 |
|
---|
3 | print "1..15\n";
|
---|
4 |
|
---|
5 | $SIG{__DIE__} = sub { print ref($_[0]) ? ("ok ",$_[0]->[0]++,"\n") : @_ } ;
|
---|
6 |
|
---|
7 | $err = "#[\000]\nok 1\n";
|
---|
8 | eval {
|
---|
9 | die $err;
|
---|
10 | };
|
---|
11 |
|
---|
12 | print "not " unless $@ eq $err;
|
---|
13 | print "ok 2\n";
|
---|
14 |
|
---|
15 | $x = [3];
|
---|
16 | eval { die $x; };
|
---|
17 |
|
---|
18 | print "not " unless $x->[0] == 4;
|
---|
19 | print "ok 4\n";
|
---|
20 |
|
---|
21 | eval {
|
---|
22 | eval {
|
---|
23 | die [ 5 ];
|
---|
24 | };
|
---|
25 | die if $@;
|
---|
26 | };
|
---|
27 |
|
---|
28 | eval {
|
---|
29 | eval {
|
---|
30 | die bless [ 7 ], "Error";
|
---|
31 | };
|
---|
32 | die if $@;
|
---|
33 | };
|
---|
34 |
|
---|
35 | print "not " unless ref($@) eq "Out";
|
---|
36 | print "ok 10\n";
|
---|
37 |
|
---|
38 | {
|
---|
39 | package Error;
|
---|
40 |
|
---|
41 | sub PROPAGATE {
|
---|
42 | print "ok ",$_[0]->[0]++,"\n";
|
---|
43 | bless [$_[0]->[0]], "Out";
|
---|
44 | }
|
---|
45 | }
|
---|
46 |
|
---|
47 | {
|
---|
48 | # die/warn and utf8
|
---|
49 | use utf8;
|
---|
50 | local $SIG{__DIE__};
|
---|
51 | my $msg = "ce ºtii tu, bã ?\n";
|
---|
52 | eval { die $msg }; print "not " unless $@ eq $msg;
|
---|
53 | print "ok 11\n";
|
---|
54 | our $err;
|
---|
55 | local $SIG{__WARN__} = $SIG{__DIE__} = sub { $err = shift };
|
---|
56 | eval { die $msg }; print "not " unless $err eq $msg;
|
---|
57 | print "ok 12\n";
|
---|
58 | eval { warn $msg }; print "not " unless $err eq $msg;
|
---|
59 | print "ok 13\n";
|
---|
60 | eval qq/ use strict; \$\x{3b1} /;
|
---|
61 | print "not " unless $@ =~ /Global symbol "\$\x{3b1}"/;
|
---|
62 | print "ok 14\n";
|
---|
63 | }
|
---|
64 |
|
---|
65 | # [perl #36470] got uninit warning if $@ was undef
|
---|
66 |
|
---|
67 | {
|
---|
68 | my $ok = 1;
|
---|
69 | local $SIG{__DIE__};
|
---|
70 | local $SIG{__WARN__} = sub { $ok = 0 };
|
---|
71 | eval { undef $@; die };
|
---|
72 | print "not " unless $ok;
|
---|
73 | print "ok 15\n";
|
---|
74 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.