summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>2014-10-30 13:24:22 +0100
committerJędrzej Nowacki <jedrzej.nowacki@digia.com>2014-11-11 14:11:40 +0100
commit0c9d1f99dac5c118d49e7f2b04f70eae3ba7b837 (patch)
tree3e4647bbaaeddba0a4054282969e718d0b697c79 /tests
parenta8723871ee7125b97ce5467b94198e93a528c960 (diff)
Fix moc preprocessor
When tokenizing, after macro expansion, moc needs to concatenate subsequent string literals, because parser do not check for such expressions. Change-Id: Icc4f01395a5a7b67368eb8341a45ee74ade7d7f5 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/tools/moc/tst_moc.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp
index 13e786cd20..965a16e7c2 100644
--- a/tests/auto/tools/moc/tst_moc.cpp
+++ b/tests/auto/tools/moc/tst_moc.cpp
@@ -572,6 +572,7 @@ private slots:
void relatedMetaObjectsInGadget();
void relatedMetaObjectsNameConflict_data();
void relatedMetaObjectsNameConflict();
+ void strignLiteralsInMacroExtension();
signals:
void sigWithUnsignedArg(unsigned foo);
@@ -3269,6 +3270,45 @@ void tst_Moc::relatedMetaObjectsNameConflict()
QCOMPARE(dependency.size(), relatedMetaObjects.size());
}
+class StringLiteralsInMacroExtension: public QObject
+{
+ Q_OBJECT
+#define Macro(F) F " " F
+ Q_CLASSINFO(Macro("String"), Macro("Literal"))
+#undef Macro
+
+#define Macro(F) F
+ Q_CLASSINFO("String" Macro("!"), "Literal" Macro("!"))
+ Q_CLASSINFO(Macro("!") "String", Macro("!") "Literal")
+#undef Macro
+
+#define Macro "foo"
+ Q_CLASSINFO("String" Macro, "Literal" Macro)
+ Q_CLASSINFO(Macro "String", Macro "Literal")
+#undef Macro
+};
+
+void tst_Moc::strignLiteralsInMacroExtension()
+{
+ const QMetaObject *mobj = &StringLiteralsInMacroExtension::staticMetaObject;
+ QCOMPARE(mobj->classInfoCount(), 5);
+
+ QCOMPARE(mobj->classInfo(0).name(), "String String");
+ QCOMPARE(mobj->classInfo(0).value(), "Literal Literal");
+
+ QCOMPARE(mobj->classInfo(1).name(), "String!");
+ QCOMPARE(mobj->classInfo(1).value(), "Literal!");
+
+ QCOMPARE(mobj->classInfo(2).name(), "!String");
+ QCOMPARE(mobj->classInfo(2).value(), "!Literal");
+
+ QCOMPARE(mobj->classInfo(3).name(), "Stringfoo");
+ QCOMPARE(mobj->classInfo(3).value(), "Literalfoo");
+
+ QCOMPARE(mobj->classInfo(4).name(), "fooString");
+ QCOMPARE(mobj->classInfo(4).value(), "fooLiteral");
+}
+
QTEST_MAIN(tst_Moc)
// the generated code must compile with QT_NO_KEYWORDS