aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMaximilian Goldstein <max.goldstein@qt.io>2021-05-12 13:23:59 +0200
committerMaximilian Goldstein <max.goldstein@qt.io>2021-05-14 10:43:41 +0200
commit401b515626c46d915a8394a98fbe95cf1c6f4aa4 (patch)
tree2b3b78b371534b18f1bdb6ab38411743ab1479f4 /tests
parente6bc19d518b92d47639de871e255bfe73118cd17 (diff)
qmllint: Utilize qjsroot.qmltypes
Previously for some types like QString, QDateTime and QRegularExpression and others there was no sensible type information available. Now that we have qjsroot.qmltypes we can refer to its type information in order to resolve these types. Change-Id: Iea88cf467c694299396630e0f180ca6ff4ca3847 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qmllint/data/qjsroot.qml20
-rw-r--r--tests/auto/qml/qmllint/tst_qmllint.cpp1
2 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/qml/qmllint/data/qjsroot.qml b/tests/auto/qml/qmllint/data/qjsroot.qml
new file mode 100644
index 0000000000..c5995b9576
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/qjsroot.qml
@@ -0,0 +1,20 @@
+import QtQuick
+
+QtObject {
+ property var locale: Qt.locale()
+ property date currentDate: new Date()
+ property RegularExpressionValidator validator: RegularExpressionValidator { regularExpression: /20([0-9]+)/ };
+ property double pi: 3.14
+
+ // Test date
+ property string dateString: currentDate.toLocaleDateString();
+
+ // Test string
+ property int dateStringDotIndex: dateString.indexOf(".")
+
+ // Test regularExpression
+ property var dateStringReplace: validator.regularExpression.exec(dateString)
+
+ // Test double
+ property string fixedPi: pi.toFixed(1)
+}
diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp
index df303088bf..d6f5088a9d 100644
--- a/tests/auto/qml/qmllint/tst_qmllint.cpp
+++ b/tests/auto/qml/qmllint/tst_qmllint.cpp
@@ -747,6 +747,7 @@ void TestQmllint::cleanQmlCode_data()
QTest::newRow("aliasToList") << QStringLiteral("aliasToList.qml");
QTest::newRow("QVariant") << QStringLiteral("qvariant.qml");
QTest::newRow("Accessible") << QStringLiteral("accessible.qml");
+ QTest::newRow("qjsroot") << QStringLiteral("qjsroot.qml");
}
void TestQmllint::cleanQmlCode()