Debian Codegraph @

dist/SelfLoader/t/02SelfLoader-buggy.t

raw
1 use SelfLoader;
2 print "1..1\n";
3
4 # this script checks that errors on self-loaded
5 # subroutines that affect $@ are reported
6
7 eval { buggy(); };
8 unless ($@ =~ /^syntax error/) {
9 print "not ";
10 }
11 print "ok 1 - syntax errors are reported\n";
12
13 __END__
14
15 sub buggy
16 {
17 +>*;
18 }
19
20
21 # RT 40216
22 #
23 # by Bo Lindbergh <[email protected]>, at Aug 22, 2006 5:42 PM
24 #
25 # In the example below, there's a syntax error in the selfloaded
26 # code for main::buggy. When the eval fails, SelfLoader::AUTOLOAD
27 # tries to report this with "croak $@;". Unfortunately,
28 # SelfLoader::croak does "require Carp;" without protecting $@,
29 # which gets clobbered. The program then dies with the
30 # uninformative message " at ./example line 3".
31 #
32 # #! /usr/local/bin/perl
33 # use SelfLoader;
34 # buggy();
35 # __END__
36 # sub buggy
37 # {
38 # +>*;
39 # }