diff options
author | Stefan Radomski <github@mintwerk.de> | 2016-06-18 11:55:39 (GMT) |
---|---|---|
committer | Stefan Radomski <github@mintwerk.de> | 2016-06-18 11:55:39 (GMT) |
commit | 0e0be07906a720ae54e4572d6ac0cb657424550d (patch) | |
tree | 7d48c87a9142a5dad06570ca4daf0212475d83f1 /test | |
parent | 84bbbd42c3480c40c0355c64899f99f8d588d5c0 (diff) | |
download | uscxml-0e0be07906a720ae54e4572d6ac0cb657424550d.zip uscxml-0e0be07906a720ae54e4572d6ac0cb657424550d.tar.gz uscxml-0e0be07906a720ae54e4572d6ac0cb657424550d.tar.bz2 |
Started to port Debugger and issue 87
Diffstat (limited to 'test')
-rw-r--r-- | test/issues/test-issue87.scxml.todo | 189 | ||||
-rw-r--r-- | test/src/test-lifecycle.cpp | 46 | ||||
-rw-r--r-- | test/src/test-state-pass.cpp | 4 | ||||
-rw-r--r-- | test/src/test-stress.cpp | 4 | ||||
-rw-r--r-- | test/src/test-url.cpp | 2 | ||||
-rw-r--r-- | test/src/test-validating.cpp | 4 |
6 files changed, 219 insertions, 30 deletions
diff --git a/test/issues/test-issue87.scxml.todo b/test/issues/test-issue87.scxml.todo new file mode 100644 index 0000000..55f0b60 --- /dev/null +++ b/test/issues/test-issue87.scxml.todo @@ -0,0 +1,189 @@ +<scxml datamodel="lua" initial="Work" name="Simulator" version="1.0" xmlns="http://www.w3.org/2005/07/scxml"> + <datamodel> + <data id="PauseTimers">{ + test = 'a', + b = 25, + t_test = { + xxx = '23', + zzz = 45 + } +} + </data> + </datamodel> + <final id="Pass"/> + <final id="Fail"/> + <state id="Work" initial="Init"> + <onentry> + <log expr="'Hello from work'"/> + </onentry> + <transition event="error.*" target="Fail"/> + <transition event="quit" target="Pass"/> + <state id="Init"> + <onentry> + <log expr="'Hello from init'"/> + </onentry> + <transition event="StartExercise" target="Training"/> + </state> + <parallel id="Training"> + <transition event="StopExercise" target="Init"/> + <state id="APU"> + <invoke type="scxml"> + <content> + <scxml datamodel="lua" initial="StateShape1" name="ScxmlShape1" version="1.0" xmlns="http://www.w3.org/2005/07/scxml"> + <final id="Fail"/> + <state id="StateShape1" initial="Flash"> + <transition event="error" target="Fail"/> + <transition event="StopExercise" target="Pass"/> + <state id="Flash"> + <datamodel> + <data id="t_ApuOff">{ + dDiff = 0, + dEnter = os.clock(), + dInterval = 2000 +} + </data> + <data id="t_ApuOn">{ + dDiff = 0, + dEnter = os.clock(), + dInterval = 2000 +} + </data> + <data expr="'xxx'" id="FlashName"/> + </datamodel> + <transition event="Pause" target="OnPause"/> + <state id="ApuOn"> + <onentry> + <send delayexpr="tostring(t_ApuOn.dInterval-t_ApuOn.dDiff)..'ms'" event="DoApuOff" id="ID_DoApuOff"/> + <assign expr="os.clock()" location="t_ApuOn.dEnter"/> + <log expr="string.format('%s=%d',FlashName,t_ApuOn.dInterval-t_ApuOn.dDiff)" label="Delay[On]"/> + </onentry> + <onexit> + <cancel sendid="ID_DoApuOff"/> + <assign expr="t_ApuOn.dDiff + (os.clock() - t_ApuOn.dEnter)*1000" location="t_ApuOn.dDiff"/> + <log expr="string.format('%s=%d',FlashName,t_ApuOn.dDiff)" label="Elapsed[On]"/> + </onexit> + <transition event="DoApuOff" target="ApuOff"> + <assign location="t_ApuOn.dDiff" expr="0"/> + </transition> + </state> + <initial> + <transition target="ApuOff"> + <assign location="t_ApuOff.dDiff" expr="0"/> + <assign location="t_ApuOn.dDiff" expr="0"/> + </transition> + </initial> + <state id="ApuOff"> + <onentry> + <send delayexpr="tostring(t_ApuOff.dInterval-t_ApuOff.dDiff)..'ms'" event="DoApuOn" id="ID_DoApuOn"/> + <assign expr="os.clock()" location="t_ApuOff.dEnter"/> + <log expr="string.format('%s=%d',FlashName,t_ApuOff.dInterval-t_ApuOff.dDiff)" label="Delay[Off]"/> + </onentry> + <onexit> + <cancel sendid="ID_DoApuOn"/> + <assign expr="t_ApuOff.dDiff + (os.clock() - t_ApuOff.dEnter)*1000" location="t_ApuOff.dDiff"/> + <log expr="string.format('%s=%d',FlashName,t_ApuOff.dDiff)" label="Elapsed[Off]"/> + </onexit> + <transition event="DoApuOn" target="ApuOn"> + <assign location="t_ApuOff.dDiff" expr="0"/> + </transition> + </state> + <history id="HistoryShape1" type="deep"> + <transition target="ApuOff"/> + </history> + </state> + <state id="OnPause"> + <transition event="Resume" target="HistoryShape1"/> + </state> + </state> + <final id="Pass"/> + </scxml> + </content> + <param expr="'APU'" name="FlashName"/> + </invoke> + </state> + <state id="StateShape3"> + <state id="OnResume"> + <transition event="Pause" target="OnPause"/> + </state> + <state id="OnPause"> + <transition event="Resume" target="OnResume"/> + </state> + </state> + <state id="ENGINES"> + <invoke type="scxml"> + <content> + <scxml datamodel="lua" initial="StateShape1" name="ScxmlShape1" version="1.0" xmlns="http://www.w3.org/2005/07/scxml"> + <final id="Fail"/> + <state id="StateShape1" initial="Flash"> + <transition event="error" target="Fail"/> + <transition event="StopExercise" target="Pass"/> + <state id="Flash"> + <datamodel> + <data id="t_ApuOff">{ + dDiff = 0, + dEnter = os.clock(), + dInterval = 2000 +} + </data> + <data id="t_ApuOn">{ + dDiff = 0, + dEnter = os.clock(), + dInterval = 2000 +} + </data> + <data expr="'xxx'" id="FlashName"/> + </datamodel> + <transition event="Pause" target="OnPause"/> + <state id="ApuOn"> + <onentry> + <send delayexpr="tostring(t_ApuOn.dInterval-t_ApuOn.dDiff)..'ms'" event="DoApuOff" id="ID_DoApuOff"/> + <assign expr="os.clock()" location="t_ApuOn.dEnter"/> + <log expr="string.format('%s=%d',FlashName,t_ApuOn.dInterval-t_ApuOn.dDiff)" label="Delay[On]"/> + </onentry> + <onexit> + <cancel sendid="ID_DoApuOff"/> + <assign expr="t_ApuOn.dDiff + (os.clock() - t_ApuOn.dEnter)*1000" location="t_ApuOn.dDiff"/> + <log expr="string.format('%s=%d',FlashName,t_ApuOn.dDiff)" label="Elapsed[On]"/> + </onexit> + <transition event="DoApuOff" target="ApuOff"> + <assign location="t_ApuOn.dDiff" expr="0"/> + </transition> + </state> + <initial> + <transition target="ApuOff"> + <assign location="t_ApuOff.dDiff" expr="0"/> + <assign location="t_ApuOn.dDiff" expr="0"/> + </transition> + </initial> + <state id="ApuOff"> + <onentry> + <send delayexpr="tostring(t_ApuOff.dInterval-t_ApuOff.dDiff)..'ms'" event="DoApuOn" id="ID_DoApuOn"/> + <assign expr="os.clock()" location="t_ApuOff.dEnter"/> + <log expr="string.format('%s=%d',FlashName,t_ApuOff.dInterval-t_ApuOff.dDiff)" label="Delay[Off]"/> + </onentry> + <onexit> + <cancel sendid="ID_DoApuOn"/> + <assign expr="t_ApuOff.dDiff + (os.clock() - t_ApuOff.dEnter)*1000" location="t_ApuOff.dDiff"/> + <log expr="string.format('%s=%d',FlashName,t_ApuOff.dDiff)" label="Elapsed[Off]"/> + </onexit> + <transition event="DoApuOn" target="ApuOn"> + <assign location="t_ApuOff.dDiff" expr="0"/> + </transition> + </state> + <history id="HistoryShape1" type="deep"> + <transition target="ApuOff"/> + </history> + </state> + <state id="OnPause"> + <transition event="Resume" target="HistoryShape1"/> + </state> + </state> + <final id="Pass"/> + </scxml> + </content> + <param expr="'ENGINES'" name="FlashName"/> + </invoke> + </state> + </parallel> + </state> +</scxml> diff --git a/test/src/test-lifecycle.cpp b/test/src/test-lifecycle.cpp index 14ebd94..81fc363 100644 --- a/test/src/test-lifecycle.cpp +++ b/test/src/test-lifecycle.cpp @@ -48,67 +48,67 @@ std::list<CallbackType> callBackSeq; class SequenceCheckingMonitor : public InterpreterMonitor { - virtual void beforeProcessingEvent(const Event& event) { + virtual void beforeProcessingEvent(InterpreterImpl* impl, const Event& event) { CHECK_CALLBACK_TYPE(USCXML_BEFOREPROCESSINGEVENT); } - virtual void beforeMicroStep() { + virtual void beforeMicroStep(InterpreterImpl* impl) { CHECK_CALLBACK_TYPE(USCXML_BEFOREMICROSTEP); } - virtual void beforeExitingState(const XERCESC_NS::DOMElement* state) { + virtual void beforeExitingState(InterpreterImpl* impl, const XERCESC_NS::DOMElement* state) { CHECK_CALLBACK_TYPE(USCXML_BEFOREEXITINGSTATE); } - virtual void afterExitingState(const XERCESC_NS::DOMElement* state) { + virtual void afterExitingState(InterpreterImpl* impl, const XERCESC_NS::DOMElement* state) { CHECK_CALLBACK_TYPE(USCXML_AFTEREXITINGSTATE); } - virtual void beforeExecutingContent(const XERCESC_NS::DOMElement* element) { + virtual void beforeExecutingContent(InterpreterImpl* impl, const XERCESC_NS::DOMElement* element) { CHECK_CALLBACK_TYPE(USCXML_BEFOREEXECUTINGCONTENT); } - virtual void afterExecutingContent(const XERCESC_NS::DOMElement* element) { + virtual void afterExecutingContent(InterpreterImpl* impl, const XERCESC_NS::DOMElement* element) { CHECK_CALLBACK_TYPE(USCXML_AFTEREXECUTINGCONTENT); } - virtual void beforeUninvoking(const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeid) { + virtual void beforeUninvoking(InterpreterImpl* impl, const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeid) { CHECK_CALLBACK_TYPE(USCXML_BEFOREUNINVOKING); } - virtual void afterUninvoking(const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeid) { + virtual void afterUninvoking(InterpreterImpl* impl, const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeid) { CHECK_CALLBACK_TYPE(USCXML_AFTERUNINVOKING); } - virtual void beforeTakingTransition(const XERCESC_NS::DOMElement* transition) { + virtual void beforeTakingTransition(InterpreterImpl* impl, const XERCESC_NS::DOMElement* transition) { CHECK_CALLBACK_TYPE(USCXML_BEFORETAKINGTRANSITION); } - virtual void afterTakingTransition(const XERCESC_NS::DOMElement* transition) { + virtual void afterTakingTransition(InterpreterImpl* impl, const XERCESC_NS::DOMElement* transition) { CHECK_CALLBACK_TYPE(USCXML_AFTERTAKINGTRANSITION); } - virtual void beforeEnteringState(const XERCESC_NS::DOMElement* state) { + virtual void beforeEnteringState(InterpreterImpl* impl, const XERCESC_NS::DOMElement* state) { CHECK_CALLBACK_TYPE(USCXML_BEFOREENTERINGSTATE); } - virtual void afterEnteringState(const XERCESC_NS::DOMElement* state) { + virtual void afterEnteringState(InterpreterImpl* impl, const XERCESC_NS::DOMElement* state) { CHECK_CALLBACK_TYPE(USCXML_AFTERENTERINGSTATE); } - virtual void beforeInvoking(const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeid) { + virtual void beforeInvoking(InterpreterImpl* impl, const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeid) { CHECK_CALLBACK_TYPE(USCXML_BEFOREINVOKING); } - virtual void afterInvoking(const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeid) { + virtual void afterInvoking(InterpreterImpl* impl, const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeid) { CHECK_CALLBACK_TYPE(USCXML_AFTERINVOKING); } - virtual void afterMicroStep() { + virtual void afterMicroStep(InterpreterImpl* impl) { CHECK_CALLBACK_TYPE(USCXML_AFTERMICROSTEP); } - virtual void onStableConfiguration() { + virtual void onStableConfiguration(InterpreterImpl* impl) { CHECK_CALLBACK_TYPE(USCXML_ONSTABLECONFIGURATION); } - virtual void beforeCompletion() { + virtual void beforeCompletion(InterpreterImpl* impl) { CHECK_CALLBACK_TYPE(USCXML_BEFORECOMPLETION); } - virtual void afterCompletion() { + virtual void afterCompletion(InterpreterImpl* impl) { CHECK_CALLBACK_TYPE(USCXML_AFTERCOMPLETION); } @@ -139,7 +139,7 @@ int main(int argc, char** argv) { try { const char* xml = "<invalid />"; Interpreter interpreter = Interpreter::fromXML(xml, ""); - interpreter.setMonitor(&mon); + interpreter.addMonitor(&mon); assert(interpreter.getState() == USCXML_INSTANTIATED); interpreter.step(); assert(false); @@ -159,7 +159,7 @@ int main(int argc, char** argv) { " <final id=\"done\" />" "</scxml>"; Interpreter interpreter = Interpreter::fromXML(xml, ""); - interpreter.setMonitor(&mon); + interpreter.addMonitor(&mon); assert(interpreter.getState() == USCXML_INSTANTIATED); interpreter.step(); assert(false); @@ -182,7 +182,7 @@ int main(int argc, char** argv) { "</scxml>"; Interpreter interpreter = Interpreter::fromXML(xml, ""); - interpreter.setMonitor(&mon); + interpreter.addMonitor(&mon); callBackSeq.push_back(USCXML_BEFOREMICROSTEP); callBackSeq.push_back(USCXML_BEFOREENTERINGSTATE); // scxml @@ -232,7 +232,7 @@ int main(int argc, char** argv) { "</scxml>"; Interpreter interpreter = Interpreter::fromXML(xml, ""); - interpreter.setMonitor(&mon); + interpreter.addMonitor(&mon); callBackSeq.push_back(USCXML_BEFOREMICROSTEP); callBackSeq.push_back(USCXML_BEFOREENTERINGSTATE); // scxml @@ -304,7 +304,7 @@ int main(int argc, char** argv) { "</scxml>"; Interpreter interpreter = Interpreter::fromXML(xml, ""); - interpreter.setMonitor(&mon); + interpreter.addMonitor(&mon); callBackSeq.push_back(USCXML_BEFOREMICROSTEP); callBackSeq.push_back(USCXML_BEFOREENTERINGSTATE); // scxml callBackSeq.push_back(USCXML_AFTERENTERINGSTATE); diff --git a/test/src/test-state-pass.cpp b/test/src/test-state-pass.cpp index ac52a0b..afda506 100644 --- a/test/src/test-state-pass.cpp +++ b/test/src/test-state-pass.cpp @@ -73,11 +73,11 @@ int main(int argc, char** argv) { // interpreter.setActionLanguage(al); StateTransitionMonitor mon; - interpreter.setMonitor(&mon); + interpreter.addMonitor(&mon); InterpreterState state = InterpreterState::USCXML_UNDEF; while(state != USCXML_FINISHED) { - state = interpreter.step(true); + state = interpreter.step(); } assert(interpreter.isInState("pass")); } catch (Event e) { diff --git a/test/src/test-stress.cpp b/test/src/test-stress.cpp index 8bd2e4a..dc54f4e 100644 --- a/test/src/test-stress.cpp +++ b/test/src/test-stress.cpp @@ -16,7 +16,7 @@ int startedAt; int lastTransitionAt; class StatusMonitor : public uscxml::InterpreterMonitor { - void beforeTakingTransition(const XERCESC_NS::DOMElement* transition) { + void beforeTakingTransition(uscxml::InterpreterImpl* impl, const XERCESC_NS::DOMElement* transition) { lastTransitionAt = time(NULL); } @@ -81,7 +81,7 @@ int main(int argc, char** argv) { LOG(INFO) << "Processing " << interpreter.getImpl()->getBaseURL(); if (interpreter) { - interpreter.setMonitor(&vm); + interpreter.addMonitor(&vm); InterpreterState state = InterpreterState::USCXML_UNDEF; int now = time(NULL); diff --git a/test/src/test-url.cpp b/test/src/test-url.cpp index aa559f3..0e1d115 100644 --- a/test/src/test-url.cpp +++ b/test/src/test-url.cpp @@ -137,7 +137,7 @@ int main(int argc, char** argv) { // assert(foo.isAbsolute());
- HTTPServer::getInstance(8099, 8100);
+ HTTPServer::getInstance(8199, 8200);
std::string exeName = argv[0];
exeName = exeName.substr(exeName.find_last_of("\\/") + 1);
diff --git a/test/src/test-validating.cpp b/test/src/test-validating.cpp index 840a105..c3bc693 100644 --- a/test/src/test-validating.cpp +++ b/test/src/test-validating.cpp @@ -31,7 +31,7 @@ public: IssueMonitor() { runtimeIssues = 0; } - void reportIssue(const InterpreterIssue& issue) { + void reportIssue(InterpreterImpl* impl, const InterpreterIssue& issue) { runtimeIssues++; } }; @@ -60,7 +60,7 @@ int main(int argc, char** argv) { IssueMonitor monitor; Interpreter interpreter = Interpreter::fromXML(xml, ""); - interpreter.setMonitor(&monitor); + interpreter.addMonitor(&monitor); while(interpreter.step() > 0) {} |