From: SADAHIRO Tomoyuki Date: Thu, 26 May 2005 23:46:35 +0000 (+0900) Subject: bytes.pm doesn't check undefined subroutine calling X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5b5a256ab100c58f58aab1b20dc1f7777b745fd1;p=p5sagit%2Fp5-mst-13.2.git bytes.pm doesn't check undefined subroutine calling Message-Id: <20050526234321.92F1.BQW10602@nifty.com> p4raw-id: //depot/perl@24585 --- diff --git a/lib/bytes.pm b/lib/bytes.pm index 9a04491..a822279 100644 --- a/lib/bytes.pm +++ b/lib/bytes.pm @@ -1,6 +1,6 @@ package bytes; -our $VERSION = '1.01'; +our $VERSION = '1.02'; $bytes::hint_bits = 0x00000008; @@ -14,7 +14,9 @@ sub unimport { sub AUTOLOAD { require "bytes_heavy.pl"; - goto &$AUTOLOAD; + goto &$AUTOLOAD if defined &$AUTOLOAD; + require Carp; + Carp::croak("Undefined subroutine $AUTOLOAD called"); } sub length ($); diff --git a/lib/bytes.t b/lib/bytes.t index 6b66a55..ea1b9f6 100644 --- a/lib/bytes.t +++ b/lib/bytes.t @@ -4,7 +4,7 @@ BEGIN { require './test.pl'; } -plan tests => 19; +plan tests => 20; my $a = chr(0x100); @@ -46,3 +46,9 @@ my $c = chr(0x100); is(bytes::index($c, "\x80"), 1, "bytes::index under use bytes looks at bytes"); is(bytes::rindex($c, "\xc4"), 0, "bytes::rindex under use bytes looks at bytes"); } + +{ + fresh_perl_like ('use bytes; bytes::moo()', + qr/Undefined subroutine bytes::moo/, {stderr=>1}, + "Check Carp is loaded for AUTOLOADing errors") +}