xref: /openbsd-src/gnu/usr.bin/perl/dist/SelfLoader/t/02SelfLoader-buggy.t (revision b39c515898423c8d899e35282f4b395f7cad3298)
1use SelfLoader;
2print "1..1\n";
3
4# this script checks that errors on self-loaded
5# subroutines that affect $@ are reported
6
7eval { buggy(); };
8unless ($@ =~ /^syntax error/) {
9    print "not ";
10}
11print "ok 1 - syntax errors are reported\n";
12
13__END__
14
15sub buggy
16{
17    +>*;
18}
19
20
21# RT 40216
22#
23# by Bo Lindbergh <blgl@hagernas.com>, 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# }
40