diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-16 06:01:33 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-16 06:01:33 +0000 |
commit | ada8802640aa232d34b1fe2793b9f52cd62b41f1 (patch) | |
tree | b72a576c33e5593e7d2842339f06e5e1b2d9faae /cpp/sca/modules/eval/eval-test.cpp | |
parent | 4109b6c23b5169463bd493347dddb1ab58aa0860 (diff) |
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
Diffstat (limited to 'cpp/sca/modules/eval/eval-test.cpp')
-rw-r--r-- | cpp/sca/modules/eval/eval-test.cpp | 45 |
1 files changed, 40 insertions, 5 deletions
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<value>& 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<value>("testReturnLambda"); + std::istringstream trlis(testReturnLambda); + const value trlv = evalScript(trl, trlis, env, pool); + + std::istringstream tclis(testCallLambda); + const value tcl = cons<value>("testCallLambda", quotedParameters(mklist<value>(trlv, 2, 3))); + const value tclv = evalScript(tcl, tclis, env, pool); + assert(tclv == value(6)); + + std::istringstream tcelis(testCallLambda); + const value tcel = cons<value>("testCallLambda", quotedParameters(mklist<value>(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; |