diff options
author | Jarek Kobus <jaroslaw.kobus@theqtcompany.com> | 2016-01-28 10:32:05 +0100 |
---|---|---|
committer | Jarek Kobus <jaroslaw.kobus@theqtcompany.com> | 2016-04-14 10:08:22 +0000 |
commit | 14c1090c89bba1af881d568274d4f1b9fe5f8a28 (patch) | |
tree | 5c04b1eb0176557cc945da95af387d07a4e32094 /tests | |
parent | 181928775bb5456c88e0528c639274bc7da259c2 (diff) |
Detect clashes in event and state names
Change-Id: I6df9f73965442b7866c8912ac8a0a0858640bb62
Reviewed-by: Ulf Hermann <ulf.hermann@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/parser/qtmode.scxml | 46 | ||||
-rw-r--r-- | tests/auto/parser/tst_parser.cpp | 80 | ||||
-rw-r--r-- | tests/auto/parser/tst_parser.qrc | 1 |
3 files changed, 105 insertions, 22 deletions
diff --git a/tests/auto/parser/qtmode.scxml b/tests/auto/parser/qtmode.scxml new file mode 100644 index 0000000..c5df8b0 --- /dev/null +++ b/tests/auto/parser/qtmode.scxml @@ -0,0 +1,46 @@ +<?xml version="1.0" ?> +<!-- +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtScxml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +--> +<!-- enable-qt-mode: yes --> +<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" + name="test1"> + <state id="a"> + <transition event="a"/> + <transition event="void"/> + <transition event="aChanged"/> + <transition event="finished"/> + <transition event="done.state.a"/> + <transition event="done.state.double"/> + </state> + <state id="int"/> + <state id="objectName"/> + <state id="foo"/> + <state id="fooChanged"/> +</scxml> diff --git a/tests/auto/parser/tst_parser.cpp b/tests/auto/parser/tst_parser.cpp index 68ca9db..e00b8b6 100644 --- a/tests/auto/parser/tst_parser.cpp +++ b/tests/auto/parser/tst_parser.cpp @@ -49,28 +49,64 @@ void tst_Parser::error_data() QTest::addColumn<QVector<QScxmlError> >("expectedErrors"); QVector<QScxmlError> errors; - errors << QScxmlError(QString(":/tst_parser/test1.scxml"), 34, 46, - QString("unknown state 'b' in target")); - QTest::newRow("test1") << QString(":/tst_parser/test1.scxml") << errors; - - QTest::newRow("namespaces 1") << QStringLiteral(":/tst_parser/namespaces1.scxml") - << QVector<QScxmlError>(); - QTest::newRow("IDs 1") << QStringLiteral(":/tst_parser/ids1.scxml") << QVector<QScxmlError>(); - QTest::newRow("IDs 2") << QStringLiteral(":/tst_parser/ids2.scxml") << (QVector<QScxmlError>() - << QScxmlError(":/tst_parser/ids2.scxml", 33, 25, - "state id 'foo.bar' is not a valid C++ identifier in Qt mode") - << QScxmlError(":/tst_parser/ids2.scxml", 34, 25, - "state id 'foo-bar' is not a valid C++ identifier in Qt mode") - << QScxmlError(":/tst_parser/ids2.scxml", 36, 19, "'1' is not a valid XML ID") - ); - QTest::newRow("eventnames") << QStringLiteral(":/tst_parser/eventnames.scxml") - << (QVector<QScxmlError>() - << QScxmlError(":/tst_parser/eventnames.scxml", 50, 38, "'.invalid' is not a valid event") - << QScxmlError(":/tst_parser/eventnames.scxml", 51, 38, "'invalid.' is not a valid event") - << QScxmlError(":/tst_parser/eventnames.scxml", 39, 36, "'.invalid' is not a valid event") - << QScxmlError(":/tst_parser/eventnames.scxml", 40, 36, "'invalid.' is not a valid event") - << QScxmlError(":/tst_parser/eventnames.scxml", 41, 36, "'in valid' is not a valid event") - ); + QString filename; + + filename = QLatin1String(":/tst_parser/test1.scxml"); + errors.clear(); + errors << QScxmlError(filename, 34, 46, + QLatin1String("unknown state 'b' in target")); + QTest::newRow("test1") << filename << errors; + + filename = QLatin1String(":/tst_parser/namespaces1.scxml"); + errors.clear(); + QTest::newRow("namespaces 1") << filename << errors; + + filename = QLatin1String(":/tst_parser/ids1.scxml"); + errors.clear(); + QTest::newRow("IDs 1") << filename << errors; + + filename = QLatin1String(":/tst_parser/ids2.scxml"); + errors.clear(); + errors << QScxmlError(filename, 33, 25, + QLatin1String("state name 'foo.bar' is not a valid C++ identifier in Qt mode")); + errors << QScxmlError(filename, 34, 25, + QLatin1String("state name 'foo-bar' is not a valid C++ identifier in Qt mode")); + errors << QScxmlError(filename, 36, 19, + QLatin1String("'1' is not a valid XML ID")); + + QTest::newRow("IDs 2") << filename << errors; + + filename = QLatin1String(":/tst_parser/eventnames.scxml"); + errors.clear(); + errors << QScxmlError(filename, 50, 38, + QLatin1String("'.invalid' is not a valid event")); + errors << QScxmlError(filename, 51, 38, + QLatin1String("'invalid.' is not a valid event")); + errors << QScxmlError(filename, 39, 36, + QLatin1String("'.invalid' is not a valid event")); + errors << QScxmlError(filename, 40, 36, + QLatin1String("'invalid.' is not a valid event")); + errors << QScxmlError(filename, 41, 36, + QLatin1String("'in valid' is not a valid event")); + QTest::newRow("eventnames") << filename << errors; + + filename = QString(":/tst_parser/qtmode.scxml"); + errors.clear(); + errors << QScxmlError(filename, 35, 31, + QLatin1String("event name 'a' collides with a state name 'a' in Qt mode")); + errors << QScxmlError(filename, 36, 34, + QLatin1String("event name 'void' is not a valid C++ identifier in Qt mode")); + errors << QScxmlError(filename, 37, 38, + QLatin1String("event name 'aChanged' collides with a state name 'a' in Qt mode")); + errors << QScxmlError(filename, 38, 38, + QLatin1String("event name 'finished' is not a valid Qt identifier in Qt mode")); + errors << QScxmlError(filename, 42, 21, + QLatin1String("state name 'int' is not a valid C++ identifier in Qt mode")); + errors << QScxmlError(filename, 43, 28, + QLatin1String("state name 'objectName' is not a valid Qt identifier in Qt mode")); + errors << QScxmlError(filename, 45, 28, + QLatin1String("state name 'fooChanged' collides with a state name 'foo' in Qt mode")); + QTest::newRow("qtmode") << filename << errors; } void tst_Parser::error() diff --git a/tests/auto/parser/tst_parser.qrc b/tests/auto/parser/tst_parser.qrc index 3c6c944..9073f0d 100644 --- a/tests/auto/parser/tst_parser.qrc +++ b/tests/auto/parser/tst_parser.qrc @@ -5,5 +5,6 @@ <file>ids1.scxml</file> <file>ids2.scxml</file> <file>eventnames.scxml</file> + <file>qtmode.scxml</file> </qresource> </RCC> |