From 457539959363245082add602c186239be0f71af1 Mon Sep 17 00:00:00 2001 From: Jedrzej Nowacki Date: Wed, 28 Jul 2010 13:57:53 +0200 Subject: Increase test coverage for QScriptValue. New test value for tst_QScriptValue::getSetData testcase. Setting data is allowed only for an object. Reviewed-by: Kent Hansen --- tests/auto/qscriptvalue/tst_qscriptvalue.cpp | 43 +++++++++++++++++++--------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp index 8aa4e711..1d8706c 100644 --- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp +++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp @@ -2234,19 +2234,36 @@ void tst_QScriptValue::getSetScope() void tst_QScriptValue::getSetData() { QScriptEngine eng; - QScriptValue object = eng.newObject(); - QVERIFY(!object.data().isValid()); - QScriptValue v1(true); - object.setData(v1); - QVERIFY(object.data().strictlyEquals(v1)); - QScriptValue v2(123); - object.setData(v2); - QVERIFY(object.data().strictlyEquals(v2)); - QScriptValue v3 = eng.newObject(); - object.setData(v3); - QVERIFY(object.data().strictlyEquals(v3)); - object.setData(QScriptValue()); - QVERIFY(!object.data().isValid()); + { + QScriptValue object = eng.newObject(); + QVERIFY(!object.data().isValid()); + QScriptValue v1(true); + object.setData(v1); + QVERIFY(object.data().strictlyEquals(v1)); + QScriptValue v2(123); + object.setData(v2); + QVERIFY(object.data().strictlyEquals(v2)); + QScriptValue v3 = eng.newObject(); + object.setData(v3); + QVERIFY(object.data().strictlyEquals(v3)); + object.setData(QScriptValue()); + QVERIFY(!object.data().isValid()); + } + { + QScriptValue value = eng.undefinedValue(); + QVERIFY(!value.data().isValid()); + QScriptValue v1(true); + value.setData(v1); + QVERIFY(!value.data().isValid()); + QScriptValue v2(123); + value.setData(v2); + QVERIFY(!value.data().isValid()); + QScriptValue v3 = eng.newObject(); + value.setData(v3); + QVERIFY(!value.data().isValid()); + value.setData(QScriptValue()); + QVERIFY(!value.data().isValid()); + } } class TestScriptClass : public QScriptClass -- cgit v0.12