[Bps-public-commit] r12631 - in pie/branches/named-params: lib/PIE t

jesse at bestpractical.com jesse at bestpractical.com
Fri May 23 03:17:43 EDT 2008


Author: jesse
Date: Fri May 23 03:17:42 2008
New Revision: 12631

Modified:
   pie/branches/named-params/lib/PIE/Builder.pm
   pie/branches/named-params/lib/PIE/Lambda.pm
   pie/branches/named-params/lib/PIE/Lambda/Native.pm
   pie/branches/named-params/t/01basic.t
   pie/branches/named-params/t/hello_world.t
   pie/branches/named-params/t/named-params.t

Log:
* 'args' -> 'signature' (but only when we meant signature)

Modified: pie/branches/named-params/lib/PIE/Builder.pm
==============================================================================
--- pie/branches/named-params/lib/PIE/Builder.pm	(original)
+++ pie/branches/named-params/lib/PIE/Builder.pm	Fri May 23 03:17:42 2008
@@ -35,8 +35,8 @@
 
 sub defun {
     my $self = shift;
-    my %args = validate( @_, { ops => 1, args => 1 });
-    return PIE::Lambda->new( nodes => [map { $self->build_expression($_) } @{$args{ops}} ], args => $args{args} );
+    my %args = validate( @_, { ops => 1, signature => 1 });
+    return PIE::Lambda->new( nodes => [map { $self->build_expression($_) } @{$args{ops}} ], signature => $args{signature} );
 }
 
 1;

Modified: pie/branches/named-params/lib/PIE/Lambda.pm
==============================================================================
--- pie/branches/named-params/lib/PIE/Lambda.pm	(original)
+++ pie/branches/named-params/lib/PIE/Lambda.pm	Fri May 23 03:17:42 2008
@@ -12,7 +12,7 @@
     is => 'rw',
     isa => 'ArrayRef[Str]');
 
-has args => (
+has signature => (
     is => 'rw',
     isa => 'HashRef[PIE::FunctionArgument]');
 
@@ -20,7 +20,7 @@
 sub check {
     my $self = shift;
     my $passed = shift; #reference to hash of provided args
-    my $args = $self->args; # expected args
+    my $args = $self->signature; # expected args
     
     
     my $missing = {};
@@ -52,7 +52,7 @@
     
     return undef if (keys %$missing || keys %$unwanted);
     
-    my $arguments = $self->args;
+    my $arguments = $self->signature;
     for (sort keys %$arguments) {
         $evaluator->set_named( $_ => $arguments->{$_} );
     }

Modified: pie/branches/named-params/lib/PIE/Lambda/Native.pm
==============================================================================
--- pie/branches/named-params/lib/PIE/Lambda/Native.pm	(original)
+++ pie/branches/named-params/lib/PIE/Lambda/Native.pm	Fri May 23 03:17:42 2008
@@ -16,10 +16,10 @@
     
     my ($missing, $unwanted)  = $self->check($args);
     
-
-    die "Something went wrong with your args" if (keys %$missing || keys %$unwanted);
+    use YAML;
+    die "Something went wrong with your args". YAML::Dump($missing, $unwanted) if (keys %$missing || keys %$unwanted);
     
-    my $arguments = $self->args;
+    my $arguments = $self->signature;
     my %args = map { $evaluator->run($args->{$_}); ( $_ => $evaluator->result->value ) } keys %$args;
     # XXX TODO - these are eagerly evaluated at this point. we probably want to lazy {} them with Scalar::Defer
     my $r = $self->body->(\%args);    

Modified: pie/branches/named-params/t/01basic.t
==============================================================================
--- pie/branches/named-params/t/01basic.t	(original)
+++ pie/branches/named-params/t/01basic.t	Fri May 23 03:17:42 2008
@@ -72,7 +72,7 @@
         return ($arg =~ m/$regexp/ )? 1 : 0;
     },
 
-    args => {
+    signature => {
         'tested-string' => PIE::FunctionArgument->new( name => 'tested-string' => type => 'Str'),
         'regex' => PIE::FunctionArgument->new( name => 'regex', type => 'Str' )
         }
@@ -111,7 +111,7 @@
                 }
             }
         ],
-        args => {},
+        signature => {},
     ),
     {},
 );

Modified: pie/branches/named-params/t/hello_world.t
==============================================================================
--- pie/branches/named-params/t/hello_world.t	(original)
+++ pie/branches/named-params/t/hello_world.t	Fri May 23 03:17:42 2008
@@ -59,7 +59,7 @@
     'make-whoever',
     PIE::Lambda::Native->new(
         body => sub { my $args = shift; return $args->{'name'} },
-        args => {
+        signature => {
             name => PIE::FunctionArgument->new( name => 'name', type => 'Str' )
             }
 
@@ -70,7 +70,7 @@
 my $builder = PIE::Builder->new();
 my $script  = $builder->defun(
     ops => $tree,
-    args =>
+    signature =>
         { name => PIE::FunctionArgument->new( name => 'name', type => 'Str' ) }
 );
 
@@ -80,7 +80,7 @@
 
 my $script2 = $builder->defun(
     ops =>[ { name => 'make-bob' }, { name => 'make-fred' } ] ,
- args =>
+    signature =>
         { name => PIE::FunctionArgument->new( name => 'name', type => 'Str' ) }
 );
 $hello->rules( [$script2] );
@@ -88,10 +88,10 @@
 
 is( $hello->run('jesse'), 'Hello fred' );
 
-my $script3 = $builder->defun( ops => [ { name => 'make-bob' } ], args =>
+my $script3 = $builder->defun( ops => [ { name => 'make-bob' } ], signature =>
     { name => PIE::FunctionArgument->new( name => 'name', type => 'Str' ) } );
 my $script4 = $builder->defun ( ops => [ { name => 'make-fred' } ],
-args =>
+signature =>
     { name => PIE::FunctionArgument->new( name => 'name', type => 'Str' ) } );
 
 $hello->rules( [ $script3, $script4 ] );

Modified: pie/branches/named-params/t/named-params.t
==============================================================================
--- pie/branches/named-params/t/named-params.t	(original)
+++ pie/branches/named-params/t/named-params.t	Fri May 23 03:17:42 2008
@@ -13,7 +13,7 @@
         return $arg =~ m/$regexp/;
     },
 
-    args => {
+    signature => {
            'tested-string' =>  PIE::FunctionArgument->new( name =>              'tested-string' =>  type => 'Str' ),
            'regex'=>  PIE::FunctionArgument->new( name =>      'regex', type => 'Str' )
     }



More information about the Bps-public-commit mailing list