diff options
Diffstat (limited to 'tests/auto/qscriptengine/tst_qscriptengine.cpp')
-rw-r--r-- | tests/auto/qscriptengine/tst_qscriptengine.cpp | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp index 26eb1af..7133a6c 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -1915,7 +1915,6 @@ void tst_QScriptEngine::valueConversion() QString snum = qScriptValueToValue<QString>(num); QCOMPARE(snum, QLatin1String("123")); } -#ifndef QT_NO_MEMBER_TEMPLATES { QScriptValue num = eng.toScriptValue(123); QCOMPARE(num.isNumber(), true); @@ -1927,7 +1926,6 @@ void tst_QScriptEngine::valueConversion() QString snum = eng.fromScriptValue<QString>(num); QCOMPARE(snum, QLatin1String("123")); } -#endif { QScriptValue num(&eng, 123); QCOMPARE(qScriptValueToValue<char>(num), char(123)); @@ -2097,6 +2095,38 @@ void tst_QScriptEngine::valueConversion() QVERIFY(!val.isVariant()); QVERIFY(val.isUndefined()); } + // Checking nested QVariants + { + QVariant tmp1; + QVariant tmp2(QMetaType::QVariant, &tmp1); + QVERIFY(QMetaType::Type(tmp2.type()) == QMetaType::QVariant); + + QScriptValue val1 = qScriptValueFromValue(&eng, tmp1); + QScriptValue val2 = qScriptValueFromValue(&eng, tmp2); + QVERIFY(val1.isValid()); + QVERIFY(val2.isValid()); + QVERIFY(val1.isUndefined()); + QVERIFY(!val2.isUndefined()); + QVERIFY(!val1.isVariant()); + QVERIFY(val2.isVariant()); + } + { + QVariant tmp1(123); + QVariant tmp2(QMetaType::QVariant, &tmp1); + QVariant tmp3(QMetaType::QVariant, &tmp2); + QVERIFY(QMetaType::Type(tmp1.type()) == QMetaType::Int); + QVERIFY(QMetaType::Type(tmp2.type()) == QMetaType::QVariant); + QVERIFY(QMetaType::Type(tmp3.type()) == QMetaType::QVariant); + + QScriptValue val1 = qScriptValueFromValue(&eng, tmp2); + QScriptValue val2 = qScriptValueFromValue(&eng, tmp3); + QVERIFY(val1.isValid()); + QVERIFY(val2.isValid()); + QVERIFY(val1.isVariant()); + QVERIFY(val2.isVariant()); + QVERIFY(val1.toVariant().toInt() == 123); + QVERIFY(qScriptValueFromValue(&eng, val2.toVariant()).toVariant().toInt() == 123); + } { QScriptValue val = qScriptValueFromValue(&eng, QVariant(true)); QVERIFY(!val.isVariant()); |