my %args;
if (scalar @_ == 1 && defined $_[0] && ref($_[0]) eq 'HASH') {
%args = %{$_[0]};
- } else {
+ } elsif( scalar(@_) ) {
%args = @_;
}
my @extra = grep { !exists($self->{$_}) } keys %args;
=head1 AUTHOR
-Guillermo Roditi (groditi) <groditi@cpan.org>
+Guillermo Roditi (groditi) E<lt>groditi@cpan.orgE<gt>
=head1 LICENSE
#!perl
use strict;
use lib 't/lib';
-use Test::More tests => 12;
+use Test::More tests => 13;
#1,2
require_ok("MooseX::Adopt::Class::Accessor::Fast");
ok(TestAdoptCAF->meta->find_attribute_by_name($_), "attribute $_ created")
for qw(foo bar baz);
+{
+ my $ok = eval {
+ local $SIG{__WARN__} = sub {
+ die "Warning generated when new was called with no arguments: " .
+ join("; ", @_);
+ };
+ TestAdoptCAF->new(());
+ };
+ ok( ref($ok), ref($ok) ? "no warnings when instantiating object" : $@);
+}
#7-9
my $t = TestAdoptCAF->new(foo => 100, bar => 200, groditi => 300);
is($t->{foo}, 100, '$self->{foo} set');
#10-12
my $u = TestAdoptCAF->new({foo => 100, bar => 200, groditi => 300});
-is($t->{foo}, 100, '$self->{foo} set');
-is($t->{bar}, 200, '$self->{bar} set');
-is($t->{groditi}, 300, '$self->{groditi} set');
+is($u->{foo}, 100, '$self->{foo} set');
+is($u->{bar}, 200, '$self->{bar} set');
+is($u->{groditi}, 300, '$self->{groditi} set');
+