diff options
Diffstat (limited to 'test/src/test-datamodel.cpp')
-rw-r--r-- | test/src/test-datamodel.cpp | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/test/src/test-datamodel.cpp b/test/src/test-datamodel.cpp index 71189d6..f0b7536 100644 --- a/test/src/test-datamodel.cpp +++ b/test/src/test-datamodel.cpp @@ -13,6 +13,22 @@ using namespace uscxml; using namespace boost; +class TestDataModelExtension : public DataModelExtension { +public: + TestDataModelExtension() {} + + std::string provides() { + return "_x.platform.pool"; + } + + Data getValueOf(const std::string& member) { + return Data(true); + } + + void setValueOf(const std::string& member, const Data& data) { + std::cout << "Setting " << member << " to " << std::endl << Data::toJSON(data); + } +}; int main(int argc, char** argv) { #ifdef _WIN32 @@ -34,7 +50,6 @@ int main(int argc, char** argv) { assert(testData[i] == otherData[i]); } - exit(0); } Interpreter interpreter = Interpreter::fromXML("<scxml></scxml>"); @@ -482,4 +497,31 @@ int main(int argc, char** argv) { std::cout << content << std::endl; assert(boost::equals(content, "There are 12 monkeys! Really 12 monkeys!")); } + + { + std::string xml = + "<scxml datamodel=\"ecmascript\">" + " <script src=\"http://uscxml.tk.informatik.tu-darmstadt.de/scripts/dump.js\" />" + " <state id=\"s1\">" + " <onentry>" + " <script>_x.platform.pool('memeber.second', { foo: 12, bar: 34})</script>" + " <log label=\"ext\" expr=\"dump(_x.platform.pool('member.first'))\" />" + " </onentry>" + " <transition target=\"done\" />" + " </state>" + " <final id=\"done\" />" + "</scxml>"; + + TestDataModelExtension ext; + Interpreter interpreter = Interpreter::fromXML(xml); + interpreter.addDataModelExtension(&ext); + + InterpreterState state; + + do { + state = interpreter.step(); + } while (state != USCXML_FINISHED && state!= USCXML_DESTROYED); + + + } }
\ No newline at end of file |