summaryrefslogtreecommitdiffstats
path: root/cpp/sca/test/store-script/store-script-test.cpp
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2009-10-11 00:01:09 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2009-10-11 00:01:09 +0000
commit4a4c32fea2f0cc36b01ee1382964b10936e1d7d0 (patch)
treef9059ef059f45a28c7379a7f101035f7b20557a1 /cpp/sca/test/store-script/store-script-test.cpp
parenta64c1ec2a50f62d63872eac6bc740966602e87bd (diff)
Added support for JSON-RPC to httpd module. Fixed issues with double numbers in json.hpp. Added store .html and .js files to store test case.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@823982 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/sca/test/store-script/store-script-test.cpp')
-rw-r--r--cpp/sca/test/store-script/store-script-test.cpp33
1 files changed, 29 insertions, 4 deletions
diff --git a/cpp/sca/test/store-script/store-script-test.cpp b/cpp/sca/test/store-script/store-script-test.cpp
index dff802b714..95e7ba0929 100644
--- a/cpp/sca/test/store-script/store-script-test.cpp
+++ b/cpp/sca/test/store-script/store-script-test.cpp
@@ -29,18 +29,42 @@
#include <string>
#include "driver.hpp"
-namespace store
-{
+namespace store {
bool contains(const std::string& str, const std::string& pattern) {
return str.find(pattern) != str.npos;
}
bool testScript() {
- std::ifstream is("store-script.scm", std::ios_base::in);
+ std::ifstream is("store.scm", std::ios_base::in);
std::ostringstream os;
tuscany::evalDriverRun(is, os);
- assert(contains(os.str(), "List::(List::(String::'apple', (String::'USD', (String::'$', (Number::2.99, ())))), ())"));
+ assert(contains(os.str(), "List::(List::(List::(Symbol::name, (String::\"apple\", ())), (List::(Symbol::currency, (String::\"USD\", ())), (List::(Symbol::symbol, (String::\"$\", ())), (List::(Symbol::price, (Number::2.99, ())), ())))), ())"));
+ return true;
+}
+
+const tuscany::value evalLoop(std::istream& is, const tuscany::value& req, tuscany::Env& globalEnv) {
+ tuscany::value in = tuscany::read(is);
+ if(tuscany::isNil(in))
+ return tuscany::eval(req, globalEnv);
+ tuscany::eval(in, globalEnv);
+ return evalLoop(is, req, globalEnv);
+}
+
+bool testEval() {
+ std::ifstream is("store.scm", std::ios_base::in);
+ std::ostringstream os;
+
+ tuscany::setupEvalOut(os);
+ tuscany::Env globalEnv = tuscany::setupEnvironment();
+
+ const tuscany::value req(tuscany::makeList<tuscany::value>("storeui_service", std::string("getcatalog")));
+ const tuscany::value res = evalLoop(is, req, globalEnv);
+
+ std::ostringstream rs;
+ rs << res;
+ assert(contains(rs.str(), "List::(List::(List::(Symbol::name, (String::\"apple\", ())), (List::(Symbol::currency, (String::\"USD\", ())), (List::(Symbol::symbol, (String::\"$\", ())), (List::(Symbol::price, (Number::2.99, ())), ())))), (List::(List::(Symbol::name, (String::\"orange\", ())), (List::(Symbol::currency, (String::\"USD\", ())), (List::(Symbol::symbol, (String::\"$\", ())), (List::(Symbol::price, (Number::3.55, ())), ())))), (List::(List::(Symbol::name, (String::\"pear\", ())), (List::(Symbol::currency, (String::\"USD\", ())), (List::(Symbol::symbol, (String::\"$\", ())), (List::(Symbol::price, (Number::1.55, ())), ())))), ())))"));
+
return true;
}
@@ -51,6 +75,7 @@ int main() {
std::cout << "Testing..." << std::endl;
store::testScript();
+ store::testEval();
std::cout << "OK" << std::endl;