summaryrefslogtreecommitdiffstats
path: root/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
diff options
context:
space:
mode:
authorJedrzej Nowacki <jedrzej.nowacki@nokia.com>2010-10-29 12:02:51 (GMT)
committerJedrzej Nowacki <jedrzej.nowacki@nokia.com>2010-11-01 07:57:58 (GMT)
commit121b7a47670f8a8e8e4c7ef6cf69a42865297158 (patch)
tree9b436e3eb646dd4b8df662ca567c6c71f78f0c80 /tests/auto/qscriptvalue/tst_qscriptvalue.cpp
parent0540537b2841d3c9e367d84d0f89f6a5f5f487a7 (diff)
downloadQt-121b7a47670f8a8e8e4c7ef6cf69a42865297158.zip
Qt-121b7a47670f8a8e8e4c7ef6cf69a42865297158.tar.gz
Qt-121b7a47670f8a8e8e4c7ef6cf69a42865297158.tar.bz2
Increase range of getSetScriptClass test.
Few bound QScriptValue instances were added to the test. Reviewed-by: Kent Hansen
Diffstat (limited to 'tests/auto/qscriptvalue/tst_qscriptvalue.cpp')
-rw-r--r--tests/auto/qscriptvalue/tst_qscriptvalue.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
index 4232aff..e5af792 100644
--- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
+++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
@@ -56,7 +56,8 @@ tst_QScriptValue::tst_QScriptValue()
tst_QScriptValue::~tst_QScriptValue()
{
- delete engine;
+ if (engine)
+ delete engine;
}
void tst_QScriptValue::ctor_invalid()
@@ -2278,8 +2279,9 @@ public:
TestScriptClass(QScriptEngine *engine) : QScriptClass(engine) {}
};
-void tst_QScriptValue::getSetScriptClass_nonObjects_data()
+void tst_QScriptValue::getSetScriptClass_emptyClass_data()
{
+ newEngine();
QTest::addColumn<QScriptValue>("value");
QTest::newRow("invalid") << QScriptValue();
@@ -2288,9 +2290,18 @@ void tst_QScriptValue::getSetScriptClass_nonObjects_data()
QTest::newRow("bool") << QScriptValue(false);
QTest::newRow("null") << QScriptValue(QScriptValue::NullValue);
QTest::newRow("undefined") << QScriptValue(QScriptValue::UndefinedValue);
+
+ QTest::newRow("number") << QScriptValue(engine, 123);
+ QTest::newRow("string") << QScriptValue(engine, "pong");
+ QTest::newRow("bool") << QScriptValue(engine, true);
+ QTest::newRow("null") << QScriptValue(engine->nullValue());
+ QTest::newRow("undefined") << QScriptValue(engine->undefinedValue());
+ QTest::newRow("object") << QScriptValue(engine->newObject());
+ QTest::newRow("date") << QScriptValue(engine->evaluate("new Date()"));
+ QTest::newRow("qobject") << QScriptValue(engine->newQObject(this));
}
-void tst_QScriptValue::getSetScriptClass_nonObjects()
+void tst_QScriptValue::getSetScriptClass_emptyClass()
{
QFETCH(QScriptValue, value);
QCOMPARE(value.scriptClass(), (QScriptClass*)0);
@@ -2303,7 +2314,6 @@ void tst_QScriptValue::getSetScriptClass_JSObjectFromCpp()
// object created in C++ (newObject())
{
QScriptValue obj = eng.newObject();
- QCOMPARE(obj.scriptClass(), (QScriptClass*)0);
obj.setScriptClass(&testClass);
QCOMPARE(obj.scriptClass(), (QScriptClass*)&testClass);
obj.setScriptClass(0);
@@ -2355,7 +2365,6 @@ void tst_QScriptValue::getSetScriptClass_QObject()
{
QScriptValue obj = eng.newQObject(this);
QVERIFY(obj.isQObject());
- QCOMPARE(obj.scriptClass(), (QScriptClass*)0);
obj.setScriptClass(&testClass);
QCOMPARE(obj.scriptClass(), (QScriptClass*)&testClass);
QVERIFY(obj.isObject());