From ada8802640aa232d34b1fe2793b9f52cd62b41f1 Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Mon, 16 Nov 2009 06:01:33 +0000 Subject: Fixed parsing of comments. Added functions to read scripts and more test cases. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@880600 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/sca/modules/eval/eval-test.cpp | 45 +++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-) (limited to 'cpp/sca/modules/eval/eval-test.cpp') diff --git a/cpp/sca/modules/eval/eval-test.cpp b/cpp/sca/modules/eval/eval-test.cpp index 7d92c79eba..984b17b26d 100644 --- a/cpp/sca/modules/eval/eval-test.cpp +++ b/cpp/sca/modules/eval/eval-test.cpp @@ -167,11 +167,50 @@ bool testEvalExpr() { return true; } +bool testEvalRun() { + evalDriverRun(std::cin, std::cout); + return true; +} + +const value mult(const list& args) { + const double x = car(args); + const double y = cadr(args); + return x * y; +} + +const std::string testReturnLambda( + "(define (testReturnLambda) * )"); + +const std::string testCallLambda( + "(define (testCallLambda l x y) (l x y))"); + +bool testEvalLambda() { + gc_pool pool; + Env env = setupEnvironment(pool); + + const value trl = mklist("testReturnLambda"); + std::istringstream trlis(testReturnLambda); + const value trlv = evalScript(trl, trlis, env, pool); + + std::istringstream tclis(testCallLambda); + const value tcl = cons("testCallLambda", quotedParameters(mklist(trlv, 2, 3))); + const value tclv = evalScript(tcl, tclis, env, pool); + assert(tclv == value(6)); + + std::istringstream tcelis(testCallLambda); + const value tcel = cons("testCallLambda", quotedParameters(mklist(primitiveProcedure(mult), 3, 4))); + const value tcelv = evalScript(tcel, tcelis, env, pool); + assert(tcelv == value(12)); + return true; +} + bool testEvalGC() { resetLambdaCounters(); resetListCounters(); resetValueCounters(); testEval(); + testEvalExpr(); + testEvalLambda(); assert(countValues == 0); assert(countLambdas == 0); assert(countlists == 0); @@ -181,11 +220,6 @@ bool testEvalGC() { return true; } -bool testEvalRun() { - evalDriverRun(std::cin, std::cout); - return true; -} - } } @@ -198,6 +232,7 @@ int main() { tuscany::eval::testWrite(); tuscany::eval::testEval(); tuscany::eval::testEvalExpr(); + tuscany::eval::testEvalLambda(); tuscany::eval::testEvalGC(); std::cout << "OK" << std::endl; -- cgit v1.2.3