This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[PATCHES] various small Math::BigInt et. al. fixes
[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
a37cecd0
RGS
30# RT 40216
31#
32# by Bo Lindbergh <blgl@hagernas.com>, at Aug 22, 2006 5:42 PM
33#
34# In the example below, there's a syntax error in the selfloaded
35# code for main::buggy. When the eval fails, SelfLoader::AUTOLOAD
36# tries to report this with "croak $@;". Unfortunately,
37# SelfLoader::croak does "require Carp;" without protecting $@,
38# which gets clobbered. The program then dies with the
39# uninformative message " at ./example line 3".
40#
41# #! /usr/local/bin/perl
42# use SelfLoader;
43# buggy();
44# __END__
45# sub buggy
46# {
47# +>*;
48# }