X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fsimple.t;h=edc09d3ac197b88e14acc55733f85dcaf263c0a0;hb=13edc71b58c5f74174e0f97f5345ee0514ef8230;hp=266bb8b0af6c8add8e50fa2be73bd6f151397e46;hpb=94caac6e9e3af7e002f7eef2bed2e2bf2bb6d2a8;p=p5sagit%2FDevel-Declare.git diff --git a/t/simple.t b/t/simple.t index 266bb8b..edc09d3 100644 --- a/t/simple.t +++ b/t/simple.t @@ -1,23 +1,36 @@ use strict; use warnings; - -print "1..1\n"; +use Test::More 'no_plan'; sub method { - my ($pack, $name, $sub) = @_; + my ($usepack, $name, $inpack, $sub) = @_; no strict 'refs'; - *{"${pack}::${name}"} = $sub; + *{"${inpack}::${name}"} = $sub; +} + +sub handle_method { + my ($usepack, $use, $inpack, $name) = @_; + return sub (&) { ($usepack, $name, $inpack, $_[0]); }; } -use Devel::Declare 'method'; +use Devel::Declare 'method' => \&handle_method; + +my ($args1, $args2); method bar { - my $str = join(', ', @_); - if ($str eq 'main, baz, quux') { - print "ok 1\n"; - } else { - print "not ok 1\n"; - } + $args1 = join(', ', @_); }; -__PACKAGE__->bar(qw(baz quux)); +method # blather + baz + # whee +{ # fweet + $args2 = join(', ', @_); +}; + +__PACKAGE__->bar(qw(1 2)); +__PACKAGE__->baz(qw(3 4)); + +is($args1, 'main, 1, 2', 'Method bar args ok'); +is($args2, 'main, 3, 4', 'Method baz args ok'); +