stop using & prototypes at all
[p5sagit/Devel-Declare.git] / t / sugar.t
index 4ca64e6..8b51917 100644 (file)
--- a/t/sugar.t
+++ b/t/sugar.t
@@ -6,11 +6,15 @@ BEGIN {
     'DeclareTest', 'method', DECLARE_PACKAGE | DECLARE_PROTO,
     sub {
       my ($name, $proto) = @_;
+no warnings 'uninitialized';
+warn "NP: ".join(', ', @_)."\n";
       return 'my $self = shift;' unless defined $proto && $proto ne '@_';
       return 'my ($self'.(length $proto ? ", ${proto}" : "").') = @_;';
     },
     sub {
-      my ($name, $proto, $sub) = @_;
+      my ($name, $proto, $sub, @rest) = @_;
+no warnings 'uninitialized';
+warn "NPS: ".join(', ', @_)."\n";
       if (defined $name && length $name) {
         unless ($name =~ /::/) {
           $name = "DeclareTest::${name}";
@@ -18,13 +22,13 @@ BEGIN {
         no strict 'refs';
         *{$name} = $sub;
       }
-      return $sub;
+      return wantarray ? ($sub, @rest) : $sub;
     }
   );
 
 }
 
-my ($test_method1, $test_method2);
+my ($test_method1, $test_method2, @test_list);
 
 {
   package DeclareTest;
@@ -54,6 +58,8 @@ my ($test_method1, $test_method2);
     return join(', ', ref $self, $what);
   };
 
+  @test_list = method { 1 }, sub { 2 }, method () { 3 }, sub { 4 };
+
 }
 
 use Test::More 'no_plan';
@@ -75,3 +81,5 @@ is($o->bar, 'DeclareTest2: bar', 'absolute method declaration ok');
 is($o->$test_method1('no', 'yes'), 'value, yes', 'anon method with @_ ok');
 
 is($o->$test_method2('this'), 'DeclareTest2, this', 'anon method with proto ok');
+
+warn map { $_->() } @test_list;