From: Dave Rolsky Date: Tue, 3 Aug 2010 10:11:34 +0000 (+0200) Subject: Don't swallow errors from BUILDARGS X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=eb959c492a30b5e56697be88629fc10b6c17477f;p=gitmo%2Fmoose-presentations.git Don't swallow errors from BUILDARGS The test code bailed out if BUILDARGS failed, but didn't show the error, which makes debugging much harder. --- diff --git a/moose-class/exercises/t/lib/MooseClass/Tests.pm b/moose-class/exercises/t/lib/MooseClass/Tests.pm index b7dd57f..4fdf477 100644 --- a/moose-class/exercises/t/lib/MooseClass/Tests.pm +++ b/moose-class/exercises/t/lib/MooseClass/Tests.pm @@ -519,10 +519,18 @@ sub person01 { ); $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' + + if ( my $e = $@ ) { + diag( + "Calling Person->new() with an array reference threw an error:\n$e" + ); + BAIL_OUT( + 'You must implement Person->BUILDARGS correctly in order to continue these tests' ); + } + else { + ok( 1, 'Person->new() can accept an array reference as an argument' ); + } is( $person->first_name, 'Lisa', 'set first_name from two-arg arrayref' ); is( $person->last_name, 'Smith', 'set last_name from two-arg arrayref' );