Skip to content

Commit

Permalink
5.10 doesn't auto-load Carp, apparently
Browse files Browse the repository at this point in the history
  • Loading branch information
sartak committed Sep 23, 2007
1 parent 940fca1 commit 79c33ee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
14 changes: 10 additions & 4 deletions lib/NetHack/PriceID.pm
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ our %item_table =
},
);

sub _croak
{
require Carp;
Carp::croak @_;
}

sub priceid
{
my %args = _canonicalize_args(@_);
Expand All @@ -133,7 +139,7 @@ sub priceid_buy
my %args = _canonicalize_args(@_);
my @base;

Carp::croak "Calculating 'buy' prices requires that you set 'charisma'."
_croak "Calculating 'buy' prices requires that you set 'charisma'."
if !defined $args{charisma};

for my $base (keys %{ $item_table{ $args{type} } })
Expand Down Expand Up @@ -216,15 +222,15 @@ sub _canonicalize_args
@_,
);

Carp::croak "Price IDing requires that you set 'amount'"
_croak "Price IDing requires that you set 'amount'"
if !defined $args{amount};

Carp::croak "Price IDing requires that you set 'type'"
_croak "Price IDing requires that you set 'type'"
if !defined $args{type};

$args{type} = $glyph2type{ $args{type} } || $args{type};

Carp::croak "Unknown item type: $args{type}"
_croak "Unknown item type: $args{type}"
if !exists $item_table{ $args{type} };

return %args;
Expand Down
3 changes: 2 additions & 1 deletion t/005-error.t
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!perl -T
use strict;
use warnings;
use Test::More tests => 11;
use Test::More tests => 12;
use NetHack::PriceID 'priceid';

eval
Expand All @@ -16,6 +16,7 @@ eval

ok($@);
like($@, qr/Calculating 'buy' prices requires that you set 'charisma'/);
like($@, qr/005-error/, "croak reports the correct file");

eval
{
Expand Down

0 comments on commit 79c33ee

Please sign in to comment.