summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2015-04-02 11:44:48 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2015-04-02 11:44:48 (GMT)
commit81aa1c79dd158aa7bc76876552e4b1d05ecea656 (patch)
tree4b590410d4042c156cfd3d4e874f3a329390a72b /test
parentff86d690dc02d7dd495000331d378e7d8eb688ac (diff)
downloaduscxml-81aa1c79dd158aa7bc76876552e4b1d05ecea656.zip
uscxml-81aa1c79dd158aa7bc76876552e4b1d05ecea656.tar.gz
uscxml-81aa1c79dd158aa7bc76876552e4b1d05ecea656.tar.bz2
Reactivated PHP bindings and some work on PROMELA
Diffstat (limited to 'test')
-rw-r--r--test/src/test-predicates.cpp2
-rw-r--r--test/src/test-promela-parser.cpp56
-rw-r--r--test/uscxml/promela/test-event-source-auto.scxml51
3 files changed, 94 insertions, 15 deletions
diff --git a/test/src/test-predicates.cpp b/test/src/test-predicates.cpp
index f66e8ba..7ba9225 100644
--- a/test/src/test-predicates.cpp
+++ b/test/src/test-predicates.cpp
@@ -118,7 +118,7 @@ int main(int argc, char** argv) {
assert(InterpreterImpl::nameMatch(transEvents, "error"));
assert(!InterpreterImpl::nameMatch(transEvents, "foo"));
- transEvents = "error foo";
+ transEvents = " error foo";
assert(InterpreterImpl::nameMatch(transEvents, "error"));
assert(InterpreterImpl::nameMatch(transEvents, "error.send"));
assert(InterpreterImpl::nameMatch(transEvents, "error.send.failed"));
diff --git a/test/src/test-promela-parser.cpp b/test/src/test-promela-parser.cpp
index 00cc347..8c8f2b4 100644
--- a/test/src/test-promela-parser.cpp
+++ b/test/src/test-promela-parser.cpp
@@ -9,13 +9,68 @@
#include <assert.h>
#include <boost/algorithm/string.hpp>
#include <iostream>
+#include <DOM/Document.hpp>
using namespace uscxml;
using namespace boost;
+using namespace Arabica::DOM;
extern int promela_debug;
void testInlinePromela() {
+
+ DOMImplementation<std::string> domFactory = Arabica::SimpleDOM::DOMImplementation<std::string>::getDOMImplementation();
+ Document<std::string> document = domFactory.createDocument("", "", 0);
+
+ {
+ std::string test = "\
+ promela-code This is foo!\
+ ";
+
+ Comment<std::string> comment = document.createComment(test);
+ PromelaInline inl(comment);
+ assert(inl.type == PromelaInline::PROMELA_CODE);
+ assert(inl.content == "This is foo!");
+ }
+
+ {
+ std::string test = "\
+ promela-code\n \
+ This is foo!\
+ ";
+
+ Comment<std::string> comment = document.createComment(test);
+ PromelaInline inl(comment);
+ assert(inl.type == PromelaInline::PROMELA_CODE);
+ assert(inl.content == "This is foo!");
+ }
+
+ {
+ std::string test = "\
+ promela-event\n \
+ [{\"name\": \"e1\", \"data\": { \"foo\": \"some string\" }}, \
+ {\"name\": \"e1\", \"data\": { \"bar\": 12 }}]";
+
+ Comment<std::string> comment = document.createComment(test);
+ PromelaInline inl(comment);
+ assert(inl.type == PromelaInline::PROMELA_EVENT_ONLY);
+
+ PromelaEventSource es(inl);
+ assert(es.events.array.size() == 2);
+
+ }
+
+ {
+ Interpreter interpreter = Interpreter::fromURL("/Users/sradomski/Documents/TK/Code/uscxml/test/uscxml/promela/test-event-source-auto.scxml");
+ assert(interpreter);
+ PromelaInlines inls(interpreter.getDocument().getDocumentElement());
+
+ assert(inls.getAllOfType(PromelaInline::PROMELA_EVENT_ONLY).size() == 1);
+ assert(inls.getAllOfType(PromelaInline::PROMELA_EVENT_ALL_BUT).size() == 1);
+ interpreter.getImpl()->getState("s0");
+ }
+
+#if 0
{
std::string test = "\
#promela-inline:\n \
@@ -169,6 +224,7 @@ void testInlinePromela() {
assert(pmlES.sequences.size() == 0);
assert(boost::trim_copy(pmlES.source.content) == "This is foo!");
}
+#endif
}
void checkTokenLocations(const std::string& expr, PromelaParserNode* ast) {
diff --git a/test/uscxml/promela/test-event-source-auto.scxml b/test/uscxml/promela/test-event-source-auto.scxml
index ef0e26c..cb33636 100644
--- a/test/uscxml/promela/test-event-source-auto.scxml
+++ b/test/uscxml/promela/test-event-source-auto.scxml
@@ -1,22 +1,45 @@
<scxml datamodel="promela">
<!--
- #promela-event-source-auto
- { e1: [
- { state: ['s0'],
- data: { foo: 'some string' }}
- { state: ['s0'],
- data: { bar: 12 }}
- { state: ['s1'],
- data: { foo: 'some other string' }}
- ]}
- -->
-
+ An auto event source will raise all events that enable transitions. If a
+ transition depends on a data field, these will have to be specified explicitly.
+
+ promela-event-all-but
+ [ "error.bar" ]
+ -->
+ <!-- this will become a PROMELA_NIL -->
<state id="s0">
+ <!--
+ if _x.states[s0]
+
+ These specialized events will only be dispatched in s0
+ promela-event
+ [ {"name": "e1",
+ "data": { "foo": "some string" }},
+ {"name": "e1",
+ "data": { "bar": 12 }}
+ ]
+ -->
<transition event="e1" cond="_event.data.foo == 'some string'" />
+ <transition event="error.foo" cond="_event.data.foo == 'some string'" />
+ <transition event="error.bar.*" />
+ <transition event="error.baz.*" target="s1" />
<transition event="e1" cond="_event.data.bar == 12" />
+ <invoke type="foo">
+ <!--
+ promela-event
+ [ {"name": "inv1",
+ "data": { "foo": "something else" }},
+ {"name": "inv2",
+ "data": { "baz": 23 }}
+ ]
+ -->
+ </invoke>
</state>
<state id="s1">
- <transition event="e1" cond="_event.data.foo == 'some other string'" />
- <transition event="e1" cond="_event.data.bar == 12" />
+ <!-- This transition will never be enabled -->
+ <transition event="e1" cond="_event.data.bar == 23" />
+ <transition event="e3" cond="bar == 23" />
+ <transition event="e1" />
+ <transition event="e2" />
</state>
-</scxml> \ No newline at end of file
+</scxml>