summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@theqtcompany.com>2016-05-04 16:02:06 +0200
committerJarek Kobus <jaroslaw.kobus@qt.io>2016-05-20 11:09:03 +0000
commit3277abece0c1c258cd2fcbdb3044b9c64b0ccfef (patch)
treed57c11c39fc10e735fc3d731940b8fc5dafd7ff3 /tests
parent6b1884cac1e54b6aa6fd19daf354ee07eeb6379b (diff)
Refactor parser, parse recursively now
Splits the parsering function into several smaller functions per element kind. Fixes parsing of 11 scion tests. Fixes parsing of non-terminated comment inside <script> element. Change-Id: I1d82c3164415a71e69e90bc6d3b96bda67dabb6c Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qscxmlc/data/commentInScript.scxml19
-rw-r--r--tests/auto/qscxmlc/tst_qscxmlc.qrc1
-rw-r--r--tests/auto/scion/tst_scion.cpp61
3 files changed, 54 insertions, 27 deletions
diff --git a/tests/auto/qscxmlc/data/commentInScript.scxml b/tests/auto/qscxmlc/data/commentInScript.scxml
new file mode 100644
index 0000000..2af8286
--- /dev/null
+++ b/tests/auto/qscxmlc/data/commentInScript.scxml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- enable-qt-mode: yes -->
+<scxml
+ xmlns="http://www.w3.org/2005/07/scxml"
+ version="1.0"
+ name="CommentInScript"
+ datamodel="ecmascript"
+>
+ <datamodel>
+ <data id="media"/>
+ </datamodel>
+
+ <script><!--
+ function isValidMedia() {
+ var m = _event.data.media
+ return (m + "").length > 0
+ }
+ <initial>
+</scxml>
diff --git a/tests/auto/qscxmlc/tst_qscxmlc.qrc b/tests/auto/qscxmlc/tst_qscxmlc.qrc
index d6b8a6a..a86c786 100644
--- a/tests/auto/qscxmlc/tst_qscxmlc.qrc
+++ b/tests/auto/qscxmlc/tst_qscxmlc.qrc
@@ -1,5 +1,6 @@
<RCC>
<qresource prefix="/tst_qscxmlc">
+ <file>data/commentInScript.scxml</file>
<file>data/empty.scxml</file>
<file>data/misplacedinvoke.scxml</file>
<file>data/invalidRoot.scxml</file>
diff --git a/tests/auto/scion/tst_scion.cpp b/tests/auto/scion/tst_scion.cpp
index 92dc291..0e017c7 100644
--- a/tests/auto/scion/tst_scion.cpp
+++ b/tests/auto/scion/tst_scion.cpp
@@ -43,7 +43,17 @@ Q_DECLARE_METATYPE(std::function<QScxmlStateMachine *()>);
enum { SpyWaitTime = 12000 };
-static QSet<QString> weFailOnThese = QSet<QString>()
+static QSet<QString> testFailOnParse = QSet<QString>()
+ // Currently we do not support loading data as XML content inside the <data> tag.
+ << QLatin1String("w3c-ecma/test557.txml")
+ // The following test uses the undocumented "exmode" attribute.
+ << QLatin1String("w3c-ecma/test441a.txml")
+ // The following test needs manual inspection of the result. However, note that we do not support the undocumented "exmode" attribute.
+ << QLatin1String("w3c-ecma/test441b.txml")
+ // The following test needs manual inspection of the result.
+ ;
+
+static QSet<QString> testFailOnRun = QSet<QString>()
// The following test needs manual inspection of the result. However, note that we do not support multiple identical keys for event data.
<< QLatin1String("delayedSend/send1") // same as above
<< QLatin1String("delayedSend/send2") // same as above
@@ -54,20 +64,12 @@ static QSet<QString> weFailOnThese = QSet<QString>()
<< QLatin1String("w3c-ecma/test201.txml")
<< QLatin1String("w3c-ecma/test364.txml") // initial attribute on <state>
<< QLatin1String("w3c-ecma/test388.txml") // Qt refuses to set an initial state to a "deep" state
-
- // Currently we do not support loading data as XML content inside the <data> tag.
- << QLatin1String("w3c-ecma/test557.txml")
- // The following test uses the undocumented "exmode" attribute.
- << QLatin1String("w3c-ecma/test441a.txml")
- // The following test needs manual inspection of the result. However, note that we do not support the undocumented "exmode" attribute.
- << QLatin1String("w3c-ecma/test441b.txml")
- // The following test needs manual inspection of the result.
<< QLatin1String("w3c-ecma/test230.txml")
<< QLatin1String("w3c-ecma/test250.txml")
<< QLatin1String("w3c-ecma/test307.txml")
;
-static QSet<QString> differentSemantics = QSet<QString>()
+static QSet<QString> testUseDifferentSemantics = QSet<QString>()
// FIXME: looks like a bug in internal event ordering when writing to read-only variables.
<< QLatin1String("w3c-ecma/test329.txml")
// Qt does not support forcing initial states that are not marked as such.
@@ -165,7 +167,8 @@ void TestScion::initTestCase()
enum TestStatus {
TestIsOk,
- TestFails,
+ TestFailsOnParse,
+ TestFailsOnRun,
TestUsesDifferentSemantics
};
Q_DECLARE_METATYPE(TestStatus)
@@ -181,10 +184,12 @@ void TestScion::generateData()
for (int i = 0; i < nrOfTests; ++i) {
TestStatus testStatus;
QString base = QString::fromUtf8(testBases[i]);
- if (differentSemantics.contains(base))
+ if (testUseDifferentSemantics.contains(base))
testStatus = TestUsesDifferentSemantics;
- else if (weFailOnThese.contains(base))
- testStatus = TestFails;
+ else if (testFailOnParse.contains(base))
+ testStatus = TestFailsOnParse;
+ else if (testFailOnRun.contains(base))
+ testStatus = TestFailsOnRun;
else
testStatus = TestIsOk;
QTest::newRow(testBases[i]) << base + QLatin1String(".scxml")
@@ -226,22 +231,21 @@ void TestScion::dynamic()
DynamicLoader loader(&parser);
parser.setLoader(&loader);
parser.parse();
- if (testStatus == TestFails && parser.state() != QScxmlParser::FinishedParsing)
- QEXPECT_FAIL("", "This is expected to fail", Abort);
- QCOMPARE(parser.state(), QScxmlParser::FinishedParsing);
+ if (testStatus == TestFailsOnParse)
+ QEXPECT_FAIL("", "This is expected to fail on parse", Abort);
QVERIFY(parser.errors().isEmpty());
scxmlFile.close();
QScopedPointer<QScxmlStateMachine> stateMachine(parser.instantiateStateMachine());
- if (stateMachine == Q_NULLPTR && testStatus == TestFails) {
- QEXPECT_FAIL("", "This is expected to fail", Abort);
- }
QVERIFY(stateMachine != Q_NULLPTR);
+
parser.instantiateDataModel(stateMachine.data());
- if (testStatus == TestFails)
- QEXPECT_FAIL("", "This is expected to fail", Abort);
- QVERIFY(runTest(stateMachine.data(), testDescription.object()));
+ const bool runResult = runTest(stateMachine.data(), testDescription.object());
+ if (runResult == false && testStatus == TestFailsOnRun)
+ QEXPECT_FAIL("", "This is expected to fail on run", Abort);
+
+ QVERIFY(runResult);
QCoreApplication::processEvents(); // flush any pending events
}
@@ -279,14 +283,17 @@ void TestScion::compiled()
jsonFile.close();
QScopedPointer<QScxmlStateMachine> stateMachine(creator());
- if (stateMachine == Q_NULLPTR && testStatus == TestFails) {
+ if (stateMachine == Q_NULLPTR && testStatus == TestFailsOnRun) {
QEXPECT_FAIL("", "This is expected to fail", Abort);
}
QVERIFY(stateMachine != Q_NULLPTR);
- if (testStatus == TestFails)
- QEXPECT_FAIL("", "This is expected to fail", Abort);
- QVERIFY(runTest(stateMachine.data(), testDescription.object()));
+ const bool runResult = runTest(stateMachine.data(), testDescription.object());
+ if (runResult == false && testStatus == TestFailsOnRun)
+ QEXPECT_FAIL("", "This is expected to fail on run", Abort);
+
+ QVERIFY(runResult);
+
QCoreApplication::processEvents(); // flush any pending events
}