aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativeecmascript
diff options
context:
space:
mode:
authorChris Adams <christopher.adams@nokia.com>2011-12-01 16:07:59 +1000
committerQt by Nokia <qt-info@nokia.com>2011-12-06 02:46:28 +0100
commit8601f3444f7926a7b47ae217d8bf51044ff61809 (patch)
treebb26f7ba247e0f0745266ea897af43dbabd4ff3a /tests/auto/declarative/qdeclarativeecmascript
parent2a5bd344ee27bfd61c0e83ce25df5cf843cebdee (diff)
Document function limitation of var properties
Functions cannot be assigned to var properties due to the fact that such an assignment signifies a binding assignment. This limitation needs to be documented. One workaround is to assign an array which contains a function element to a var property, and this commit also adds a unit test to ensure this works. Change-Id: I02363b88233282106ac6d26f14df1988155057b9 Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests/auto/declarative/qdeclarativeecmascript')
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.6.qml9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.6.qml b/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.6.qml
index 5197aeada7..060d24e7bc 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.6.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.6.qml
@@ -5,13 +5,22 @@ Item {
property var items: [1, 2, 3, "four", "five"]
property int bound: items[0]
+ property var funcs: [(function() { return 6; })]
+ property int bound2: funcs[0]()
+
+ function returnTwenty() {
+ return 20;
+ }
Component.onCompleted: {
if (bound != 1) return false;
+ if (bound2 != 6) return false;
items = [10, 2, 3, "four", "five"] // bound should now be 10
+ funcs = [returnTwenty] // bound2 should now be 20
if (bound != 10) return false;
+ if (bound2 != 20) return false;
test = true;
}