diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2025-02-06 17:29:09 +0100 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2025-02-28 20:11:32 +0100 |
| commit | d9d1c1fb5e324ce379bac4087178e63adc0c58ba (patch) | |
| tree | 16288ca09ef564428ce4f08fefadb3518b439ec1 /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | |
| parent | 024022700dcfbcf87ce91e261646c626deecd52d (diff) | |
QtQml: Support url and date in 'instanceof' and 'as'
Those have several possible representations. Besides
QQmlValueTypeWrapper, they can also be their own special heap objects
with extra methods, or VariantObject.
Also, remove some pointless restrictions in QmlCompiler that prevented
such as-casts from being compiled to C++. The code generator will
currently reject non-trivial type assertions for value types. Therefore
we don't have to take care of ValueTypeBehavior: Assertable, yet.
Also fix tst_qqmllanguage::instanceOf() to actually test something. So
far the return value of the expression was ignored for most data tags.
Pick-to: 6.9
Fixes: QTBUG-130291
Change-Id: I2facf48455a04a02a078615e5ebd4b1c26d1bd93
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp')
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index d3f917e280..e023d705d9 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -738,6 +738,10 @@ void tst_QmlCppCodegen::asCast() QCOMPARE(qvariant_cast<QObject *>(root->property("undefinedAsItem")), nullptr); QCOMPARE(qvariant_cast<QObject *>(root->property("undefinedAsRectangle")), nullptr); QCOMPARE(qvariant_cast<QObject *>(root->property("undefinedAsDummy")), nullptr); + + QCOMPARE(root->property("stringAsString"), u"a"_s); + QCOMPARE(root->property("urlAsUrl"), QUrl(u"http://example.com"_s)); + QCOMPARE(root->property("dateAsDate"), QDateTime(QDate(1996, 3, 3), QTime())); } void tst_QmlCppCodegen::attachedBaseEnum() |
