From 48009e6bafca54d117bee81ea2a8b41f2aae1d70 Mon Sep 17 00:00:00 2001 From: Stefan Radomski Date: Fri, 5 Apr 2013 14:24:46 +0200 Subject: Redownloaded tests and fixed some more w3c issues --- README.md | 39 +++++++++++++++++++--- src/uscxml/Factory.h | 5 +++ src/uscxml/Interpreter.cpp | 27 +++++++++++++-- src/uscxml/Message.h | 2 +- src/uscxml/interpreter/InterpreterDraft6.cpp | 4 ++- .../datamodel/ecmascript/v8/V8DataModel.cpp | 38 ++++++++++++++------- .../plugins/datamodel/ecmascript/v8/V8DataModel.h | 3 ++ src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp | 2 +- test/samples/w3c/tests/test153.scxml | 2 +- test/samples/w3c/tests/test224.scxml | 4 +-- test/samples/w3c/tests/test226.scxml | 2 +- test/samples/w3c/tests/test301.scxml | 2 +- test/samples/w3c/tests/test302.scxml | 2 +- test/samples/w3c/tests/test303.scxml | 2 +- test/samples/w3c/tests/test304.scxml | 2 +- test/samples/w3c/tests/test307.scxml | 2 +- test/samples/w3c/tests/test321.scxml | 2 +- test/samples/w3c/tests/test322.scxml | 7 +--- test/samples/w3c/tests/test323.scxml | 2 +- test/samples/w3c/tests/test330.scxml | 6 ++-- test/samples/w3c/tests/test403c.scxml | 2 +- test/samples/w3c/tests/test539.txt | 4 +++ test/samples/w3c/tests/test540.txt | 3 ++ test/samples/w3c/tests/test552.txt | 2 +- test/samples/w3c/txml/test216sub1.txml.1 | 9 ----- test/samples/w3c/txml/test277.txml | 32 ++++++++++++++++++ test/samples/w3c/txml/test561.txml | 4 +-- test/samples/w3c/txml/test568.txml | 19 +++++++++++ test/samples/w3c/update-txml.sh | 3 +- 29 files changed, 177 insertions(+), 56 deletions(-) create mode 100644 test/samples/w3c/tests/test539.txt create mode 100644 test/samples/w3c/tests/test540.txt delete mode 100644 test/samples/w3c/txml/test216sub1.txml.1 create mode 100644 test/samples/w3c/txml/test277.txml create mode 100644 test/samples/w3c/txml/test568.txml diff --git a/README.md b/README.md index 679c947..df56af6 100644 --- a/README.md +++ b/README.md @@ -33,8 +33,12 @@ the respective build-process. - + + + + + @@ -44,11 +48,23 @@ the respective build-process. is considered non-conformant, and the platform must reject it" -- USCXML will try to evaluate the rest of the document nevertheless. + + + + + + - + + + + + + scope that only lasts for one event + + @@ -59,7 +75,22 @@ the respective build-process. - + + + + + + + + + + + + + + + +
Test#StatusComment
178Failed / Won't fix
153Failed / Fix in testThe XSLT transformation leave some gibberish in the file
178Failed / Fix in draft A manual test that relies on an unspecified _event.raw attribute
226Failed / Fix in testRequires a file with wrong file extension
230False report A manual test that is not actually failing but does not end in a state called pass
250False report
302Failed / Fix in testdatamodel attribute is missing from test
303Failed / Fix in testdatamodel attribute is missing from test
304Failed / Fix in testdatamodel attribute is missing from test
307False report A manual test that is not actually failing but does not end in a state called pass
329Failed / Won't fix
321Failed / Fix in testGibberish form XSLT transformation still inside $_sessionid
323Failed / Fix in testGibberish form XSLT transformation still inside $_name
329Failed / Raise on ML Tests that _event cannot be assigned, but I like to add attributes to _event to have a - scope that only lasts for one event. Will raise the issue on the ML.
330FailedNamespace issues
333Failed / Won't fix "sendid [...] Otherwise it must leave it blank." -- USCXML sets this to the empty string instead of null.
335Failed / Won't fix"invokeid [...] Otherwise it must leave it blank." -- USCXML sets this to the empty string instead of null.
346Failed / Won't fix "test that any attempt to change the value of a system variable causes error.execution to be raised." -- I like to edit _event.
436Failed / Won't fixRequires NULL datamodel
441bFailed / Won't fixRequires NULL datamodel
456Failed / Raise on MLExpects undefined + 1 to be 1
463 - 486bFailed / Won't fixRequires xpath datamodel
488Failed / Raise on MLExpects _event.data to be the empty string when we have it as undefined
537 - 547Failed / Won't fixRequires xpath datamodel
555Failed / Won't fixRequires xpath datamodel
569FailedSCXML I/O processor is implicit at the moment
diff --git a/src/uscxml/Factory.h b/src/uscxml/Factory.h index 65dc5fd..990b035 100644 --- a/src/uscxml/Factory.h +++ b/src/uscxml/Factory.h @@ -243,6 +243,7 @@ public: virtual void eval(const std::string& expr) = 0; virtual std::string evalAsString(const std::string& expr) = 0; virtual bool evalAsBool(const std::string& expr) = 0; + virtual void assign(const std::string& location, const Arabica::DOM::Document& doc) = 0; virtual void assign(const std::string& location, const std::string& expr) = 0; virtual void assign(const std::string& location, const Data& data) = 0; virtual bool isDeclared(const std::string& expr) = 0; @@ -305,6 +306,10 @@ public: return _impl->evalAsBool(expr); } + virtual void assign(const std::string& location, const Arabica::DOM::Document& doc) { + return _impl->assign(location, doc); + } + virtual void assign(const std::string& location, const std::string& expr) { return _impl->assign(location, expr); } diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp index 5f54cc7..86f40c1 100644 --- a/src/uscxml/Interpreter.cpp +++ b/src/uscxml/Interpreter.cpp @@ -289,9 +289,12 @@ void Interpreter::init() { } else { LOG(ERROR) << "Cannot find SCXML element" << std::endl; + _done = true; + return; } } else { LOG(ERROR) << "Interpreter has no DOM at all!" << std::endl; + _done = true; } _isInitialized = true; } @@ -353,12 +356,27 @@ void Interpreter::initializeData(const Node& data) { _cachedURLs[srcURL.asString()] = srcURL; } contentToProcess = ss.str(); + + // try to parse as XML + std::stringstream* xmlStr = new std::stringstream(); + (*xmlStr) << contentToProcess; + std::auto_ptr ssPtr(xmlStr); + Arabica::SAX::InputSource inputSource; + inputSource.setByteStream(ssPtr); + Arabica::SAX2DOM::Parser parser; + if(parser.parse(inputSource) && parser.getDocument()) { + _dataModel.assign(ATTR(data, "id"), parser.getDocument()); + return; + } } else if (data.hasChildNodes()) { bool presentAsDom = false; Node contentChild = data.getFirstChild(); while(contentChild) { if (contentChild.getNodeType() == Node_base::TEXT_NODE) { - break; + std::string trimmed = contentChild.getNodeValue(); + boost::trim(trimmed); + if (trimmed.length() > 0) + break; } if (contentChild.getNodeType() == Node_base::ELEMENT_NODE) { presentAsDom = true; @@ -368,7 +386,12 @@ void Interpreter::initializeData(const Node& data) { } if (contentChild && presentAsDom) { - LOG(ERROR) << "Passing DOM in data is TODO."; + Arabica::DOM::DOMImplementation domFactory = Arabica::SimpleDOM::DOMImplementation::getDOMImplementation(); + Document dom = domFactory.createDocument(contentChild.getNamespaceURI(), "", 0); + Node newNode = dom.importNode(contentChild, true); + dom.appendChild(newNode); + _dataModel.assign(ATTR(data, "id"), dom); + return; } else if (contentChild) { // get first child and process below contentToProcess = contentChild.getNodeValue(); diff --git a/src/uscxml/Message.h b/src/uscxml/Message.h index 19adf99..ae88225 100644 --- a/src/uscxml/Message.h +++ b/src/uscxml/Message.h @@ -28,7 +28,7 @@ public: Data() {} Data(const std::string& atom_, Type type_ = INTERPRETED) : atom(atom_), type(type_) {} - Data(const Arabica::DOM::Node& dom); + explicit Data(const Arabica::DOM::Node& dom); virtual ~Data() {} static Data fromJSON(const std::string& jsonString); diff --git a/src/uscxml/interpreter/InterpreterDraft6.cpp b/src/uscxml/interpreter/InterpreterDraft6.cpp index 453e64f..2f05be9 100644 --- a/src/uscxml/interpreter/InterpreterDraft6.cpp +++ b/src/uscxml/interpreter/InterpreterDraft6.cpp @@ -13,8 +13,10 @@ void InterpreterDraft6::interpret() { if (!_isInitialized) init(); - if (!_scxml) + if (!_scxml) { + _mutex.unlock(); return; + } // dump(); if (_sessionId.length() == 0) diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp index e86472b..1d01e12 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp @@ -99,6 +99,7 @@ v8::Handle V8DataModel::getIOProcessors(v8::Local propert std::map ioProcessors = dataModel->_interpreter->getIOProcessors(); std::map::const_iterator ioProcIter = ioProcessors.begin(); while(ioProcIter != ioProcessors.end()) { + std::cout << ioProcIter->first << std::endl; dataModel->_ioProcessors->Set(v8::String::New(ioProcIter->first.c_str()), dataModel->getDataAsValue(ioProcIter->second.getDataModelVariables())); ioProcIter++; @@ -143,18 +144,7 @@ void V8DataModel::setEvent(const Event& event) { eventObj->SetInternalField(0, Arabica::DOM::V8DOM::toExternal(privData)); eventObj.MakeWeak(0, Arabica::DOM::V8SCXMLEvent::jsDestructor); if (event.dom) { - // _event.data is a DOM document - v8::Handle retCtor = Arabica::DOM::V8Document::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); - - struct Arabica::DOM::V8Document::V8DocumentPrivate* retPrivData = new Arabica::DOM::V8Document::V8DocumentPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = (Arabica::DOM::Document*)&event.dom; - - retObj->SetInternalField(0, Arabica::DOM::V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, Arabica::DOM::V8Document::jsDestructor); - - eventObj->Set(v8::String::New("data"), retObj); + eventObj->Set(v8::String::New("data"), getDocumentAsValue(event.dom)); } else if (event.content.length() > 0) { // _event.data is a string eventObj->Set(v8::String::New("data"), v8::String::New(event.content.c_str())); @@ -253,6 +243,20 @@ Data V8DataModel::getValueAsData(const v8::Handle& value) { return data; } +v8::Handle V8DataModel::getDocumentAsValue(const Arabica::DOM::Document& doc) { + v8::Handle retCtor = Arabica::DOM::V8Document::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + + struct Arabica::DOM::V8Document::V8DocumentPrivate* retPrivData = new Arabica::DOM::V8Document::V8DocumentPrivate(); + retPrivData->dom = _dom; + retPrivData->nativeObj = new Arabica::DOM::Document(doc); + + retObj->SetInternalField(0, Arabica::DOM::V8DOM::toExternal(retPrivData)); + retObj.MakeWeak(0, Arabica::DOM::V8Document::jsDestructor); + + return retObj; +} + v8::Handle V8DataModel::getDataAsValue(const Data& data) { if (data.compound.size() > 0) { v8::Handle value = v8::Object::New(); @@ -385,6 +389,16 @@ double V8DataModel::evalAsNumber(const std::string& expr) { return 0; } +void V8DataModel::assign(const std::string& location, const Arabica::DOM::Document& doc) { + v8::Locker locker; + v8::HandleScope handleScope; + v8::Context::Scope contextScope(_contexts.front()); + v8::Handle global = _contexts.front()->Global(); + + global->Set(v8::String::New(location.c_str()), getDocumentAsValue(doc)); + +} + void V8DataModel::assign(const std::string& location, const Data& data) { v8::Locker locker; v8::HandleScope handleScope; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h index 6348cbc..e67e4ca 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h @@ -40,11 +40,13 @@ public: virtual void popContext(); virtual void eval(const std::string& expr); + virtual void assign(const std::string& location, const Arabica::DOM::Document& doc); virtual void assign(const std::string& location, const std::string& expr); virtual void assign(const std::string& location, const Data& data); virtual Data getStringAsData(const std::string& content); virtual Data getValueAsData(const v8::Handle& value); + virtual bool isDeclared(const std::string& expr); virtual std::string evalAsString(const std::string& expr); @@ -66,6 +68,7 @@ protected: v8::Handle evalAsValue(const std::string& expr); v8::Handle getDataAsValue(const Data& data); + v8::Handle getDocumentAsValue(const Arabica::DOM::Document& doc); void throwExceptionEvent(const v8::TryCatch& tryCatch); }; diff --git a/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp b/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp index bbd2538..a142231 100644 --- a/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp +++ b/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp @@ -49,7 +49,7 @@ void USCXMLInvoker::invoke(const InvokeRequest& req) { } else if (req.dom) { _invokedInterpreter = Interpreter::fromDOM(req.dom); } else if (req.content.size() > 0) { - LOG(ERROR) << "Instantiating nested SCXML interpreter by content not supported yet"; + LOG(ERROR) << "Instantiating nested SCXML interpreter by content or expr not supported yet"; } else { LOG(ERROR) << "Cannot invoke nested SCXML interpreter, neither src attribute nor DOM is given"; } diff --git a/test/samples/w3c/tests/test153.scxml b/test/samples/w3c/tests/test153.scxml index c904232..9917789 100644 --- a/test/samples/w3c/tests/test153.scxml +++ b/test/samples/w3c/tests/test153.scxml @@ -13,7 +13,7 @@ it ever isn't, set Var4 to 0, indicating failure --> - + diff --git a/test/samples/w3c/tests/test224.scxml b/test/samples/w3c/tests/test224.scxml index 585d014..e2e8a32 100644 --- a/test/samples/w3c/tests/test224.scxml +++ b/test/samples/w3c/tests/test224.scxml @@ -22,9 +22,7 @@ - - - + diff --git a/test/samples/w3c/tests/test226.scxml b/test/samples/w3c/tests/test226.scxml index e1c6d3f..c831a1d 100644 --- a/test/samples/w3c/tests/test226.scxml +++ b/test/samples/w3c/tests/test226.scxml @@ -9,7 +9,7 @@ success. otherwise it will hang and the timeout in this doc signifies failure. - + diff --git a/test/samples/w3c/tests/test301.scxml b/test/samples/w3c/tests/test301.scxml index 1c25c6d..59125c8 100644 --- a/test/samples/w3c/tests/test301.scxml +++ b/test/samples/w3c/tests/test301.scxml @@ -1,5 +1,5 @@ +Therefore we fail if it runs at all. This test is valid only for datamodels that support scripting --> diff --git a/test/samples/w3c/tests/test303.scxml b/test/samples/w3c/tests/test303.scxml index 2fa5b27..dcb3490 100644 --- a/test/samples/w3c/tests/test303.scxml +++ b/test/samples/w3c/tests/test303.scxml @@ -1,5 +1,5 @@ +right point. This test is valid only for datamodels that support scripting --> diff --git a/test/samples/w3c/tests/test304.scxml b/test/samples/w3c/tests/test304.scxml index 250d0cd..cdb4c22 100644 --- a/test/samples/w3c/tests/test304.scxml +++ b/test/samples/w3c/tests/test304.scxml @@ -1,4 +1,4 @@ - + diff --git a/test/samples/w3c/tests/test307.scxml b/test/samples/w3c/tests/test307.scxml index 6eff148..3f93f10 100644 --- a/test/samples/w3c/tests/test307.scxml +++ b/test/samples/w3c/tests/test307.scxml @@ -1,4 +1,4 @@ - + - + diff --git a/test/samples/w3c/tests/test322.scxml b/test/samples/w3c/tests/test322.scxml index 2c7f536..2d0fee1 100644 --- a/test/samples/w3c/tests/test322.scxml +++ b/test/samples/w3c/tests/test322.scxml @@ -12,9 +12,7 @@ be assigned to --> - - @@ -25,10 +23,7 @@ be assigned to --> - - - - + diff --git a/test/samples/w3c/tests/test323.scxml b/test/samples/w3c/tests/test323.scxml index 43fa9c8..01ca4cb 100644 --- a/test/samples/w3c/tests/test323.scxml +++ b/test/samples/w3c/tests/test323.scxml @@ -1,6 +1,6 @@ - + diff --git a/test/samples/w3c/tests/test330.scxml b/test/samples/w3c/tests/test330.scxml index 5488f96..5cbf4bc 100644 --- a/test/samples/w3c/tests/test330.scxml +++ b/test/samples/w3c/tests/test330.scxml @@ -1,4 +1,4 @@ - + @@ -17,7 +17,7 @@ - - + + \ No newline at end of file diff --git a/test/samples/w3c/tests/test403c.scxml b/test/samples/w3c/tests/test403c.scxml index c02425d..9e7fd12 100644 --- a/test/samples/w3c/tests/test403c.scxml +++ b/test/samples/w3c/tests/test403c.scxml @@ -6,7 +6,7 @@ - + diff --git a/test/samples/w3c/tests/test539.txt b/test/samples/w3c/tests/test539.txt new file mode 100644 index 0000000..de1b0a1 --- /dev/null +++ b/test/samples/w3c/tests/test539.txt @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/test/samples/w3c/tests/test540.txt b/test/samples/w3c/tests/test540.txt new file mode 100644 index 0000000..2191239 --- /dev/null +++ b/test/samples/w3c/tests/test540.txt @@ -0,0 +1,3 @@ +123 +4 5 + \ No newline at end of file diff --git a/test/samples/w3c/tests/test552.txt b/test/samples/w3c/tests/test552.txt index 0cfbf08..d8263ee 100644 --- a/test/samples/w3c/tests/test552.txt +++ b/test/samples/w3c/tests/test552.txt @@ -1 +1 @@ -2 +2 \ No newline at end of file diff --git a/test/samples/w3c/txml/test216sub1.txml.1 b/test/samples/w3c/txml/test216sub1.txml.1 deleted file mode 100644 index eb4c9df..0000000 --- a/test/samples/w3c/txml/test216sub1.txml.1 +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/test/samples/w3c/txml/test277.txml b/test/samples/w3c/txml/test277.txml new file mode 100644 index 0000000..bd08341 --- /dev/null +++ b/test/samples/w3c/txml/test277.txml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/samples/w3c/txml/test561.txml b/test/samples/w3c/txml/test561.txml index 221145c..4b7ec8e 100644 --- a/test/samples/w3c/txml/test561.txml +++ b/test/samples/w3c/txml/test561.txml @@ -1,6 +1,6 @@ - + diff --git a/test/samples/w3c/txml/test568.txml b/test/samples/w3c/txml/test568.txml new file mode 100644 index 0000000..ab00644 --- /dev/null +++ b/test/samples/w3c/txml/test568.txml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/samples/w3c/update-txml.sh b/test/samples/w3c/update-txml.sh index dab3cf3..6cf9c01 100755 --- a/test/samples/w3c/update-txml.sh +++ b/test/samples/w3c/update-txml.sh @@ -1,4 +1,5 @@ #!/bin/bash -wget -rl1 http://www.w3.org/Voice/2013/scxml-irp/ +wget -rl1 -Atxml,txt http://www.w3.org/Voice/2013/scxml-irp/ find ./www.w3.org -name *.txml -exec cp {} ./txml \; +find ./www.w3.org -name *.txt -exec cp {} ./txml \; rm -rf www.w3.org \ No newline at end of file -- cgit v0.12