diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-11-13 23:56:53 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-11-13 23:56:53 (GMT) |
commit | 7a1dc775d5d8edcf9193ca4ad7154af5eab18f1c (patch) | |
tree | b681e35b778f5c17d768b0713d8141a17a1dedb9 /test | |
parent | 2bc6ae32bbb67d242436d173c41fabc47626b943 (diff) | |
download | uscxml-7a1dc775d5d8edcf9193ca4ad7154af5eab18f1c.zip uscxml-7a1dc775d5d8edcf9193ca4ad7154af5eab18f1c.tar.gz uscxml-7a1dc775d5d8edcf9193ca4ad7154af5eab18f1c.tar.bz2 |
Support for DataModelExtensions
Diffstat (limited to 'test')
-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 |