Some kind of fix or workaround for phaylon's parameterized role bug in MXD.
[p5sagit/Devel-Declare.git] / t / simple.t
index 7dfc49c..edc09d3 100644 (file)
@@ -3,16 +3,34 @@ use warnings;
 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;
 }
 
-use Devel::Declare 'method';
+sub handle_method {
+  my ($usepack, $use, $inpack, $name) = @_;
+  return sub (&) { ($usepack, $name, $inpack, $_[0]); };
+}
+
+use Devel::Declare 'method' => \&handle_method;
+
+my ($args1, $args2);
 
 method bar {
-  my $str = join(', ', @_);
-  is($str, 'main, baz, quux', 'Method args ok');
+  $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');
+