aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qml/qml/qqmlrewrite.cpp10
-rw-r--r--src/qml/qml/qqmlrewrite_p.h3
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyQJSValue.16.qml22
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVar.16.qml36
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp2
5 files changed, 73 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlrewrite.cpp b/src/qml/qml/qqmlrewrite.cpp
index 83ede9456b..d498f98f50 100644
--- a/src/qml/qml/qqmlrewrite.cpp
+++ b/src/qml/qml/qqmlrewrite.cpp
@@ -313,6 +313,16 @@ void RewriteBinding::endVisit(AST::LocalForEachStatement *)
--_inLoop;
}
+bool RewriteBinding::visit(AST::FunctionExpression *)
+{
+ return false;
+}
+
+bool RewriteBinding::visit(AST::FunctionDeclaration *)
+{
+ return false;
+}
+
bool RewriteBinding::visit(AST::CaseBlock *ast)
{
// Process the initial sequence of the case clauses.
diff --git a/src/qml/qml/qqmlrewrite_p.h b/src/qml/qml/qqmlrewrite_p.h
index 064398115a..9fcc9896e6 100644
--- a/src/qml/qml/qqmlrewrite_p.h
+++ b/src/qml/qml/qqmlrewrite_p.h
@@ -120,6 +120,9 @@ protected:
virtual bool visit(AST::CaseBlock *ast);
+ virtual bool visit(AST::FunctionExpression *ast);
+ virtual bool visit(AST::FunctionDeclaration *ast);
+
private:
int _inLoop;
};
diff --git a/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.16.qml b/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.16.qml
new file mode 100644
index 0000000000..7c691435ea
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/propertyQJSValue.16.qml
@@ -0,0 +1,22 @@
+import QtQuick 2.0
+import Qt.test 1.0
+
+MyQmlObject {
+ property bool test: false
+ property string string1
+
+ qjsvalue: function () {
+ string1 = "Test case 1"
+ return 100;
+ }
+
+ Component.onCompleted: {
+ if (qjsvalue() != 100)
+ return
+
+ if (string1 != "Test case 1")
+ return;
+
+ test = true;
+ }
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/propertyVar.16.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.16.qml
new file mode 100644
index 0000000000..e208c98766
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.16.qml
@@ -0,0 +1,36 @@
+import QtQuick 2.0
+
+Item {
+ property bool test: false
+ property string string1
+ property string string2
+
+ property var f1 : function () {
+ string1 = "Test case 1"
+ return 100;
+ }
+
+ property var f2;
+ function testcase2() {
+ string2 = "Test case 2"
+ return 100;
+ }
+
+ f2: testcase2
+
+ Component.onCompleted: {
+ if (f1() != 100)
+ return
+
+ if (f2() != 100)
+ return;
+
+ if (string1 != "Test case 1")
+ return;
+
+ if (string2 != "Test case 2")
+ return;
+
+ test = true;
+ }
+}
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index f907a1cb21..e1a59ed0dd 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -4228,6 +4228,7 @@ void tst_qqmlecmascript::propertyVar_data()
QTest::newRow("declarative binding assignment") << testFileUrl("propertyVar.13.qml");
QTest::newRow("imperative binding assignment") << testFileUrl("propertyVar.14.qml");
QTest::newRow("stored binding assignment") << testFileUrl("propertyVar.15.qml");
+ QTest::newRow("function expression binding assignment") << testFileUrl("propertyVar.16.qml");
}
void tst_qqmlecmascript::propertyVar()
@@ -4263,6 +4264,7 @@ void tst_qqmlecmascript::propertyQJSValue_data()
QTest::newRow("declarative binding assignment") << testFileUrl("propertyQJSValue.13.qml");
QTest::newRow("imperative binding assignment") << testFileUrl("propertyQJSValue.14.qml");
QTest::newRow("stored binding assignment") << testFileUrl("propertyQJSValue.15.qml");
+ QTest::newRow("javascript function binding") << testFileUrl("propertyQJSValue.16.qml");
QTest::newRow("reset property") << testFileUrl("propertyQJSValue.reset.qml");
QTest::newRow("reset property in binding") << testFileUrl("propertyQJSValue.bindingreset.qml");