diff options
Diffstat (limited to 'tests/auto/tools/moc/tst_moc.cpp')
-rw-r--r-- | tests/auto/tools/moc/tst_moc.cpp | 50 |
1 files changed, 39 insertions, 11 deletions
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 0f801fe902..cc465a213a 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -41,7 +41,6 @@ #include "single_function_keyword.h" #include "backslash-newlines.h" #include "slots-with-void-template.h" -#include "pure-virtual-signals.h" #include "qinvokable.h" // msvc and friends crap out on it #if !defined(Q_CC_GNU) || defined(Q_OS_WIN) @@ -62,6 +61,7 @@ #include "cxx11-enums.h" #include "cxx11-final-classes.h" #include "cxx11-explicit-override-control.h" +#include "cxx11-trailing-return.h" #include "parse-defines.h" #include "related-metaobjects-in-namespaces.h" @@ -630,7 +630,6 @@ public: private slots: void initTestCase(); - void slotWithException() throw(MyStruct); void dontStripNamespaces(); void oldStyleCasts(); void warnOnExtraSignalSlotQualifiaction(); @@ -687,6 +686,7 @@ private slots: void privateClass(); void cxx11Enums_data(); void cxx11Enums(); + void cxx11TrailingReturn(); void returnRefs(); void memberProperties_data(); void memberProperties(); @@ -782,12 +782,6 @@ void tst_Moc::initTestCase() #endif } -void tst_Moc::slotWithException() throw(MyStruct) -{ - // be happy - QVERIFY(true); -} - void tst_Moc::dontStripNamespaces() { Sender sender; @@ -1593,7 +1587,7 @@ void tst_Moc::qprivateproperties() #include "task189996.h" -void InlineSlotsWithThrowDeclaration::c() throw() {} +void InlineSlotsWithThrowDeclaration::c() noexcept {} void tst_Moc::inlineSlotsWithThrowDeclaration() { @@ -1602,8 +1596,6 @@ void tst_Moc::inlineSlotsWithThrowDeclaration() QVERIFY(mobj->indexOfSlot("a()") != -1); QVERIFY(mobj->indexOfSlot("b()") != -1); QVERIFY(mobj->indexOfSlot("c()") != -1); - QVERIFY(mobj->indexOfSlot("d()") != -1); - QVERIFY(mobj->indexOfSlot("e()") != -1); } void tst_Moc::warnOnPropertyWithoutREAD() @@ -2200,6 +2192,30 @@ void tst_Moc::warnings_data() << QString() << QString("standard input:2: Error: Plugin Metadata file \"does.not.exists\" does not exist. Declaration will be ignored"); + QTest::newRow("Auto-declared, missing trailing return") + << QByteArray("class X { \n public slots: \n auto fun() { return 1; } };") + << QStringList() + << 1 + << QString() + << QString("standard input:3: Error: Function declared with auto as return type but missing trailing return type. Return type deduction is not supported."); + + QTest::newRow("Auto-declared, volatile auto as trailing return type") + << QByteArray("class X { \n public slots: \n auto fun() -> volatile auto { return 1; } };") + << QStringList() + << 1 + << QString() + << QString("standard input:3: Error: Function declared with auto as return type but missing trailing return type. Return type deduction is not supported."); + + // We don't currently support the decltype keyword, so it's not the same error as above. + // The test is just here to make sure this keeps generating an error until return type deduction + // is supported. + QTest::newRow("Auto-declared, decltype in trailing return type") + << QByteArray("class X { \n public slots: \n auto fun() -> decltype(0+1) { return 1; } };") + << QStringList() + << 1 + << QString() + << QString("standard input:3: Parse error at \"decltype\""); + #ifdef Q_OS_LINUX // Limit to Linux because the error message is platform-dependent QTest::newRow("Q_PLUGIN_METADATA: unreadable file") << QByteArray("class X { \n Q_PLUGIN_METADATA(FILE \".\") \n };") @@ -2329,6 +2345,18 @@ void tst_Moc::cxx11Enums() QCOMPARE(meta->enumerator(idx).isScoped(), isScoped); } +void tst_Moc::cxx11TrailingReturn() +{ + CXX11TrailingReturn retClass; + const QMetaObject *mobj = retClass.metaObject(); + QVERIFY(mobj->indexOfSlot("fun()") != -1); + QVERIFY(mobj->indexOfSlot("arguments(int,char)") != -1); + QVERIFY(mobj->indexOfSlot("inlineFunc(int)") != -1); + QVERIFY(mobj->indexOfSlot("constRefReturn()") != -1); + QVERIFY(mobj->indexOfSlot("constConstRefReturn()") != -1); + QVERIFY(mobj->indexOfSignal("trailingSignalReturn(int)") != -1); +} + void tst_Moc::returnRefs() { TestClass tst; |