From 5b5a256ab100c58f58aab1b20dc1f7777b745fd1 Mon Sep 17 00:00:00 2001 From: SADAHIRO Tomoyuki Date: Fri, 27 May 2005 08:46:35 +0900 Subject: [PATCH] bytes.pm doesn't check undefined subroutine calling Message-Id: <20050526234321.92F1.BQW10602@nifty.com> p4raw-id: //depot/perl@24585 --- lib/bytes.pm | 6 ++++-- lib/bytes.t | 8 +++++++- 2 files changed, 11 insertions(+), 3 deletions(-) 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") +} -- 2.7.4