From 7894f271ab3714102e14744914de6d0549b9a7d8 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 9 Apr 2024 09:06:51 +0200 Subject: QmlCompiler: Allow coercion of lists to strings We have to allow two different forms of coercion. When printing directly through console.log etc, we add a pair of square brackets around the string. Fixes: QTBUG-119482 Change-Id: I03177e5905b41f5f0b5aaa867b18379eb9c7a243 Reviewed-by: Fabian Kosmale --- tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp') diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index fb1ab69c71..b8bb660516 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -155,6 +155,7 @@ private slots: void listLength(); void listOfInvisible(); void listPropertyAsModel(); + void listToString(); void lotsOfRegisters(); void math(); void mathMinMax(); @@ -2992,6 +2993,30 @@ void tst_QmlCppCodegen::listPropertyAsModel() QCOMPARE(children.count(), 5); } +void tst_QmlCppCodegen::listToString() +{ + QQmlEngine engine; + QQmlComponent c(&engine, QUrl(u"qrc:/qt/qml/TestTypes/listToString.qml"_s)); + QVERIFY2(c.isReady(), qPrintable(c.errorString())); + + QTest::ignoreMessage(QtDebugMsg, "[one,two]"); + QTest::ignoreMessage(QtDebugMsg, "one,two"); + QTest::ignoreMessage(QtDebugMsg, "[1,2]"); + QTest::ignoreMessage(QtDebugMsg, "1,2"); + QTest::ignoreMessage( + QtDebugMsg, + QRegularExpression("\\[QObject_QML_[0-9]+\\(0x[0-9a-f]+\\)," + "QObject_QML_[0-9]+\\(0x[0-9a-f]+\\)\\]")); + QTest::ignoreMessage( + QtDebugMsg, + QRegularExpression("QObject_QML_[0-9]+\\(0x[0-9a-f]+\\)," + "QObject_QML_[0-9]+\\(0x[0-9a-f]+\\)")); + + QTest::ignoreMessage(QtDebugMsg, "[a,b]"); + + QScopedPointer o(c.create()); +} + void tst_QmlCppCodegen::lotsOfRegisters() { QQmlEngine engine; -- cgit v1.2.3