summaryrefslogtreecommitdiff
path: root/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2012-08-13 09:47:43 +0200
committerQt by Nokia <qt-info@nokia.com>2012-08-14 08:29:21 +0200
commitb0c4e816e6da2c09593cf8de2f563093947ebdaf (patch)
tree50659e7b5e8689af5d4a6cf4dd55ff75e54ce36b /tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp
parentd1cf1cc364463c196dfc99f04328755a67476569 (diff)
downloadqtscript-b0c4e816e6da2c09593cf8de2f563093947ebdaf.tar.gz
Add default conversion for types long and ulong
Such conversion is not guaranteed to be lossless on all platforms, but it's still reasonable to support these types by default. JSC::JSValue already had constructors for them. The type matching / overload resolution in the QObject binding already handled long and ulong, but the value conversion itself was missing, for some reason. Task-number: QTBUG-2124 Change-Id: I14ff29a8e949403234b7659c0aca8b48bcdbda0e Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp')
-rw-r--r--tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp b/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp
index 43e640a..9706901 100644
--- a/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp
+++ b/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp
@@ -343,6 +343,10 @@ public:
{ m_qtFunctionInvoked = 67; m_actuals << qVariantFromValue(arg); return arg; }
Q_INVOKABLE qulonglong myInvokableWithULonglongArg(qulonglong arg)
{ m_qtFunctionInvoked = 68; m_actuals << qVariantFromValue(arg); return arg; }
+ Q_INVOKABLE long myInvokableWithLongArg(long arg)
+ { m_qtFunctionInvoked = 69; m_actuals << qVariantFromValue(arg); return arg; }
+ Q_INVOKABLE unsigned long myInvokableWithULongArg(unsigned long arg)
+ { m_qtFunctionInvoked = 70; m_actuals << qVariantFromValue(arg); return arg; }
Q_INVOKABLE QObjectList findObjects() const
{ return findChildren<QObject *>(); }
@@ -1594,6 +1598,32 @@ void tst_QScriptExtQObject::callQtInvokable4()
QCOMPARE(v.userType(), int(QMetaType::ULongLong));
QCOMPARE(qvariant_cast<qulonglong>(v), qulonglong(123));
}
+
+ m_myObject->resetQtFunctionInvoked();
+ {
+ QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithLongArg(123)");
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 69);
+ QVERIFY(ret.isNumber());
+ QCOMPARE(long(ret.toInteger()), long(123));
+
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+ QVariant v = m_myObject->qtFunctionActuals().at(0);
+ QCOMPARE(v.userType(), int(QMetaType::Long));
+ QCOMPARE(qvariant_cast<long>(v), long(123));
+ }
+
+ m_myObject->resetQtFunctionInvoked();
+ {
+ QScriptValue ret = m_engine->evaluate("myObject.myInvokableWithULongArg(456)");
+ QCOMPARE(m_myObject->qtFunctionInvoked(), 70);
+ QVERIFY(ret.isNumber());
+ QCOMPARE(ulong(ret.toInteger()), ulong(456));
+
+ QCOMPARE(m_myObject->qtFunctionActuals().size(), 1);
+ QVariant v = m_myObject->qtFunctionActuals().at(0);
+ QCOMPARE(v.userType(), int(QMetaType::ULong));
+ QCOMPARE(qvariant_cast<unsigned long>(v), ulong(456));
+ }
}
void tst_QScriptExtQObject::callQtInvokable5()