diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-06-15 15:34:33 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-06-15 15:35:05 (GMT) |
commit | 9d6069f32962128f737b83a4bf7d7e7309983023 (patch) | |
tree | d5c37af610ffceeb76ad9878a2039112be917193 /tests/auto/qscriptvalue | |
parent | b8231cb61129964dfecaf862b6ef5fecb6753c01 (diff) | |
download | Qt-9d6069f32962128f737b83a4bf7d7e7309983023.zip Qt-9d6069f32962128f737b83a4bf7d7e7309983023.tar.gz Qt-9d6069f32962128f737b83a4bf7d7e7309983023.tar.bz2 |
add a bunch of qtscript autotests
Get that code coverage up.
Diffstat (limited to 'tests/auto/qscriptvalue')
-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 { |