diff options
author | Tobias Koenig <tokoe@kde.org> | 2009-06-16 16:07:42 (GMT) |
---|---|---|
committer | Tobias Koenig <tokoe@kde.org> | 2009-06-16 16:07:42 (GMT) |
commit | 65c2d095cddfda32052925654dd1defd314ad4b3 (patch) | |
tree | 222ac5b04cd1c7a273b0c22d01d0ff3682d5d2d3 /tests/auto/qscriptvalue/tst_qscriptvalue.cpp | |
parent | f1e6e89f7ee452af0e4404af537f5fed2a2b2dc5 (diff) | |
parent | d9308550f104526d29b1cdd56514ae3bb967d7f9 (diff) | |
download | Qt-65c2d095cddfda32052925654dd1defd314ad4b3.zip Qt-65c2d095cddfda32052925654dd1defd314ad4b3.tar.gz Qt-65c2d095cddfda32052925654dd1defd314ad4b3.tar.bz2 |
Merge branch 'master' of git://gitorious.org/qt/qt
Diffstat (limited to 'tests/auto/qscriptvalue/tst_qscriptvalue.cpp')
-rw-r--r-- | tests/auto/qscriptvalue/tst_qscriptvalue.cpp | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp index ad1080a..7901b65 100644 --- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp +++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp @@ -1482,21 +1482,43 @@ void tst_QScriptValue::toObject() { QScriptValue undefined = QScriptValue(QScriptValue::UndefinedValue); QVERIFY(!undefined.toObject().isValid()); + QVERIFY(!eng.toObject(undefined).isValid()); QScriptValue null = QScriptValue(QScriptValue::NullValue); QVERIFY(!null.toObject().isValid()); + QVERIFY(!eng.toObject(null).isValid()); QScriptValue falskt = QScriptValue(false); QVERIFY(!falskt.toObject().isValid()); + { + QScriptValue tmp = eng.toObject(falskt); + QVERIFY(tmp.isObject()); + QVERIFY(tmp.toBool()); + } QScriptValue sant = QScriptValue(true); QVERIFY(!sant.toObject().isValid()); + { + QScriptValue tmp = eng.toObject(sant); + QVERIFY(tmp.isObject()); + QVERIFY(tmp.toBool()); + } QScriptValue number = QScriptValue(123.0); QVERIFY(!number.toObject().isValid()); + { + QScriptValue tmp = eng.toObject(number); + QVERIFY(tmp.isObject()); + QCOMPARE(tmp.toInt32(), number.toInt32()); + } - QScriptValue str = QScriptValue(QString("ciao")); + QScriptValue str = QScriptValue(QString::fromLatin1("ciao")); QVERIFY(!str.toObject().isValid()); + { + QScriptValue tmp = eng.toObject(str); + QVERIFY(tmp.isObject()); + QCOMPARE(tmp.toString(), QString::fromLatin1("ciao")); + } } } @@ -2360,6 +2382,16 @@ void tst_QScriptValue::call() QCOMPARE(qIsNaN(ret.toNumber()), true); } } + { + QScriptValue fun = eng.evaluate("Object"); + QVERIFY(fun.isFunction()); + QScriptEngine eng2; + QScriptValue objectInDifferentEngine = eng2.newObject(); + QScriptValueList args; + args << objectInDifferentEngine; + QTest::ignoreMessage(QtWarningMsg, "QScriptValue::call() failed: cannot call function with argument created in a different engine"); + fun.call(QScriptValue(), args); + } // test that invalid return value is handled gracefully { |