aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmljsscope
diff options
context:
space:
mode:
authorMaximilian Goldstein <max.goldstein@qt.io>2022-05-19 15:41:24 +0200
committerMaximilian Goldstein <max.goldstein@qt.io>2022-05-19 22:30:23 +0200
commit827193b3a196511091ec575905c01adbba55c8d4 (patch)
treea2a422d2e7f3f5a3572e933b39aa267bbc859c48 /tests/auto/qml/qqmljsscope
parent4a10e1d84ac948fb9a50cd2e44fcbeaef972e5ea (diff)
qqmljsimportvisitor: Fix assert being hit on empty block bindings
We previously hit an assert / crashed if we saw an empty script binding. Fixes: QTBUG-103707 Change-Id: I117d984a7d315ecf860d2ada5568637d154ae083 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmljsscope')
-rw-r--r--tests/auto/qml/qqmljsscope/data/emptyBlockBinding.qml6
-rw-r--r--tests/auto/qml/qqmljsscope/tst_qqmljsscope.cpp13
2 files changed, 17 insertions, 2 deletions
diff --git a/tests/auto/qml/qqmljsscope/data/emptyBlockBinding.qml b/tests/auto/qml/qqmljsscope/data/emptyBlockBinding.qml
new file mode 100644
index 0000000000..f4c1372db4
--- /dev/null
+++ b/tests/auto/qml/qqmljsscope/data/emptyBlockBinding.qml
@@ -0,0 +1,6 @@
+import QtQuick
+
+Item {
+ x: {}
+ y: {5}
+}
diff --git a/tests/auto/qml/qqmljsscope/tst_qqmljsscope.cpp b/tests/auto/qml/qqmljsscope/tst_qqmljsscope.cpp
index ebf9bd9beb..cb1a03ab2b 100644
--- a/tests/auto/qml/qqmljsscope/tst_qqmljsscope.cpp
+++ b/tests/auto/qml/qqmljsscope/tst_qqmljsscope.cpp
@@ -129,6 +129,7 @@ private Q_SLOTS:
void attachedProperties();
void scriptIndices();
void extensions();
+ void emptyBlockBinding();
public:
tst_qqmljsscope()
@@ -177,14 +178,14 @@ void tst_qqmljsscope::orderedBindings()
QVERIFY(root);
auto [pBindingsBegin, pBindingsEnd] = root->ownPropertyBindings(u"p"_s);
- QVERIFY(std::distance(pBindingsBegin, pBindingsEnd) == 2);
+ QCOMPARE(std::distance(pBindingsBegin, pBindingsEnd), 2);
// check that the bindings are properly ordered
QCOMPARE(pBindingsBegin->bindingType(), QQmlJSMetaPropertyBinding::Object);
QCOMPARE(std::next(pBindingsBegin)->bindingType(), QQmlJSMetaPropertyBinding::Interceptor);
auto [itemsBindingsBegin, itemsBindingsEnd] = root->ownPropertyBindings(u"items"_s);
- QVERIFY(std::distance(itemsBindingsBegin, itemsBindingsEnd) == 2);
+ QCOMPARE(std::distance(itemsBindingsBegin, itemsBindingsEnd), 2);
QCOMPARE(itemsBindingsBegin->bindingType(), QQmlJSMetaPropertyBinding::Object);
QCOMPARE(std::next(itemsBindingsBegin)->bindingType(), QQmlJSMetaPropertyBinding::Object);
@@ -631,5 +632,13 @@ void tst_qqmljsscope::extensions()
QCOMPARE(owner, childScopes[4]->baseType()->extensionType().scope);
}
+void tst_qqmljsscope::emptyBlockBinding()
+{
+ QQmlJSScope::ConstPtr root = run(u"emptyBlockBinding.qml"_s);
+ QVERIFY(root);
+ QVERIFY(root->hasOwnPropertyBindings(u"x"_s));
+ QVERIFY(root->hasOwnPropertyBindings(u"y"_s));
+}
+
QTEST_MAIN(tst_qqmljsscope)
#include "tst_qqmljsscope.moc"