summaryrefslogtreecommitdiffstats
path: root/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
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/qscriptvalue/tst_qscriptvalue.cpp
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/qscriptvalue/tst_qscriptvalue.cpp')
-rw-r--r--tests/auto/qscriptvalue/tst_qscriptvalue.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
index b2f6caf..815747d 100644
--- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
+++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
@@ -1446,9 +1446,11 @@ void tst_QScriptValue::toObject()
QScriptValue undefined = eng.undefinedValue();
QCOMPARE(undefined.toObject().isValid(), false);
+ QVERIFY(undefined.isUndefined());
QScriptValue null = eng.nullValue();
QCOMPARE(null.toObject().isValid(), false);
+ QVERIFY(null.isNull());
{
QScriptValue falskt = QScriptValue(&eng, false);
@@ -1457,6 +1459,7 @@ void tst_QScriptValue::toObject()
QCOMPARE(tmp.isObject(), true);
QCOMPARE(tmp.toNumber(), falskt.toNumber());
}
+ QVERIFY(falskt.isBool());
QScriptValue sant = QScriptValue(&eng, true);
{
@@ -1464,6 +1467,7 @@ void tst_QScriptValue::toObject()
QCOMPARE(tmp.isObject(), true);
QCOMPARE(tmp.toNumber(), sant.toNumber());
}
+ QVERIFY(sant.isBool());
QScriptValue number = QScriptValue(&eng, 123.0);
{
@@ -1471,6 +1475,7 @@ void tst_QScriptValue::toObject()
QCOMPARE(tmp.isObject(), true);
QCOMPARE(tmp.toNumber(), number.toNumber());
}
+ QVERIFY(number.isNumber());
QScriptValue str = QScriptValue(&eng, QString("ciao"));
{
@@ -1478,6 +1483,7 @@ void tst_QScriptValue::toObject()
QCOMPARE(tmp.isObject(), true);
QCOMPARE(tmp.toString(), str.toString());
}
+ QVERIFY(str.isString());
}
QScriptValue object = eng.newObject();
@@ -1497,10 +1503,12 @@ void tst_QScriptValue::toObject()
QScriptValue undefined = QScriptValue(QScriptValue::UndefinedValue);
QVERIFY(!undefined.toObject().isValid());
QVERIFY(!eng.toObject(undefined).isValid());
+ QVERIFY(undefined.isUndefined());
QScriptValue null = QScriptValue(QScriptValue::NullValue);
QVERIFY(!null.toObject().isValid());
QVERIFY(!eng.toObject(null).isValid());
+ QVERIFY(null.isNull());
QScriptValue falskt = QScriptValue(false);
QVERIFY(!falskt.toObject().isValid());
@@ -1509,6 +1517,7 @@ void tst_QScriptValue::toObject()
QVERIFY(tmp.isObject());
QVERIFY(tmp.toBool());
}
+ QVERIFY(falskt.isBool());
QScriptValue sant = QScriptValue(true);
QVERIFY(!sant.toObject().isValid());
@@ -1517,6 +1526,7 @@ void tst_QScriptValue::toObject()
QVERIFY(tmp.isObject());
QVERIFY(tmp.toBool());
}
+ QVERIFY(sant.isBool());
QScriptValue number = QScriptValue(123.0);
QVERIFY(!number.toObject().isValid());
@@ -1525,6 +1535,7 @@ void tst_QScriptValue::toObject()
QVERIFY(tmp.isObject());
QCOMPARE(tmp.toInt32(), number.toInt32());
}
+ QVERIFY(number.isNumber());
QScriptValue str = QScriptValue(QString::fromLatin1("ciao"));
QVERIFY(!str.toObject().isValid());
@@ -1533,6 +1544,7 @@ void tst_QScriptValue::toObject()
QVERIFY(tmp.isObject());
QCOMPARE(tmp.toString(), QString::fromLatin1("ciao"));
}
+ QVERIFY(str.isString());
}
}