aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qjsengine
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2012-03-15 10:15:53 +0100
committerQt by Nokia <qt-info@nokia.com>2012-03-20 06:49:30 +0100
commitd96d89c63c28f81f9c17666ed66222f523571f03 (patch)
tree085e7cbd6fe9f134d46ad00433907ed7abc35893 /tests/auto/qml/qjsengine
parentd38e9e413ce0c9ee636ea0b4aa722668ad54d1ae (diff)
Make QVariant conversion for JS null type symmetric
If you pass (void*)0 to QJSEngine::toScriptValue(), or you pass a QVariant of type QMetaType::VoidStar containing a 0 value, you get back a QJSValue of type null (isNull() returns true); that's fine. However, if you called QJSValue::toVariant() on a JS null value, you would get back an invalid QVariant. The expected result is a QVariant of type QMetaType::VoidStar containing a 0 value. This makes the conversion of the JS null type symmetric and avoids loss of data. Change-Id: Ifa6e788152118f80adf9c2d7be1283f053b44294 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com> Reviewed-by: Simon Hausmann <simon.hausmann@nokia.com>
Diffstat (limited to 'tests/auto/qml/qjsengine')
-rw-r--r--tests/auto/qml/qjsengine/tst_qjsengine.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
index 6f9cc93757..e34304b258 100644
--- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
@@ -2369,6 +2369,8 @@ void tst_QJSEngine::valueConversion_basic()
QCOMPARE(eng.fromScriptValue<QChar>(code), c);
QCOMPARE(eng.fromScriptValue<QChar>(eng.toScriptValue(c)), c);
}
+
+ QVERIFY(eng.toScriptValue(static_cast<void *>(0)).isNull());
}
#if 0 // FIXME: No API for custom types
@@ -2588,6 +2590,8 @@ void tst_QJSEngine::valueConversion_QVariant()
}
QCOMPARE(qjsvalue_cast<QVariant>(QJSValue(123)), QVariant(123));
+
+ QVERIFY(eng.toScriptValue(QVariant(QMetaType::VoidStar, 0)).isNull());
}
#if 0 // FIXME: No support for custom types