From: Guillermo Roditi Date: Tue, 29 Jul 2008 18:52:42 +0000 (+0000) Subject: litle changes, almost ready to ship X-Git-Tag: 0.00400~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7ed9430a4dd41884330a3b64a2b5457755eef9b2;p=gitmo%2FMooseX-Emulate-Class-Accessor-Fast.git litle changes, almost ready to ship --- diff --git a/lib/MooseX/Emulate/Class/Accessor/Fast.pm b/lib/MooseX/Emulate/Class/Accessor/Fast.pm index 64955d6..55a7015 100644 --- a/lib/MooseX/Emulate/Class/Accessor/Fast.pm +++ b/lib/MooseX/Emulate/Class/Accessor/Fast.pm @@ -72,7 +72,7 @@ sub BUILD { my %args; if (scalar @_ == 1 && defined $_[0] && ref($_[0]) eq 'HASH') { %args = %{$_[0]}; - } else { + } elsif( scalar(@_) ) { %args = @_; } my @extra = grep { !exists($self->{$_}) } keys %args; @@ -230,7 +230,7 @@ L, L =head1 AUTHOR -Guillermo Roditi (groditi) +Guillermo Roditi (groditi) Egroditi@cpan.orgE =head1 LICENSE diff --git a/t/adopt.t b/t/adopt.t index c7900a9..b9b931f 100644 --- a/t/adopt.t +++ b/t/adopt.t @@ -1,7 +1,7 @@ #!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"); @@ -12,6 +12,16 @@ ok(TestAdoptCAF->can('meta'), 'Adopt seems to work'); 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'); @@ -20,6 +30,7 @@ is($t->{groditi}, 300, '$self->{groditi} 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'); +