From: Dave Rolsky Date: Fri, 17 Sep 2010 20:41:15 +0000 (-0500) Subject: Add tests for natatime_curried X-Git-Tag: 1.15~148 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a098a4a3fa7da540ca8235cf5ab27e37a4f35d70;hp=a7821be5fbdedff67afce753d73c580ae5ada592;p=gitmo%2FMoose.git Add tests for natatime_curried --- diff --git a/t/070_native_traits/202_trait_array.t b/t/070_native_traits/202_trait_array.t index 46aa9bc..490aa51 100644 --- a/t/070_native_traits/202_trait_array.t +++ b/t/070_native_traits/202_trait_array.t @@ -606,6 +606,31 @@ sub run_tests { qr/The second argument must be a code reference/, 'throws an error with when passing a non code ref to natatime'; + my $it = $obj->natatime_curried(); + my @nat; + while ( my @v = $it->() ) { + push @nat, \@v; + } + + is_deeply( + [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ], + \@nat, + 'natatime_curried returns expected iterator' + ); + + @nat = (); + $obj->natatime_curried( sub { push @nat, [@_] } ); + + is_deeply( + [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ], + \@nat, + 'natatime_curried with function returns expected value' + ); + + throws_ok { $obj->natatime_curried( {} ) } + qr/The second argument must be a code reference/, + 'throws an error with when passing a non code ref to natatime_curried'; + if ( $class->meta->get_attribute('_values')->is_lazy ) { my $obj = $class->new; @@ -613,8 +638,10 @@ sub run_tests { $obj->_clear_values; - is_deeply( [ $obj->elements ], [ 42, 84], - 'elements contains default with lazy init' ); + is_deeply( + [ $obj->elements ], [ 42, 84 ], + 'elements contains default with lazy init' + ); $obj->_clear_values;