Fixed tst_qobject::property for clang
authorRohan McGovern <rohan.mcgovern@nokia.com>
Wed, 8 Feb 2012 06:56:38 +0000 (16:56 +1000)
committerQt by Nokia <qt-info@nokia.com>
Thu, 9 Feb 2012 09:45:38 +0000 (10:45 +0100)
The test was failing at:

  QCOMPARE(property.userType(), qMetaTypeId<CustomType*>());

The CustomType* metatype was not registered before this part of the
test.

qMetaTypeId<T> will register the metatype for T before returning it if
it is not yet registered, while QMetaProperty::userType() returns 0 if
the metatype is not yet registered.  However, the order of evaluation of
these two expressions in the above statement is technically undefined.

Apparently, gcc evaluates the arguments in order from right to left,
allowing the test to pass, while clang evaluates the arguments in order
from left to right, causing the test to fail.

Change-Id: I5059556e860cec29b57c31e4e26f46cf9e6055da
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
tests/auto/corelib/kernel/qobject/tst_qobject.cpp

index 4e7935b..91b93e4 100644 (file)
@@ -1703,6 +1703,7 @@ void tst_QObject::property()
     QVERIFY(property.isWritable());
     QVERIFY(!property.isEnumType());
     QCOMPARE(property.typeName(), "CustomType*");
+    qRegisterMetaType<CustomType*>();
     QCOMPARE(property.type(), QVariant::UserType);
     QCOMPARE(property.userType(), qMetaTypeId<CustomType*>());