aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorUlf Hermann <[email protected]>2023-09-13 15:05:12 +0200
committerUlf Hermann <[email protected]>2023-09-15 09:01:59 +0200
commit1f5b7d843d5d091b98c068f2bff2fc63957b8134 (patch)
tree5424cc4e243c017100010d297c8f20cf2e0e1842 /tests
parent5dadee1186429e61b7bb8d27120b0399f0d16655 (diff)
QmlDom: Add const-correctness
We almost never want non-const DomItems anywhere. There is exactly one exception: From a MutableDomItem we need to poke into the internals of the respective DomItem and const_cast them. However, MutableDomItem is to be handled with care anyway. Change-Id: I826f0669c049462beec9ad71dccb39c5191a1d3f Reviewed-by: Sami Shalayel <[email protected]>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qmldom/domitem/tst_qmldomitem.h26
-rw-r--r--tests/benchmarks/qml/qmldom/tst_qmldomconstruction.cpp2
2 files changed, 14 insertions, 14 deletions
diff --git a/tests/auto/qmldom/domitem/tst_qmldomitem.h b/tests/auto/qmldom/domitem/tst_qmldomitem.h
index 9c6507510e..a400f02cf6 100644
--- a/tests/auto/qmldom/domitem/tst_qmldomitem.h
+++ b/tests/auto/qmldom/domitem/tst_qmldomitem.h
@@ -28,7 +28,7 @@ QT_BEGIN_NAMESPACE
namespace QQmlJS {
namespace Dom {
-inline DomItem wrapInt(DomItem &self, const PathEls::PathComponent &p, const int &i)
+inline DomItem wrapInt(const DomItem &self, const PathEls::PathComponent &p, const int &i)
{
return self.subDataItem(p, i);
}
@@ -536,13 +536,13 @@ private slots:
QList<DomItem> rects;
obj1.resolve(
Path::Current(PathCurrent::Lookup).field(Fields::type).key(u"Rectangle"_s),
- [&rects](Path, DomItem &el) {
+ [&rects](Path, const DomItem &el) {
rects.append(el);
return true;
},
{});
QVERIFY(rects.size() == 1);
- for (DomItem &el : rects) {
+ for (const DomItem &el : rects) {
QCOMPARE(rect.first(), el);
}
}
@@ -571,7 +571,7 @@ private slots:
DomItem tFile;
env.loadFile(
FileToLoad::fromFileSystem(env.ownerAs<DomEnvironment>(), testFile1),
- [&tFile](Path, DomItem &, DomItem &newIt) { tFile = newIt.fileObject(); },
+ [&tFile](Path, const DomItem &, const DomItem &newIt) { tFile = newIt.fileObject(); },
LoadOption::DefaultLoad);
env.loadPendingDependencies();
@@ -654,7 +654,7 @@ private slots:
QCOMPARE(obj.name(), u"MyItem");
}
- static void checkAliases(DomItem &qmlObj)
+ static void checkAliases(const DomItem &qmlObj)
{
using namespace Qt::StringLiterals;
@@ -747,7 +747,7 @@ private slots:
DomItem tFile;
env.loadFile(
FileToLoad::fromFileSystem(env.ownerAs<DomEnvironment>(), testFile1),
- [&tFile](Path, DomItem &, DomItem &newIt) { tFile = newIt.fileObject(); },
+ [&tFile](Path, const DomItem &, const DomItem &newIt) { tFile = newIt.fileObject(); },
LoadOption::DefaultLoad);
env.loadPendingDependencies();
@@ -769,7 +769,7 @@ private slots:
DomItem tFile;
env.loadFile(
FileToLoad::fromFileSystem(env.ownerAs<DomEnvironment>(), testFile),
- [&tFile](Path, DomItem &, DomItem &newIt) { tFile = newIt.fileObject(); },
+ [&tFile](Path, const DomItem &, const DomItem &newIt) { tFile = newIt.fileObject(); },
LoadOption::DefaultLoad);
env.loadPendingDependencies();
@@ -803,7 +803,7 @@ private slots:
DomItem tFile;
env.loadFile(
FileToLoad::fromFileSystem(env.ownerAs<DomEnvironment>(), testFile),
- [&tFile](Path, DomItem &, DomItem &newIt) { tFile = newIt.fileObject(); },
+ [&tFile](Path, const DomItem &, const DomItem &newIt) { tFile = newIt.fileObject(); },
LoadOption::DefaultLoad);
env.loadPendingDependencies();
@@ -864,7 +864,7 @@ private slots:
env.loadFile(
FileToLoad::fromFileSystem(env.ownerAs<DomEnvironment>(), fileName,
WithSemanticAnalysis),
- [&tFile](Path, DomItem &, DomItem &newIt) { tFile = newIt.fileObject(); },
+ [&tFile](Path, const DomItem &, const DomItem &newIt) { tFile = newIt.fileObject(); },
LoadOption::DefaultLoad);
env.loadPendingDependencies();
@@ -2464,12 +2464,12 @@ private slots:
env.loadFile(
FileToLoad::fromFileSystem(env.ownerAs<DomEnvironment>(), filePathA, options),
- [&fileA](Path, DomItem &, DomItem &newIt) { fileA = newIt.fileObject(); },
+ [&fileA](Path, const DomItem &, const DomItem &newIt) { fileA = newIt.fileObject(); },
LoadOption::DefaultLoad);
env.loadFile(
FileToLoad::fromFileSystem(env.ownerAs<DomEnvironment>(), filePathB, options),
- [&fileB](Path, DomItem &, DomItem &newIt) { fileB = newIt.fileObject(); },
+ [&fileB](Path, const DomItem &, const DomItem &newIt) { fileB = newIt.fileObject(); },
LoadOption::DefaultLoad);
env.loadPendingDependencies();
@@ -2491,14 +2491,14 @@ private:
env.loadFile(
FileToLoad::fromFileSystem(env.ownerAs<DomEnvironment>(), path, options),
- [&tFile](Path, DomItem &, DomItem &newIt) { tFile = newIt.fileObject(); },
+ [&tFile](Path, const DomItem &, const DomItem &newIt) { tFile = newIt.fileObject(); },
LoadOption::DefaultLoad);
env.loadPendingDependencies();
return tFile.rootQmlObject(GoTo::MostLikely);
}
- void fieldMemberExpressionHelper(DomItem &actual, const QStringList &expected)
+ void fieldMemberExpressionHelper(const DomItem &actual, const QStringList &expected)
{
Q_ASSERT(!expected.isEmpty());
auto currentString = expected.rbegin();
diff --git a/tests/benchmarks/qml/qmldom/tst_qmldomconstruction.cpp b/tests/benchmarks/qml/qmldom/tst_qmldomconstruction.cpp
index 2c713281ee..3c95b77784 100644
--- a/tests/benchmarks/qml/qmldom/tst_qmldomconstruction.cpp
+++ b/tests/benchmarks/qml/qmldom/tst_qmldomconstruction.cpp
@@ -61,7 +61,7 @@ void tst_qmldomconstruction::domConstructionTime()
env.loadFile(
FileToLoad::fromFileSystem(env.ownerAs<DomEnvironment>(), fileName, withScope),
- [&tFile](Path, DomItem &, DomItem &newIt) { tFile = newIt.fileObject(); },
+ [&tFile](Path, const DomItem &, const DomItem &newIt) { tFile = newIt.fileObject(); },
LoadOption::DefaultLoad);
env.loadPendingDependencies();
}