From 74060990bc83b8714d017da6b2238b00e6aba0e4 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 26 Jan 2021 10:17:05 +0100 Subject: QQmlJSTypeReader: Guard against empty JS files Change-Id: Ie52ce15b7fa960ce84a6d17a21a0e307a38c726e Reviewed-by: Fabian Kosmale --- tests/auto/qml/qmllint/data/Empty.js | 0 tests/auto/qml/qmllint/data/badScript.qml | 6 ++++++ tests/auto/qml/qmllint/tst_qmllint.cpp | 4 ++++ 3 files changed, 10 insertions(+) create mode 100644 tests/auto/qml/qmllint/data/Empty.js create mode 100644 tests/auto/qml/qmllint/data/badScript.qml (limited to 'tests/auto/qml') diff --git a/tests/auto/qml/qmllint/data/Empty.js b/tests/auto/qml/qmllint/data/Empty.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/qmllint/data/badScript.qml b/tests/auto/qml/qmllint/data/badScript.qml new file mode 100644 index 0000000000..13f3e33acc --- /dev/null +++ b/tests/auto/qml/qmllint/data/badScript.qml @@ -0,0 +1,6 @@ +import QtQml +import "Empty.js" as Foo + +QtObject { + objectName: Foo.stuff() +} diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp index f5ef58940b..c1ccae7235 100644 --- a/tests/auto/qml/qmllint/tst_qmllint.cpp +++ b/tests/auto/qml/qmllint/tst_qmllint.cpp @@ -269,6 +269,10 @@ void TestQmllint::dirtyQmlCode_data() << QStringLiteral("badAliasObject.qml") << QString("Warning: Property \"wrongwrongwrong\" not found on type \"QtObject\"") << QString(); + QTest::newRow("badScript") + << QStringLiteral("badScript.qml") + << QString("Warning: Property \"stuff\" not found on type \"Empty\"") + << QString(); } void TestQmllint::dirtyQmlCode() -- cgit v1.2.3