From: Dave Rolsky Date: Mon, 7 Sep 2009 16:30:03 +0000 (-0500) Subject: Test with_meta prototype handling separately from other bits of testing X-Git-Tag: 0.89_02~32^2~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6cdf1d652c8076c547e7f8e81e90a474d125a60c;p=gitmo%2FMoose.git Test with_meta prototype handling separately from other bits of testing --- diff --git a/t/050_metaclasses/024_moose_exporter_groups.t b/t/050_metaclasses/024_moose_exporter_groups.t index 7abfdae..7b831a9 100755 --- a/t/050_metaclasses/024_moose_exporter_groups.t +++ b/t/050_metaclasses/024_moose_exporter_groups.t @@ -14,7 +14,7 @@ use Test::Exception; Moose::Exporter->setup_import_methods( also => ['Moose'], - with_meta => ['with_meta1'], + with_meta => [ 'with_meta1', 'with_meta2' ], with_caller => ['default_export1'], as_is => ['default_export2'], groups => { @@ -26,9 +26,12 @@ use Test::Exception; sub default_export1 {1} sub default_export2 {2} - sub with_meta1 (&) { - my ( $meta, $code ) = @_; - return $meta; + sub with_meta1 { + return @_; + } + + sub with_meta2 (&) { + return @_; } } @@ -43,13 +46,13 @@ use Test::Exception; ::can_ok( __PACKAGE__, 'default_export2' ); ::can_ok( __PACKAGE__, 'has' ); - my $meta; - eval q/$meta = with_meta1 { return 'coderef'; }/; - ::is( $@, '', 'calling with_meta1 with prototype is not an error' ); + my ( $meta, $arg1 ) = with_meta1(42); ::isa_ok( $meta, 'Moose::Meta::Class', 'with_meta first argument' ); + ::is( $arg1, 42, 'with_meta1 returns argument it was passed' ); + ::is( - prototype( __PACKAGE__->can('with_meta1') ), - prototype( ExGroups1->can('with_meta1') ), + prototype( __PACKAGE__->can('with_meta2') ), + prototype( ExGroups1->can('with_meta2') ), 'using correct prototype on with_meta function' );