[Bps-public-commit] r12630 - in pie/branches/named-params: lib/PIE t
jesse at bestpractical.com
jesse at bestpractical.com
Fri May 23 03:01:58 EDT 2008
Author: jesse
Date: Fri May 23 03:01:58 2008
New Revision: 12630
Modified:
pie/branches/named-params/lib/PIE/Evaluatable.pm
pie/branches/named-params/lib/PIE/Evaluator.pm
pie/branches/named-params/lib/PIE/Expression.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
Log:
* got rid of _named_args now that we no longer maintain two variants
Modified: pie/branches/named-params/lib/PIE/Evaluatable.pm
==============================================================================
--- pie/branches/named-params/lib/PIE/Evaluatable.pm (original)
+++ pie/branches/named-params/lib/PIE/Evaluatable.pm Fri May 23 03:01:58 2008
@@ -2,6 +2,6 @@
package PIE::Evaluatable;
use Moose::Role;
-requires 'evaluate_named_args';
+requires 'evaluate';
1;
Modified: pie/branches/named-params/lib/PIE/Evaluator.pm
==============================================================================
--- pie/branches/named-params/lib/PIE/Evaluator.pm (original)
+++ pie/branches/named-params/lib/PIE/Evaluator.pm Fri May 23 03:01:58 2008
@@ -25,7 +25,7 @@
my $self = shift;
my $expression = shift;
eval {
- my $ret = $expression->evaluate_named_args($self);
+ my $ret = $expression->evaluate($self);
$self->result->value($ret);
$self->result->success(1);
};
@@ -47,10 +47,10 @@
}
-sub apply_script_named_args {
+sub apply_script {
# self, a lambda, any number of positional params. (to be replaced with a params object?)
my ($self, $lambda, $args) = validate_pos(@_, { isa => 'PIE::Evaluator'}, { ISA => 'PIE::Lambda'}, { ISA => "HASHREF" } ) ;
- $lambda->evaluate_named_args($self, $args);
+ $lambda->evaluate($self, $args);
}
1;
Modified: pie/branches/named-params/lib/PIE/Expression.pm
==============================================================================
--- pie/branches/named-params/lib/PIE/Expression.pm (original)
+++ pie/branches/named-params/lib/PIE/Expression.pm Fri May 23 03:01:58 2008
@@ -30,10 +30,10 @@
-sub evaluate_named_args {
+sub evaluate {
my ($self, $ev) = @_;
my $lambda = $ev->resolve_name($self->name);
- return $ev->apply_script_named_args( $lambda, $self->args );
+ return $ev->apply_script( $lambda, $self->args );
}
@@ -41,15 +41,15 @@
use Moose;
extends 'PIE::Expression';
-sub evaluate_named_args {1}
+sub evaluate {1}
package PIE::Expression::False;
use Moose;
extends 'PIE::Expression::True';
-sub evaluate_named_args {
+sub evaluate {
my $self = shift;
- return ! $self->SUPER::evaluate_named_args();
+ return ! $self->SUPER::evaluate();
}
@@ -65,7 +65,7 @@
);
-sub evaluate_named_args {
+sub evaluate {
my $self = shift;
}
@@ -94,7 +94,7 @@
}
);
-sub evaluate_named_args {
+sub evaluate {
my ($self, $evaluator) = validate_pos(@_, { isa => 'PIE::Expression'}, { isa => 'PIE::Evaluator'}, );
@@ -121,7 +121,7 @@
default => sub { { value => PIE::FunctionArgument->new( name => 'value', type => 'Str')}});
-sub evaluate_named_args {
+sub evaluate {
my ($self, $eval, $args) = validate_pos(@_, { isa => 'PIE::Expression'}, { isa => 'PIE::Evaluator'}, 1);
return $args->{value};
@@ -137,7 +137,7 @@
default => sub { { symbol => PIE::FunctionArgument->new( name => 'symbol', type => 'Str')}});
-sub evaluate_named_args {
+sub evaluate {
my ($self, $eval, $args) = validate_pos(@_, { isa => 'PIE::Expression'}, { isa => 'PIE::Evaluator'});
my $result = $eval->get_named($self->args->{'symbol'});
return $result->isa('PIE::Expression') ? $eval->run($result) : $result; # XXX: figure out evaluation order here
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:01:58 2008
@@ -17,7 +17,7 @@
isa => 'HashRef[PIE::FunctionArgument]');
-sub check_named_args {
+sub check {
my $self = shift;
my $passed = shift; #reference to hash of provided args
my $args = $self->args; # expected args
@@ -45,10 +45,10 @@
-sub evaluate_named_args {
+sub evaluate {
my ($self, $evaluator, $args) = @_;
- my ($missing, $unwanted) = $self->check_named_args($args);
+ my ($missing, $unwanted) = $self->check($args);
return undef if (keys %$missing || keys %$unwanted);
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:01:58 2008
@@ -10,11 +10,11 @@
-sub evaluate_named_args {
+sub evaluate {
my ($self, $evaluator, $args) = @_;
- my ($missing, $unwanted) = $self->check_named_args($args);
+ my ($missing, $unwanted) = $self->check($args);
die "Something went wrong with your args" if (keys %$missing || keys %$unwanted);
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:01:58 2008
@@ -50,14 +50,14 @@
);
my $eval7 = PIE::Evaluator->new();
-$eval7->apply_script_named_args($script, {} );
+$eval7->apply_script($script, {} );
ok( $eval7->result->success );
ok( $eval7->result->value );
my $script2 = PIE::Lambda->new( nodes => [$if_true] );
my $eval8 = PIE::Evaluator->new();
-$eval8->apply_script_named_args($script2, {});
+$eval8->apply_script($script2, {});
ok( $eval8->result->success );
ok( $eval8->result->value );
@@ -80,7 +80,7 @@
);
$eval9->set_named( 'match-regexp' => $MATCH_REGEX );
-$eval9->apply_script_named_args(
+$eval9->apply_script(
$MATCH_REGEX,
{ 'tested-string' => PIE::Expression::String->new( value => 'I do love software' ),
'regex' => PIE::Expression::String->new( value => 'software' )
@@ -94,7 +94,7 @@
my $eval10 = PIE::Evaluator->new();
$eval10->set_named( 'match-regexp' => $MATCH_REGEX );
-$eval10->apply_script_named_args(
+$eval10->apply_script(
$builder->defun(
ops => [
{ name => 'IfThen',
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:01:58 2008
@@ -33,7 +33,7 @@
my $name = shift;
for ( @{ $self->rules || [] } ) {
- $self->evaluator->apply_script_named_args( $_,
+ $self->evaluator->apply_script( $_,
{ name => PIE::Expression::String->new( value => $name ) } );
last unless ( $self->evaluator->result->success );
$name = $self->evaluator->result->value;
@@ -75,7 +75,7 @@
);
$hello->rules( [$script] );
-can_ok( $hello->rules->[0], 'evaluate_named_args' );
+can_ok( $hello->rules->[0], 'evaluate' );
is( $hello->run('jesse'), 'Hello fred' );
my $script2 = $builder->defun(
@@ -84,7 +84,7 @@
{ name => PIE::FunctionArgument->new( name => 'name', type => 'Str' ) }
);
$hello->rules( [$script2] );
-can_ok( $hello->rules->[0], 'evaluate_named_args' );
+can_ok( $hello->rules->[0], 'evaluate' );
is( $hello->run('jesse'), 'Hello fred' );
@@ -96,12 +96,12 @@
$hello->rules( [ $script3, $script4 ] );
-can_ok( $hello->rules->[0], 'evaluate_named_args' );
-can_ok( $hello->rules->[1], 'evaluate_named_args' );
+can_ok( $hello->rules->[0], 'evaluate' );
+can_ok( $hello->rules->[1], 'evaluate' );
is( $hello->run('jesse'), 'Hello fred' );
$hello->rules( [ $hello->evaluator->get_named('make-whoever') ] );
-can_ok( $hello->rules->[0], 'evaluate_named_args' );
+can_ok( $hello->rules->[0], 'evaluate' );
is( $hello->run('jesse'), 'Hello jesse' );
1;
More information about the Bps-public-commit
mailing list