[Bps-public-commit] r12633 - in pie/branches/named-params: lib/PIE
jesse at bestpractical.com
jesse at bestpractical.com
Fri May 23 04:54:18 EDT 2008
Author: jesse
Date: Fri May 23 04:54:17 2008
New Revision: 12633
Modified:
pie/branches/named-params/lib/PIE/Evaluator.pm
pie/branches/named-params/lib/PIE/Expression.pm
pie/branches/named-params/t/01basic.t
pie/branches/named-params/t/named-params.t
Log:
closer! almost all tests pass
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 04:54:17 2008
@@ -25,6 +25,7 @@
my $self = shift;
my $expression = shift;
eval {
+ Carp::confess unless ($expression);
my $ret = $expression->evaluate($self);
$self->result->value($ret);
$self->result->success(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 04:54:17 2008
@@ -122,8 +122,8 @@
sub evaluate {
- my ($self, $eval, $args) = validate_pos(@_, { isa => 'PIE::Expression'}, { isa => 'PIE::Evaluator'}, 1);
- return $args->{value};
+ my ($self, $eval) = validate_pos(@_, { isa => 'PIE::Expression'}, { isa => 'PIE::Evaluator'});
+ return $self->args->{value};
}
@@ -138,7 +138,7 @@
sub evaluate {
- my ($self, $eval, $args) = validate_pos(@_, { isa => 'PIE::Expression'}, { isa => 'PIE::Evaluator'});
+ my ($self, $eval) = 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/t/01basic.t
==============================================================================
--- pie/branches/named-params/t/01basic.t (original)
+++ pie/branches/named-params/t/01basic.t Fri May 23 04:54:17 2008
@@ -19,21 +19,21 @@
ok( !$eval2->result->value );
ok( $eval2->result->success );
-my $if_true = PIE::Expression::IfThen->new(
+my $if_true = PIE::Expression::IfThen->new( args => {
condition => PIE::Expression::True->new(),
if_true => PIE::Expression::True->new(),
- if_false => PIE::Expression::False->new()
+ if_false => PIE::Expression::False->new()}
);
my $eval3 = PIE::Evaluator->new();
ok( $eval3->run($if_true) );
ok( $eval3->result->value );
-ok( $eval2->result->success );
+ok( $eval3->result->success, $eval3->result->error );
-my $if_false = PIE::Expression::IfThen->new(
+my $if_false = PIE::Expression::IfThen->new( args => {
condition => PIE::Expression::False->new(),
if_true => PIE::Expression::True->new(),
- if_false => PIE::Expression::False->new()
+ if_false => PIE::Expression::False->new()}
);
my $eval4 = PIE::Evaluator->new();
@@ -87,7 +87,7 @@
}
);
-ok( $eval9->result->success );
+ok( $eval9->result->success, $eval9->result->error );
is( $eval9->result->value, 1 );
my $builder = PIE::Builder->new();
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 04:54:17 2008
@@ -6,9 +6,9 @@
use_ok('PIE::FunctionArgument');
my $MATCH_REGEX = PIE::Lambda::Native->new(
body => sub {
- my %args = (@_);
- my $arg = $args{'tested-string'};
- my $regexp = $args{'regexp'};
+ my $args = shift;
+ my $arg = $args->{'tested-string'};
+ my $regexp = $args->{'regexp'};
return $arg =~ m/$regexp/;
},
More information about the Bps-public-commit
mailing list