From 1b11b310be61e51b3ac5ebb83f7c8a33aef3d6e8 Mon Sep 17 00:00:00 2001 From: Stefan Radomski Date: Mon, 9 May 2016 22:44:01 +0200 Subject: Fixed a typo and added a test for issue 56 --- src/uscxml/Interpreter.h | 2 +- test/src/issues/test-issue56.cpp | 66 ++++++++++++++++++++++++++++++++++++++++ test/w3c/convert-tests.sh | 13 ++++++-- 3 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 test/src/issues/test-issue56.cpp diff --git a/src/uscxml/Interpreter.h b/src/uscxml/Interpreter.h index a22b7b8..81d12d0 100644 --- a/src/uscxml/Interpreter.h +++ b/src/uscxml/Interpreter.h @@ -70,7 +70,7 @@ catch (Event e) { \ } catch (boost::bad_weak_ptr e) { \ LOG(ERROR) << "Unclean shutdown " << std::endl << std::endl; \ } catch (...) { \ - LOG(ERROR) << "An exception occured when calling " #callback " on monitors"; \ + LOG(ERROR) << "An exception occurred when calling " #callback " on monitors"; \ } \ if (_state == USCXML_DESTROYED) { \ throw boost::bad_weak_ptr(); \ diff --git a/test/src/issues/test-issue56.cpp b/test/src/issues/test-issue56.cpp new file mode 100644 index 0000000..0330512 --- /dev/null +++ b/test/src/issues/test-issue56.cpp @@ -0,0 +1,66 @@ +#include "uscxml/Interpreter.h" + +using namespace uscxml; + +// -- Issue 56 on github +int main(int argc, char** argv) { + std::deque messageQueue; + messageQueue.push_back("a"); + messageQueue.push_back("b"); + messageQueue.push_back("c"); + messageQueue.push_back("d"); + + const char* scxmlContent = + "" + "" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + ""; + + std::string msg; + + uscxml::Interpreter scxml = uscxml::Interpreter::fromXML(scxmlContent, ""); + scxml.addMonitor(new StateTransitionMonitor()); + + uscxml::InterpreterState state; + // assume initial stable configuration + do { + state = scxml.step(); + } while(state > 0); + + while(state != uscxml::USCXML_FINISHED && !messageQueue.empty()) { + msg = messageQueue.front(); + messageQueue.pop_front(); + + scxml.receive(uscxml::Event(msg, uscxml::Event::EXTERNAL)); + + // step to next stable configuration + do { + state = scxml.step(); + } while(state > 0); + + } + + return EXIT_SUCCESS; + +} \ No newline at end of file diff --git a/test/w3c/convert-tests.sh b/test/w3c/convert-tests.sh index 0e43b48..bd8d140 100755 --- a/test/w3c/convert-tests.sh +++ b/test/w3c/convert-tests.sh @@ -26,19 +26,28 @@ TXMLS=`ls txml/*.txml` # java -jar /Users/sradomski/Developer/Applications/SaxonHE9-4-0-7J/saxon9he.jar $TXML confPromela.xsl -o:$DEST # done +# for TXML in $TXMLS +# do +# DEST=prolog/`basename $TXML .txml`.scxml +# echo "Processing $TXML to $DEST" +# java -jar /Users/sradomski/Developer/Applications/SaxonHE9-4-0-7J/saxon9he.jar $TXML confProlog.xsl -o:$DEST +# done + for TXML in $TXMLS do - DEST=prolog/`basename $TXML .txml`.scxml + DEST=namespace/`basename $TXML .txml`.scxml echo "Processing $TXML to $DEST" - java -jar /Users/sradomski/Developer/Applications/SaxonHE9-4-0-7J/saxon9he.jar $TXML confProlog.xsl -o:$DEST + java -jar /Users/sradomski/Developer/Applications/SaxonHE9-4-0-7J/saxon9he.jar $TXML confEcma-ns.xsl -o:$DEST done cp txml/*.txt ecma/ +cp txml/*.txt ecma.ns/ cp txml/*.txt xpath/ cp txml/*.txt promela/ cp txml/*.txt prolog/ find ./ecma -type f -exec grep -Ili 'datamodel="xpath"' {} \; |xargs rm -fv +find ./namespace -type f -exec grep -Ili 'datamodel="xpath"' {} \; |xargs rm -fv find ./xpath -type f -exec grep -Ili 'datamodel="ecmascript"' {} \; |xargs rm -fv -- cgit v0.12