This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fixes to compile Perl with g++ and DEBUGGING.
[perl5.git] / lib / SelfLoader-buggy.t
CommitLineData
cca8f13b
AF
1#!./perl
2
3BEGIN {
4 if( $ENV{PERL_CORE} ) {
5 chdir 't' if -d 't';
6 @INC = '../lib';
7 }
8}
9
10use SelfLoader;
4e3c68f2 11print "1..1\n";
cca8f13b
AF
12
13# this script checks that errors on self-loaded
14# subroutines that affect $@ are reported
15
16eval { buggy(); };
17unless ($@ =~ /^syntax error/) {
18 print "not ";
19}
20print "ok 1 - syntax errors are reported\n";
21
22__END__
23
24sub buggy
25{
26 +>*;
27}
28
29
30=head1 RT 40216
31
32 by Bo Lindbergh <blgl@hagernas.com>, at Aug 22, 2006 5:42 PM
33
34In the example below, there's a syntax error in the selfloaded
35code for main::buggy. When the eval fails, SelfLoader::AUTOLOAD
36tries to report this with "croak $@;". Unfortunately,
37SelfLoader::croak does "require Carp;" without protecting $@,
38which gets clobbered. The program then dies with the
39uninformative message " at ./example line 3".
40
41#! /usr/local/bin/perl
42use SelfLoader;
43buggy();
44__END__
45sub buggy
46{
47 +>*;
48}
49
50=cut
51