make test less noisy
[p5sagit/Devel-Declare.git] / lib / Devel / Declare.pm
index 8d0f5a5..2e1d443 100644 (file)
@@ -4,7 +4,7 @@ use strict;
 use warnings;
 use 5.008001;
 
-our $VERSION = 0.001000;
+our $VERSION = '0.001004';
 
 # mirrored in Declare.xs as DD_HANDLE_*
 
@@ -120,7 +120,11 @@ sub build_sub_installer {
     package ${pack};
     my \$body;
     sub ${name} (${proto}) :lvalue {\n"
-    .'my $ret = $body->(@_);
+    .'  if (wantarray) {
+        my @ret = $body->(@_);
+        return @ret;
+      }
+      my $ret = $body->(@_);
       return $ret;
     };
     sub { ($body) = @_; };';
@@ -142,17 +146,20 @@ sub setup_declarators {
     $sub_proto =~ s/;//; $sub_proto = ';'.$sub_proto;
     #my $installer = $class->build_sub_installer($pack, $name, $proto);
     my $installer = $class->build_sub_installer($pack, $name, '@');
-    my $proto_maker = eval q!
-      sub {
-        my $body = shift;
-        sub (!.$sub_proto.q!) {
-          $body->(@_);
-        };
-      };
-    !;
     $installer->(sub :lvalue {
-      if (@_) { warn @_;
-        $run->(undef, undef, @_);
+#{ no warnings 'uninitialized'; warn 'INST: '.join(', ', @_)."\n"; }
+      if (@_) {
+        if (ref $_[0] eq 'HASH') {
+          shift;
+          if (wantarray) {
+            my @ret = $run->(undef, undef, @_);
+            return @ret;
+          }
+          my $r = $run->(undef, undef, @_);
+          return $r;
+        } else {
+          return @_[1..$#_];
+        }
       }
       return my $sv;
     });
@@ -161,16 +168,19 @@ sub setup_declarators {
       sub {
         my ($usepack, $use, $inpack, $name, $proto) = @_;
         my $extra_code = $compile->($name, $proto);
-        my $main_handler = $proto_maker->(sub {
-          $run->($name, $proto, @_);
-        });
+        my $shift_hashref = defined(wantarray);
+        my $main_handler = sub { shift if $shift_hashref;
+          ("DONE", $run->($name, $proto, @_));
+        };
         my ($name_h, $XX);
         if (defined $proto) {
           $name_h = sub :lvalue { return my $sv; };
           $XX = $main_handler;
-        } else {
+        } elsif (defined $name && length $name) {
           $name_h = $main_handler;
         }
+        $extra_code ||= '';
+        $extra_code = '}, sub {'.$extra_code;
         return ($name_h, $XX, $extra_code);
       }
     ];
@@ -195,6 +205,10 @@ Devel::Declare -
 
 =head1 SYNOPSIS
 
+Look at the tests. This module is currently on CPAN to ease smoke testing
+and allow early adopters who've been involved in the design to experiment
+with it.
+
 =head1 DESCRIPTION
 
 =head2 import
@@ -226,9 +240,9 @@ calls.
 
 =head1 AUTHOR
 
-Matt S Trout - <mst@shadowcatsystems.co.uk>
+Matt S Trout - <mst@shadowcat.co.uk>
 
-Company: http://www.shadowcatsystems.co.uk/
+Company: http://www.shadowcat.co.uk/
 Blog: http://chainsawblues.vox.com/
 
 =head1 LICENSE