X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fbuildargs.t;fp=t%2Fbuildargs.t;h=f1e4c2701b093096349bc07fb198589e682a4715;hb=0123201bb23a0510ae9ad5817a5138fc2eb0cb3e;hp=90cd9f8f96114814a65bbf7edd3b72130d93b446;hpb=b512e801795ecd9183b2f658e2b0b49962f45118;p=gitmo%2FMoo.git diff --git a/t/buildargs.t b/t/buildargs.t index 90cd9f8..f1e4c27 100644 --- a/t/buildargs.t +++ b/t/buildargs.t @@ -13,6 +13,31 @@ use Test::More; extends qw(Qux); } + +{ + package t::non_moo; + + sub new { + my ($class, $arg) = @_; + bless { attr => $arg }, $class; + } + + sub attr { shift->{attr} } + + package t::ext_non_moo::with_attr; + use Moo; + extends qw( t::non_moo ); + + has 'attr2' => ( is => 'ro' ); + + sub BUILDARGS { + my ( $class, @args ) = @_; + shift @args if @args % 2 == 1; + return { @args }; + } +} + + { package Foo; use Moo; @@ -97,5 +122,16 @@ foreach my $class (qw(Qux Quux)) { ); } +my $non_moo = t::non_moo->new( 'bar' ); +my $ext_non_moo = t::ext_non_moo::with_attr->new( 'bar', attr2 => 'baz' ); + +is $non_moo->attr, 'bar', + "non-moo accepts params"; +is $ext_non_moo->attr, 'bar', + "extended non-moo passes params"; +is $ext_non_moo->attr2, 'baz', + "extended non-moo has own attributes"; + + done_testing;