use warnings::register;
use vars qw($VERSION %declared);
-$VERSION = '1.19';
+$VERSION = '1.20';
#=======================================================================
}
$constants = shift;
} else {
- $constants->{+shift} = undef;
- }
-
- foreach my $name ( keys %$constants ) {
- unless (defined $name) {
+ unless (defined $_[0]) {
require Carp;
Carp::croak("Can't use undef as constant name");
}
+ $constants->{+shift} = undef;
+ }
+ foreach my $name ( keys %$constants ) {
# Normal constant name
if ($name =~ $normal_constant_name and !$forbidden{$name}) {
# Everything is okay
use strict;
-use Test::More tests => 95;
+use Test::More tests => 96;
my $TB = Test::More->builder;
BEGIN { use_ok('constant'); }
is ($@, '');
is_deeply (\@value, []);
}
+
+{
+ local $SIG{'__WARN__'} = sub { die "WARNING: $_[0]" };
+ eval 'use constant undef, 5; 1';
+ like $@, qr/\ACan't use undef as constant name at /;
+}