diff options
author | Brett Stottlemyer <bstottle@ford.com> | 2018-06-25 11:28:22 -0400 |
---|---|---|
committer | Brett Stottlemyer <bstottle@ford.com> | 2018-06-25 17:18:17 +0000 |
commit | 79e3325887ffdbc012a288729e93601314c8a3b3 (patch) | |
tree | 065cc067e368304e77eced9f963d0c377bb49ce5 /tests | |
parent | a6a1ae26edf829581f025249b634b9a751813cc8 (diff) |
Update parameter list handling
Fix multiline ENUM/POD handling, and allow tabs in parameter lists, to
address a couple of reported bugs.
This will allow multiline Signal/Slot/Prop parameter lists as well. The
enum handling already was set up for multiline processing, the issue was
actually (at least for the test provided) in having whitespace before the
'}' completing the enum. We allow whitespace before '{' and '}' now, too.
Task-number: QTBUG-68975
Task-number: QTBUG-67770
Change-Id: Ic362a3050ba6a6b646bdb9dc8cf28f2f2902b611
Reviewed-by: Michael Brasser <michael.brasser@live.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/repparser/tst_parser.cpp | 48 |
1 files changed, 34 insertions, 14 deletions
diff --git a/tests/auto/repparser/tst_parser.cpp b/tests/auto/repparser/tst_parser.cpp index 46211a2..1e22ebb 100644 --- a/tests/auto/repparser/tst_parser.cpp +++ b/tests/auto/repparser/tst_parser.cpp @@ -120,6 +120,8 @@ void tst_Parser::testProperties_data() QTest::newRow("templatetype") << "PROP(QVector<int> bar)" << "QVector<int>" << "bar" << QString() << ASTProperty::ReadPush << false; QTest::newRow("nested templatetype") << "PROP(QMap<int, QVector<int> > bar)" << "QMap<int, QVector<int> >" << "bar" << QString() << ASTProperty::ReadPush << false; QTest::newRow("non-int default value") << "PROP(double foo=1.1 CONSTANT)" << "double" << "foo" << "1.1" << ASTProperty::Constant << false; + QTest::newRow("tab") << "PROP(double\tfoo)" << "double" << "foo" << "" << ASTProperty::ReadPush << false; + QTest::newRow("two tabs") << "PROP(double\t\tfoo)" << "double" << "foo" << "" << ASTProperty::ReadPush << false; } void tst_Parser::testProperties() @@ -257,6 +259,7 @@ void tst_Parser::testPods_data() QTest::newRow("one pod") << "POD preset(int presetNumber)" << "int" << "presetNumber"; QTest::newRow("two pod") << "POD preset(int presetNumber, double foo)" << "int;double" << "presetNumber;foo"; QTest::newRow("two pod with space") << "POD preset ( int presetNumber , double foo ) " << "int;double" << "presetNumber;foo"; + QTest::newRow("two pod multiline") << "POD preset(\nint presetNumber,\ndouble foo\n)" << "int;double" << "presetNumber;foo"; //Template QTest::newRow("pod template") << "POD preset(QMap<QString,int> foo) " << "QMap<QString,int>" << "foo"; QTest::newRow("pod template (QList)") << "POD preset(QList<QString> foo) " << "QList<QString>" << "foo"; @@ -306,16 +309,23 @@ void tst_Parser::testEnums_data() QTest::addColumn<QList<int> >("expectedvalues"); QTest::addColumn<int>("expectedmax"); QTest::addColumn<bool>("expectedsigned"); - - //Separate by ";" - QTest::newRow("one enum val") << "ENUM preset {presetNumber}" << "presetNumber" << (QList<int>() << 0) << 0 << false; - QTest::newRow("two enum val") << "ENUM preset {presetNumber, foo}" << "presetNumber;foo" << (QList<int>() << 0 << 1) << 1 << false; - QTest::newRow("two enum val -1 2nd") << "ENUM preset {presetNumber, foo = -1}" << "presetNumber;foo" << (QList<int>() << 0 << -1) << 1 << true; - QTest::newRow("two enum val -1 1st") << "ENUM preset {presetNumber=-1, foo}" << "presetNumber;foo" << (QList<int>() << -1 << 0) << 1 << true; - QTest::newRow("two enum val hex") << "ENUM preset {presetNumber=0xf, foo}" << "presetNumber;foo" << (QList<int>() << 15 << 16) << 16 << false; - QTest::newRow("two enum val hex") << "ENUM preset {presetNumber=0xff, foo}" << "presetNumber;foo" << (QList<int>() << 255 << 256) << 256 << false; - QTest::newRow("two enum val with space") << "ENUM preset { presetNumber , foo } " << "presetNumber;foo" << (QList<int>() << 0 << 1) << 1 << false; - QTest::newRow("set values") << "ENUM preset { val1=1 , val3=3, val5=5 } " << "val1;val3;val5" << (QList<int>() << 1 << 3 << 5) << 5 << false; + QTest::addColumn<bool>("inclass"); + + for (int i = 0; i <= 1; ++i) { + bool inclass = i == 1; + QString identifier = inclass ? QLatin1String("%1 in class") : QLatin1String("%1 outside class"); + //Separate by ";" + QTest::newRow(identifier.arg("one enum val").toLatin1()) << "ENUM preset {presetNumber}" << "presetNumber" << (QList<int>() << 0) << 0 << false << inclass; + QTest::newRow(identifier.arg("two enum val").toLatin1()) << "ENUM preset {presetNumber, foo}" << "presetNumber;foo" << (QList<int>() << 0 << 1) << 1 << false << inclass; + QTest::newRow(identifier.arg("two enum val -1 2nd").toLatin1()) << "ENUM preset {presetNumber, foo = -1}" << "presetNumber;foo" << (QList<int>() << 0 << -1) << 1 << true << inclass; + QTest::newRow(identifier.arg("two enum val -1 1st").toLatin1()) << "ENUM preset {presetNumber=-1, foo}" << "presetNumber;foo" << (QList<int>() << -1 << 0) << 1 << true << inclass; + QTest::newRow(identifier.arg("two enum val hex").toLatin1()) << "ENUM preset {presetNumber=0xf, foo}" << "presetNumber;foo" << (QList<int>() << 15 << 16) << 16 << false << inclass; + QTest::newRow(identifier.arg("two enum val hex").toLatin1()) << "ENUM preset {presetNumber=0xff, foo}" << "presetNumber;foo" << (QList<int>() << 255 << 256) << 256 << false << inclass; + QTest::newRow(identifier.arg("two enum val with space").toLatin1()) << "ENUM preset { presetNumber , foo } " << "presetNumber;foo" << (QList<int>() << 0 << 1) << 1 << false << inclass; + QTest::newRow(identifier.arg("set values").toLatin1()) << "ENUM preset { val1=1 , val3=3, val5=5 } " << "val1;val3;val5" << (QList<int>() << 1 << 3 << 5) << 5 << false << inclass; + QTest::newRow(identifier.arg("multiline").toLatin1()) << "ENUM preset {\nval1,\nval2,\nval3\n} " << "val1;val2;val3" << (QList<int>() << 0 << 1 << 2) << 2 << false << inclass; + QTest::newRow(identifier.arg("multiline indented").toLatin1()) << " ENUM preset {\n val1,\n val2,\n val3\n } " << "val1;val2;val3" << (QList<int>() << 0 << 1 << 2) << 2 << false << inclass; + } } void tst_Parser::testEnums() @@ -325,13 +335,17 @@ void tst_Parser::testEnums() QFETCH(QList<int>, expectedvalues); QFETCH(int, expectedmax); QFETCH(bool, expectedsigned); + QFETCH(bool, inclass); QTemporaryFile file; file.open(); QTextStream stream(&file); - stream << enumdeclaration << endl; + if (!inclass) + stream << enumdeclaration << endl; stream << "class TestClass" << endl; stream << "{" << endl; + if (inclass) + stream << enumdeclaration << endl; stream << "};" << endl; file.seek(0); @@ -340,9 +354,15 @@ void tst_Parser::testEnums() const AST ast = parser.ast(); QCOMPARE(ast.classes.count(), 1); - - QCOMPARE(ast.enums.count(), 1); - const ASTEnum enums = ast.enums.first(); + ASTEnum enums; + if (inclass) { + const ASTClass astClass = ast.classes.first(); + QCOMPARE(astClass.enums.count(), 1); + enums = astClass.enums.first(); + } else { + QCOMPARE(ast.enums.count(), 1); + enums = ast.enums.first(); + } const QVector<ASTEnumParam> paramList = enums.params; const QStringList nameList = expectednames.split(QLatin1Char(';')); QVERIFY(nameList.count() == expectedvalues.count()); |