summaryrefslogtreecommitdiffstats
path: root/cpp/sca/test/store-script/store-script-test.cpp
diff options
context:
space:
mode:
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;