summaryrefslogtreecommitdiffstats
path: root/tests/auto/qscriptvalue
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-10-06 10:52:58 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-10-06 11:01:41 (GMT)
commit13cf7c64acd1652bad90966e06464b35b84e9513 (patch)
treee9032c60a2b4f00feb452e7df7e0c11c51583b16 /tests/auto/qscriptvalue
parenta6ed1f886d323d68001e3e1b50efe064073691ea (diff)
downloadQt-13cf7c64acd1652bad90966e06464b35b84e9513.zip
Qt-13cf7c64acd1652bad90966e06464b35b84e9513.tar.gz
Qt-13cf7c64acd1652bad90966e06464b35b84e9513.tar.bz2
implement property getters&setters for setProperty(quint32) overload
It's better that this works rather than asserts. Reviewed-by: Olivier Goffart
Diffstat (limited to 'tests/auto/qscriptvalue')
-rw-r--r--tests/auto/qscriptvalue/tst_qscriptvalue.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
index 6b64e76..5636c54 100644
--- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
+++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
@@ -87,6 +87,7 @@ private slots:
void getSetPrototype();
void getSetScope();
void getSetProperty();
+ void arrayElementGetterSetter();
void getSetData();
void getSetScriptClass();
void call();
@@ -2115,6 +2116,32 @@ void tst_QScriptValue::getSetProperty()
QVERIFY(object.propertyFlags(foo) == 0);
}
+void tst_QScriptValue::arrayElementGetterSetter()
+{
+ QScriptEngine eng;
+ QScriptValue obj = eng.newObject();
+ obj.setProperty(1, eng.newFunction(getterSetter), QScriptValue::PropertyGetter|QScriptValue::PropertySetter);
+ {
+ QScriptValue num(123);
+ obj.setProperty("x", num);
+ QScriptValue ret = obj.property(1);
+ QVERIFY(ret.isValid());
+ QVERIFY(ret.equals(num));
+ }
+ {
+ QScriptValue num(456);
+ obj.setProperty(1, num);
+ QScriptValue ret = obj.property(1);
+ QVERIFY(ret.isValid());
+ QVERIFY(ret.equals(num));
+ QVERIFY(ret.equals(obj.property("1")));
+ }
+ QCOMPARE(obj.propertyFlags("1"), QScriptValue::PropertyGetter|QScriptValue::PropertySetter);
+
+ obj.setProperty(1, QScriptValue(), QScriptValue::PropertyGetter|QScriptValue::PropertySetter);
+ QVERIFY(obj.propertyFlags("1") == 0);
+}
+
void tst_QScriptValue::getSetPrototype()
{
QScriptEngine eng;