[Bps-public-commit] r13891 - in Lorzy/trunk: . lib

sartak at bestpractical.com sartak at bestpractical.com
Tue Jul 8 16:55:46 EDT 2008


Author: sartak
Date: Tue Jul  8 16:55:46 2008
New Revision: 13891

Added:
   Lorzy/trunk/t/evaluate.t
Modified:
   Lorzy/trunk/   (props changed)
   Lorzy/trunk/lib/Lorzy.pm

Log:
 r63885 at onn:  sartak | 2008-07-08 16:55:42 -0400
 Add Lorzy->evaluate which takes care of creating a thunk and applying it


Modified: Lorzy/trunk/lib/Lorzy.pm
==============================================================================
--- Lorzy/trunk/lib/Lorzy.pm	(original)
+++ Lorzy/trunk/lib/Lorzy.pm	Tue Jul  8 16:55:46 2008
@@ -20,6 +20,17 @@
 use Lorzy::Evaluator;
 use Lorzy::Lambda::Native;
 
+sub evaluate {
+    my $self    = shift;
+    my $tree    = shift;
+    my $builder = Lorzy::Builder->new;
+    my $eval    = Lorzy::Evaluator->new;
+
+    my $script = $builder->defun(ops => $tree, signature => {});
+    $eval->apply_script($script, {});
+    return $eval->result->value;
+}
+
 our $VERSION = 0;
 
 1;

Added: Lorzy/trunk/t/evaluate.t
==============================================================================
--- (empty file)
+++ Lorzy/trunk/t/evaluate.t	Tue Jul  8 16:55:46 2008
@@ -0,0 +1,19 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+
+use Test::More tests => 2;
+
+use_ok('Lorzy');
+
+my $result = Lorzy->evaluate([{
+    name => 'IfThen',
+    args => {
+        if_true   => 'yes!',
+        if_false  => 'NO!',
+        condition => 1,
+    },
+}]);
+
+is($result, 'yes!');
+



More information about the Bps-public-commit mailing list