diff options
author | Semih Yavuz <semih.yavuz@qt.io> | 2023-08-30 14:50:11 +0200 |
---|---|---|
committer | Semih Yavuz <semih.yavuz@qt.io> | 2023-09-12 20:00:25 +0200 |
commit | 7c3199311f7927e22c5ccb24387565909c26e85b (patch) | |
tree | 7a776b93da0d89478fbaeab30a73ff9247fe1c06 /tests/auto/qml/qmlformat | |
parent | 44a78d01bf65434ee0b26bca3cc2fd3c472abf0c (diff) |
qmlformat: fix incorrect destructuring of objects
When creating dom objects, we populate MethodParameter::value for object
or array deconstruction in function arguments but we don't write them out.
Pick-to: 6.6 6.5
Change-Id: Id02ac6ac28ec8ae3d25a2f37de3361ecff3a3bf6
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlformat')
3 files changed, 36 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlformat/data/destructuringFunctionParameter.formatted.qml b/tests/auto/qml/qmlformat/data/destructuringFunctionParameter.formatted.qml new file mode 100644 index 0000000000..0bfcc58179 --- /dev/null +++ b/tests/auto/qml/qmlformat/data/destructuringFunctionParameter.formatted.qml @@ -0,0 +1,24 @@ +import QtQml + +QtObject { + + function evil({ + hello = "world", + x = 42 + }, [n = 42, m = 43, o = 44], { + destructuring, + is = { + a, + lot, + of + }, + fun = 42 + } = { + destructuring: 123, + is: { + x: 123 + }, + fun: 456 + }) { + } +} diff --git a/tests/auto/qml/qmlformat/data/destructuringFunctionParameter.qml b/tests/auto/qml/qmlformat/data/destructuringFunctionParameter.qml new file mode 100644 index 0000000000..f41661ed67 --- /dev/null +++ b/tests/auto/qml/qmlformat/data/destructuringFunctionParameter.qml @@ -0,0 +1,9 @@ +import QtQml + +QtObject { + + function evil({ hello = "world", x = 42 }, + [n = 42, m = 43, o = 44], + { destructuring, is = {a, lot, of}, fun = 42 } = {destructuring : 123, is : {x : 123}, fun : 456}) { + } +} diff --git a/tests/auto/qml/qmlformat/tst_qmlformat.cpp b/tests/auto/qml/qmlformat/tst_qmlformat.cpp index 013ba61409..774893bcfd 100644 --- a/tests/auto/qml/qmlformat/tst_qmlformat.cpp +++ b/tests/auto/qml/qmlformat/tst_qmlformat.cpp @@ -339,6 +339,9 @@ void TestQmlformat::testFormat_data() QTest::newRow("objectDestructuring") << "objectDestructuring.qml" << "objectDestructuring.formatted.qml" << QStringList{} << RunOption::OnCopy; + QTest::newRow("destructuringFunctionParameter") + << "destructuringFunctionParameter.qml" + << "destructuringFunctionParameter.formatted.qml" << QStringList{} << RunOption::OnCopy; } void TestQmlformat::testFormat() |