summaryrefslogtreecommitdiffstats
path: root/tests/auto/qscriptengine
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2010-04-19 11:03:51 (GMT)
committerKent Hansen <kent.hansen@nokia.com>2010-04-19 11:06:01 (GMT)
commited91e29b23a07879a748c199902e3bf3fe6cd73f (patch)
treeb6f1e0a45c625c9f8e04b4e842c4d02fa245b7de /tests/auto/qscriptengine
parentb0a500dfd0efc44e795d7348da38f162b50c8263 (diff)
downloadQt-ed91e29b23a07879a748c199902e3bf3fe6cd73f.zip
Qt-ed91e29b23a07879a748c199902e3bf3fe6cd73f.tar.gz
Qt-ed91e29b23a07879a748c199902e3bf3fe6cd73f.tar.bz2
Improve QScript{Engine,Value}::toObject() test coverage
Test that calling toObject() doesn't change the type of the original value.
Diffstat (limited to 'tests/auto/qscriptengine')
-rw-r--r--tests/auto/qscriptengine/tst_qscriptengine.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp
index 5713f8e..60b9112 100644
--- a/tests/auto/qscriptengine/tst_qscriptengine.cpp
+++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp
@@ -3833,6 +3833,7 @@ void tst_QScriptEngine::toObject()
QVERIFY(tmp.isObject());
QCOMPARE(tmp.toNumber(), falskt.toNumber());
}
+ QVERIFY(falskt.isBool());
QScriptValue sant(true);
{
@@ -3840,6 +3841,7 @@ void tst_QScriptEngine::toObject()
QVERIFY(tmp.isObject());
QCOMPARE(tmp.toNumber(), sant.toNumber());
}
+ QVERIFY(sant.isBool());
QScriptValue number(123.0);
{
@@ -3847,6 +3849,7 @@ void tst_QScriptEngine::toObject()
QVERIFY(tmp.isObject());
QCOMPARE(tmp.toNumber(), number.toNumber());
}
+ QVERIFY(number.isNumber());
QScriptValue str = QScriptValue(&eng, QString("ciao"));
{
@@ -3854,6 +3857,7 @@ void tst_QScriptEngine::toObject()
QVERIFY(tmp.isObject());
QCOMPARE(tmp.toString(), str.toString());
}
+ QVERIFY(str.isString());
QScriptValue object = eng.newObject();
{
@@ -3866,6 +3870,32 @@ void tst_QScriptEngine::toObject()
QVERIFY(eng.toObject(qobject).strictlyEquals(qobject));
QVERIFY(!eng.toObject(QScriptValue()).isValid());
+
+ // v1 constructors
+
+ QScriptValue boolValue(&eng, true);
+ {
+ QScriptValue ret = eng.toObject(boolValue);
+ QVERIFY(ret.isObject());
+ QCOMPARE(ret.toBool(), boolValue.toBool());
+ }
+ QVERIFY(boolValue.isBool());
+
+ QScriptValue numberValue(&eng, 123.0);
+ {
+ QScriptValue ret = eng.toObject(numberValue);
+ QVERIFY(ret.isObject());
+ QCOMPARE(ret.toNumber(), numberValue.toNumber());
+ }
+ QVERIFY(numberValue.isNumber());
+
+ QScriptValue stringValue(&eng, QString::fromLatin1("foo"));
+ {
+ QScriptValue ret = eng.toObject(stringValue);
+ QVERIFY(ret.isObject());
+ QCOMPARE(ret.toString(), stringValue.toString());
+ }
+ QVERIFY(stringValue.isString());
}
void tst_QScriptEngine::reservedWords_data()