summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2014-08-26 15:11:47 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2014-08-26 15:11:47 (GMT)
commit0a22a276cfff2155cbaf4939d75c257dfdb46932 (patch)
treeefd057b2bfee89557636819433bc7ecf932153cd /test
parentf3e7f0bb9866edb30682b1e1b72db7c4f6946378 (diff)
downloaduscxml-0a22a276cfff2155cbaf4939d75c257dfdb46932.zip
uscxml-0a22a276cfff2155cbaf4939d75c257dfdb46932.tar.gz
uscxml-0a22a276cfff2155cbaf4939d75c257dfdb46932.tar.bz2
Identify InterpreterIssues at runtime
Diffstat (limited to 'test')
-rw-r--r--test/src/test-flat-stateid.cpp4
-rw-r--r--test/src/test-issue-reporting.cpp32
2 files changed, 34 insertions, 2 deletions
diff --git a/test/src/test-flat-stateid.cpp b/test/src/test-flat-stateid.cpp
index 6eb1ed8..719e4ee 100644
--- a/test/src/test-flat-stateid.cpp
+++ b/test/src/test-flat-stateid.cpp
@@ -16,7 +16,7 @@ int main(int argc, char** argv) {
}
{
- std::string stateId = "active:{s1};entered:{s1,s2}";
+ std::string stateId = "active:{s1};visited:{s1,s2}";
uscxml::FlatStateIdentifier flat1(stateId);
assert(flat1.getActive().size() == 1);
assert(flat1.getVisited().size() == 2);
@@ -28,7 +28,7 @@ int main(int argc, char** argv) {
{
- std::string stateId = "active:{s0,s1,s2};entered:{s0,s1,s2};history:{h0:{s1,s2},h1:{s2,s3}}";
+ std::string stateId = "active:{s0,s1,s2};visited:{s0,s1,s2};history:{h0:{s1,s2},h1:{s2,s3}}";
uscxml::FlatStateIdentifier flat1(stateId);
listIter = flat1.getActive().begin();
diff --git a/test/src/test-issue-reporting.cpp b/test/src/test-issue-reporting.cpp
index 3cdb141..cd1687c 100644
--- a/test/src/test-issue-reporting.cpp
+++ b/test/src/test-issue-reporting.cpp
@@ -17,6 +17,15 @@ std::set<std::string> issueLocationsForXML(const std::string xml) {
return issueLocations;
}
+size_t runtimeIssues;
+class IssueMonitor : public InterpreterMonitor {
+public:
+ IssueMonitor() { runtimeIssues = 0; }
+ void reportIssue(Interpreter interpreter, const InterpreterIssue& issue) {
+ runtimeIssues++;
+ }
+};
+
int main(int argc, char** argv) {
google::InitGoogleLogging(argv[0]);
@@ -27,6 +36,29 @@ int main(int argc, char** argv) {
while(iterations--) {
if (1) {
+ // Potential endless loop
+
+ const char* xml =
+ "<scxml datamodel=\"ecmascript\">"
+ " <datamodel><data id=\"counter\" expr=\"5\" /></datamodel>"
+ " <state id=\"foo\">"
+ " <onentry><script>counter--;</script></onentry>"
+ " <transition target=\"foo\" cond=\"counter > 0\" />"
+ " <transition target=\"bar\" cond=\"counter == 0\" />"
+ " </state>"
+ " <state id=\"bar\" final=\"true\" />"
+ "</scxml>";
+
+ IssueMonitor monitor;
+ Interpreter interpreter = Interpreter::fromXML(xml);
+ interpreter.addMonitor(&monitor);
+ interpreter.interpret();
+
+ // first reiteration is not counted as it might be valid when raising internal errors
+ assert(runtimeIssues == 3);
+ }
+
+ if (1) {
// Unreachable states
const char* xml =