diff options
author | Stefan Radomski <sradomski@mintwerk.de> | 2015-12-04 08:00:18 (GMT) |
---|---|---|
committer | Stefan Radomski <sradomski@mintwerk.de> | 2015-12-04 08:00:18 (GMT) |
commit | b8ba0e7c31f397a66f9d509ff20a85b33619475a (patch) | |
tree | 9a5adb4f891cdc29eb80f597510e0cef8ee0a47f /test/src | |
parent | 57ba362eae6e8209cf560555fd4cc4bb76dbe2a1 (diff) | |
download | uscxml-b8ba0e7c31f397a66f9d509ff20a85b33619475a.zip uscxml-b8ba0e7c31f397a66f9d509ff20a85b33619475a.tar.gz uscxml-b8ba0e7c31f397a66f9d509ff20a85b33619475a.tar.bz2 |
All changes up to my dissertation
Diffstat (limited to 'test/src')
-rw-r--r-- | test/src/test-issue-reporting.cpp | 241 | ||||
-rw-r--r-- | test/src/test-lifecycle.cpp | 2 | ||||
-rw-r--r-- | test/src/test-stress.cpp | 20 | ||||
-rw-r--r-- | test/src/test-w3c.cpp | 4 |
4 files changed, 248 insertions, 19 deletions
diff --git a/test/src/test-issue-reporting.cpp b/test/src/test-issue-reporting.cpp index 7b3d99c..9750c58 100644 --- a/test/src/test-issue-reporting.cpp +++ b/test/src/test-issue-reporting.cpp @@ -207,7 +207,9 @@ int main(int argc, char** argv) { const char* xml = "<scxml datamodel=\"ecmascript\">" " <state id=\"start\" initial=\"foo\">" - " <initial></initial>" + " <initial>" + " <transition target=\"foo\" />" + " </initial>" " <state id=\"foo\" />" " </state>" "</scxml>"; @@ -216,6 +218,7 @@ int main(int argc, char** argv) { assert(issueLocations.find("//state[@id=\"start\"]") != issueLocations.end()); assert(issueLocations.size() == 1); } + { // initial attribute with atomic state const char* xml = @@ -227,23 +230,162 @@ int main(int argc, char** argv) { assert(issueLocations.find("//state[@id=\"start\"]") != issueLocations.end()); assert(issueLocations.size() == 1); } + { // initial child with atomic state const char* xml = "<scxml datamodel=\"ecmascript\">" " <state id=\"start\">" - " <initial />" + " <initial>" + " <transition target=\"start\" />" + " </initial>" " </state>" "</scxml>"; std::set<std::string> issueLocations = issueLocationsForXML(xml); assert(issueLocations.find("//state[@id=\"start\"]") != issueLocations.end()); + assert(issueLocations.size() == 2); // also invalid non-child target state in initial + } + + // combinations of namelist, content and param + { + // send with content and namelist, not allowed + const char* xml = + "<scxml datamodel=\"ecmascript\">" + " <state id=\"start\">" + " <onentry>" + " <send target=\"#_external\" namelist=\"var1\">" + " <content>Foo!</content>" + " </send>" + " </onentry>" + " </state>" + "</scxml>"; + + std::set<std::string> issueLocations = issueLocationsForXML(xml); + assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/send[1]") != issueLocations.end()); + assert(issueLocations.size() == 1); + } + + { + // send with content and params, not allowed + const char* xml = + "<scxml datamodel=\"ecmascript\">" + " <state id=\"start\">" + " <onentry>" + " <send target=\"#_external\">" + " <param name=\"foo\" expr=\"3\" />" + " <content>Foo!</content>" + " </send>" + " </onentry>" + " </state>" + "</scxml>"; + + std::set<std::string> issueLocations = issueLocationsForXML(xml); + assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/send[1]") != issueLocations.end()); + assert(issueLocations.size() == 1); + } + + { + // send with params and namelist, perfectly acceptable + const char* xml = + "<scxml datamodel=\"ecmascript\">" + " <state id=\"start\">" + " <onentry>" + " <send target=\"#_external\" namelist=\"foo\">" + " <param name=\"foo\" expr=\"3\" />" + " </send>" + " </onentry>" + " </state>" + "</scxml>"; + + std::set<std::string> issueLocations = issueLocationsForXML(xml); + assert(issueLocations.size() == 0); + } + + { + // invoke with content and src, not allowed + const char* xml = + "<scxml datamodel=\"ecmascript\">" + " <state id=\"start\">" + " <invoke type=\"scxml\" src=\"var1\">" + " <content>Foo!</content>" + " </invoke>" + " </state>" + "</scxml>"; + + std::set<std::string> issueLocations = issueLocationsForXML(xml); + assert(issueLocations.find("//state[@id=\"start\"]/invoke[1]") != issueLocations.end()); + assert(issueLocations.size() == 1); + } + + { + // invoke with namelist and param, not allowed + const char* xml = + "<scxml datamodel=\"ecmascript\">" + " <state id=\"start\">" + " <invoke type=\"scxml\" namelist=\"var1\">" + " <param name=\"foo\" expr=\"3\" />" + " </invoke>" + " </state>" + "</scxml>"; + + std::set<std::string> issueLocations = issueLocationsForXML(xml); + assert(issueLocations.find("//state[@id=\"start\"]/invoke[1]") != issueLocations.end()); assert(issueLocations.size() == 1); + } + + { + // invoke with param and content, perfectly acceptable + const char* xml = + "<scxml datamodel=\"ecmascript\">" + " <state id=\"start\">" + " <invoke type=\"scxml\">" + " <param name=\"foo\" expr=\"3\" />" + " <content>Foo!</content>" + " </invoke>" + " </state>" + "</scxml>"; + + std::set<std::string> issueLocations = issueLocationsForXML(xml); + assert(issueLocations.size() == 0); + } + + { + // invoke with namelist and content, perfectly acceptable + const char* xml = + "<scxml datamodel=\"ecmascript\">" + " <state id=\"start\">" + " <invoke type=\"scxml\" namelist=\"var1\">" + " <content>Foo!</content>" + " </invoke>" + " </state>" + "</scxml>"; + + std::set<std::string> issueLocations = issueLocationsForXML(xml); + assert(issueLocations.size() == 0); + } + + { + // donedata with content and param, not allowed + const char* xml = + "<scxml datamodel=\"ecmascript\">" + " <state id=\"start\">" + " <donedata>" + " <param name=\"foo\" expr=\"3\" />" + " <content>Foo!</content>" + " </donedata>" + " </state>" + "</scxml>"; + std::set<std::string> issueLocations = issueLocationsForXML(xml); + assert(issueLocations.find("//state[@id=\"start\"]/donedata[1]") != issueLocations.end()); + assert(issueLocations.size() == 1); } + + } - - + + if (1) { // Transition can never be optimally enabled (conditionless, eventless) @@ -405,6 +547,91 @@ int main(int argc, char** argv) { assert(issueLocations.size() == 1); } + if (1) { + // Initial with multiple transitions + const char* xml = + "<scxml datamodel=\"ecmascript\">" + " <state id=\"start\">" + " <initial>" + " <transition target=\"foo\" />" + " <transition target=\"foo\" />" + " </initial>" + " <state id=\"foo\" />" + " <transition event=\"e.bar\" target=\"done\" />" + " </state>" + " <final id=\"done\" />" + "</scxml>"; + + std::set<std::string> issueLocations = issueLocationsForXML(xml); + assert(issueLocations.find("//state[@id=\"start\"]/initial[1]") != issueLocations.end()); + assert(issueLocations.size() == 1); + } + + if (1) { + // Initial with no transitions + const char* xml = + "<scxml datamodel=\"ecmascript\">" + " <state id=\"start\">" + " <initial />" + " <state id=\"foo\" />" + " <transition event=\"e.bar\" target=\"done\" />" + " </state>" + " <final id=\"done\" />" + "</scxml>"; + + std::set<std::string> issueLocations = issueLocationsForXML(xml); + assert(issueLocations.find("//state[@id=\"start\"]/initial[1]") != issueLocations.end()); + assert(issueLocations.size() == 1); + } + + if (1) { + // History transition with event + const char* xml = + "<scxml datamodel=\"ecmascript\">" + " <state id=\"start\" initial=\"bar\">" + " <history id=\"bar\">" + " <transition event=\"e.foo\" target=\"foo\" />" + " </history>" + " <state id=\"foo\">" + " <state id=\"foo.s1\">" + " <transition target=\"foo.s2\" />" + " </state>" + " <state id=\"foo.s2\" />" + " </state>" + " <transition event=\"e.bar\" target=\"done\" />" + " </state>" + " <final id=\"done\" />" + "</scxml>"; + + std::set<std::string> issueLocations = issueLocationsForXML(xml); + assert(issueLocations.find("//history[@id=\"bar\"]/transition[1]") != issueLocations.end()); + assert(issueLocations.size() == 1); + } + + if (1) { + // History transition with condition + const char* xml = + "<scxml datamodel=\"ecmascript\">" + " <state id=\"start\" initial=\"bar\">" + " <history id=\"bar\">" + " <transition cond=\"false\" target=\"foo\" />" + " </history>" + " <state id=\"foo\">" + " <state id=\"foo.s1\">" + " <transition target=\"foo.s2\" />" + " </state>" + " <state id=\"foo.s2\" />" + " </state>" + " <transition event=\"e.bar\" target=\"done\" />" + " </state>" + " <final id=\"done\" />" + "</scxml>"; + + std::set<std::string> issueLocations = issueLocationsForXML(xml); + assert(issueLocations.find("//history[@id=\"bar\"]/transition[1]") != issueLocations.end()); + assert(issueLocations.size() == 1); + } + if (1) { // Send to unknown IO Processor @@ -502,8 +729,10 @@ int main(int argc, char** argv) { " <assign location=\"foo\" expr=\"%2345\" />" " <send>" " <param expr=\"%2345\" />" - " <content expr=\"%2345\" />" " </send>" + " <send>" + " <content expr=\"%2345\" />" + " </send>" " </onentry>" " </state>" "</scxml>"; @@ -512,8 +741,8 @@ int main(int argc, char** argv) { assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/log[1]") != issueLocations.end()); assert(issueLocations.find("//data[@id=\"foo\"]") != issueLocations.end()); assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/assign[1]") != issueLocations.end()); - assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/send[1]/content[1]") != issueLocations.end()); assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/send[1]/param[1]") != issueLocations.end()); + assert(issueLocations.find("//state[@id=\"start\"]/onentry[1]/send[2]/content[1]") != issueLocations.end()); assert(issueLocations.size() == 5); } diff --git a/test/src/test-lifecycle.cpp b/test/src/test-lifecycle.cpp index 3d675df..84ffbb5 100644 --- a/test/src/test-lifecycle.cpp +++ b/test/src/test-lifecycle.cpp @@ -45,7 +45,7 @@ void load_orig_throw_code() { } extern "C" -void __cxa_throw (void *thrown_exception, void *pvtinfo, void (*dest)(void *)) { +CXA_THROW_SIGNATURE { std::cerr << __FUNCTION__ << " will throw exception from " << std::endl; if (orig_cxa_throw == 0) load_orig_throw_code(); diff --git a/test/src/test-stress.cpp b/test/src/test-stress.cpp index d0b4a5c..220399a 100644 --- a/test/src/test-stress.cpp +++ b/test/src/test-stress.cpp @@ -8,6 +8,13 @@ #include "uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.h" #include <boost/algorithm/string.hpp> +#ifdef _WIN32 +#include "XGetopt.h" +#endif + +int startedAt; +int lastTransitionAt; + #ifdef HAS_SIGNAL_H #include <signal.h> #endif @@ -20,13 +27,6 @@ #include <dlfcn.h> #endif -#ifdef _WIN32 -#include "XGetopt.h" -#endif - -int startedAt; -int lastTransitionAt; - #ifdef HAS_EXECINFO_H void printBacktrace(void** array, int size) { char** messages = backtrace_symbols(array, size); @@ -47,7 +47,7 @@ void load_orig_throw_code() { } extern "C" -void __cxa_throw (void *thrown_exception, void *pvtinfo, void (*dest)(void *)) { +CXA_THROW_SIGNATURE { std::cerr << __FUNCTION__ << " will throw exception from " << std::endl; if (orig_cxa_throw == 0) load_orig_throw_code(); @@ -67,11 +67,11 @@ void customTerminate() { try { // try once to re-throw currently active exception if (!tried_throw) { - throw; tried_throw = true; + throw; } else { tried_throw = false; - }; + } } catch (const std::exception &e) { std::cerr << __FUNCTION__ << " caught unhandled exception. what(): " << e.what() << std::endl; diff --git a/test/src/test-w3c.cpp b/test/src/test-w3c.cpp index c7f136d..1480ecb 100644 --- a/test/src/test-w3c.cpp +++ b/test/src/test-w3c.cpp @@ -23,10 +23,11 @@ static double delayFactor = 1; static std::string documentURI; int retCode = EXIT_FAILURE; +uscxml::Interpreter interpreter; class W3CStatusMonitor : public uscxml::StateTransitionMonitor { -void beforeCompletion(uscxml::Interpreter interpreter) { +void beforeCompletion(uscxml::Interpreter tmp) { if (interpreter.getConfiguration().size() == 1 && interpreter.isInState("pass")) { std::cout << "TEST SUCCEEDED" << std::endl; retCode = EXIT_SUCCESS; @@ -75,7 +76,6 @@ int main(int argc, char** argv) { documentURI = argv[optind]; - Interpreter interpreter; LOG(INFO) << "Processing " << documentURI << (withFlattening ? " FSM converted" : "") << (delayFactor ? "" : " with delays *= " + toStr(delayFactor)); if (withFlattening) { interpreter = Interpreter::fromURL(documentURI); |