diff options
author | Erik Verbruggen <erik.verbruggen@me.com> | 2013-09-11 10:00:43 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-11 17:12:19 +0200 |
commit | 6aabeb55e663933149b716b47bcfbb37525babb4 (patch) | |
tree | deeb666818debf97c0f71d248ddea1531a81bd55 /tests/auto/qml/qqmlecmascript | |
parent | 262d7261033df7650938c38401112a4767d926ff (diff) |
Fix return type checks in test.
Same problem as 3dbc7a72c7e38b2a34df3a9ef496547c795420af fixed in
another test. Same solution.
Change-Id: Ib476239e567c43e4657487c34cfc7157a1f5d33f
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'tests/auto/qml/qqmlecmascript')
-rw-r--r-- | tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 99659fb1eb..5e1f83a43a 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -310,6 +310,18 @@ private: // static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter); static void verifyContextLifetime(QQmlContextData *ctxt); QQmlEngine engine; + + // When calling into JavaScript, the specific type of the return value can differ if that return + // value is a number. This is not only the case for non-integral numbers, or numbers that do not + // fit into the (signed) integer range, but it also depends on which optimizations are run. So, + // to check if the return value is of a number type, use this method instead of checking against + // a specific userType. + static bool isJSNumberType(int userType) + { + return userType == (int) QVariant::Int + || userType == (int) QVariant::UInt + || userType == (int) QVariant::Double; + } }; // The JavaScriptCore GC marks the C stack. To try to ensure that there is @@ -4687,8 +4699,8 @@ void tst_qqmlecmascript::propertyVarCpp() QVERIFY(object->setProperty("varProperty", QVariant::fromValue(10))); QCOMPARE(object->property("varBound"), QVariant(15)); QCOMPARE(object->property("intBound"), QVariant(15)); - QCOMPARE(object->property("varProperty").userType(), (int)QVariant::Int); - QCOMPARE(object->property("varBound").userType(), (int)QVariant::Int); + QVERIFY(isJSNumberType(object->property("varProperty").userType())); + QVERIFY(isJSNumberType(object->property("varBound").userType())); // assign string to property var that current has bool assigned QCOMPARE(object->property("varProperty2").userType(), (int)QVariant::Bool); QVERIFY(object->setProperty("varProperty2", QVariant(QLatin1String("randomString")))); |