From: Dave Rolsky Date: Thu, 24 Jun 2010 14:37:47 +0000 (-0400) Subject: Add a test that Person->new() accepts an array ref X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d047d1d4619aa3877580a69f5cdc02184b04c263;p=gitmo%2Fmoose-presentations.git Add a test that Person->new() accepts an array ref If the student had not implemented BUILDARGS, the resulting error message was not very helpful. --- diff --git a/moose-class/exercises/t/lib/MooseClass/Tests.pm b/moose-class/exercises/t/lib/MooseClass/Tests.pm index 0015192..dd0b2ef 100644 --- a/moose-class/exercises/t/lib/MooseClass/Tests.pm +++ b/moose-class/exercises/t/lib/MooseClass/Tests.pm @@ -376,7 +376,12 @@ sub person01 { is( $person->full_name, 'Bilbo Baggins', 'full_name() is correctly implemented' ); - $person = Person->new( [ qw( Lisa Smith ) ] ); + $person = eval { Person->new( [ qw( Lisa Smith ) ] ) }; + ok( !$@, 'Person->new() can accept an array reference as an argument' ) + or BAIL_OUT( + 'You must implement Person->BUILDARGS in order to continue these tests' + ); + is( $person->first_name, 'Lisa', 'set first_name from two-arg arrayref' ); is( $person->last_name, 'Smith', 'set last_name from two-arg arrayref' );