diff options
Diffstat (limited to 'tests/auto/qmldom/domdata/domitem')
59 files changed, 809 insertions, 2 deletions
diff --git a/tests/auto/qmldom/domdata/domitem/Base.qml b/tests/auto/qmldom/domdata/domitem/Base.qml new file mode 100644 index 0000000000..919619ffe6 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/Base.qml @@ -0,0 +1,5 @@ +import QtQuick + +Item { + property int a +} diff --git a/tests/auto/qmldom/domdata/domitem/Derived.qml b/tests/auto/qmldom/domdata/domitem/Derived.qml new file mode 100644 index 0000000000..8a6ce158c3 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/Derived.qml @@ -0,0 +1,5 @@ +import QtQuick + +Base { + property int b +} diff --git a/tests/auto/qmldom/domdata/domitem/ImportMeImplicitly.ui.qml b/tests/auto/qmldom/domdata/domitem/ImportMeImplicitly.ui.qml new file mode 100644 index 0000000000..169d162469 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/ImportMeImplicitly.ui.qml @@ -0,0 +1,6 @@ +import QtQuick + +Item { + property int helloProperty + +} diff --git a/tests/auto/qmldom/domdata/domitem/WithImplicitImport.qml b/tests/auto/qmldom/domdata/domitem/WithImplicitImport.qml new file mode 100644 index 0000000000..5560aee727 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/WithImplicitImport.qml @@ -0,0 +1,5 @@ +import QtQuick + +Item { + +} diff --git a/tests/auto/qmldom/domdata/domitem/Yyy.qml b/tests/auto/qmldom/domdata/domitem/Yyy.qml new file mode 100644 index 0000000000..b2235ff9cc --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/Yyy.qml @@ -0,0 +1,35 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick 2.0 +import QtQuick as QQ + +Zzz { + id: root + width: height + Rectangle { + color: "green" + anchors.fill: parent + height: root.foo.height + width: root.height + + } + + function lala() {} + property Rectangle foo: Rectangle{ height: 200 } + function longfunction(a, b, c = "c", d = "d"): string { + return "hehe: " + c + d + } + + // documentedFunction: is documented + // returns 'Good' + function documentedFunction(arg1, arg2 = "Qt"): string { + return "Good" + } + QQ.Rectangle { + color:"red" + } + + component IC: Zzz { property SomeBase data } + property SomeBase mySomeBase +} diff --git a/tests/auto/qmldom/domdata/domitem/aliasProperties.qml b/tests/auto/qmldom/domdata/domitem/aliasProperties.qml index c8653e3446..e2521b7afe 100644 --- a/tests/auto/qmldom/domdata/domitem/aliasProperties.qml +++ b/tests/auto/qmldom/domdata/domitem/aliasProperties.qml @@ -1,5 +1,5 @@ // Copyright (C) 2022 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick Item { diff --git a/tests/auto/qmldom/domdata/domitem/astComments.qml b/tests/auto/qmldom/domdata/domitem/astComments.qml new file mode 100644 index 0000000000..6fca4c69e5 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/astComments.qml @@ -0,0 +1,12 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick + +Item { + function ninja() { + // tst comment + const patron = 34; +/*Ast Comment*/ const ppp = 23; + } +} diff --git a/tests/auto/qmldom/domdata/domitem/attachedOrGroupedProperties.qml b/tests/auto/qmldom/domdata/domitem/attachedOrGroupedProperties.qml new file mode 100644 index 0000000000..ff7720506c --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/attachedOrGroupedProperties.qml @@ -0,0 +1,34 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick + +Text { + id: grouped + + // Dot notation + Binding { + grouped.font.family: "mono" + } + + // Group notation + Test { + id: test + myText { + font { + pixelSize: 12 + } + } + } + + component Test : Rectangle { + property Text myText: text1 + Text { + id: text1 + } + } + + Keys.onPressed: (event)=> { + + } +} diff --git a/tests/auto/qmldom/domdata/domitem/breakStatement.qml b/tests/auto/qmldom/domdata/domitem/breakStatement.qml new file mode 100644 index 0000000000..212fe095c0 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/breakStatement.qml @@ -0,0 +1,9 @@ +import QtQuick + +Item { + function f() { + break helloWorld; + break; + } + +} diff --git a/tests/auto/qmldom/domdata/domitem/callExpressions.qml b/tests/auto/qmldom/domdata/domitem/callExpressions.qml new file mode 100644 index 0000000000..d0de350fae --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/callExpressions.qml @@ -0,0 +1,61 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick + +Item { + property var p: f() + // crash if arguments are wrongly collected, e.g. because they are stolen from other unimplemented scriptelements + property var p2: f(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20) + + // dummy test: if these ones fail, then the deconstructing parameters cannot possibly work (they share some + // common code). + function deconstruct() { + let { a } = { a: 32, b: 42}, { b, c } = { b: 32, c: 42}, [ d, e, f ] = [ 111, 222, 333 ]; + let x = [,,,,[1,2,3],,]; + } + + function f(q,w,e,r,t,y) { + let helloF = 32 + return 42 + } + + function fWithDefault(q = 1, w = 2, e, r = 4, t, y = 6) { + let helloFWithDefault = {} + return 42 + } + + function marmelade(...onTheBread) { + let helloMarmelade = 123 + return 42 + } + + function marmelade2(spread, it,...onTheBread) { + let helloMarmelade2 = 123 + return 42 + } + + // check if nothing crashes for empty stuff + function empty({}, []) { + let {} = {}; + let [] = []; + } + + component MyType: Item{} + + function withTypes(a: int, b: MyType) {} + function empty() {} + signal mySignal() + + + property var p3: evil({ hello: "World", y: "yyy"}, [1,2,3], { is: {a: 111, lot: 222, of: 333, fun: 444, really: ["!",]}}) + + 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}) { + const helloEvil = "asdf" + return 42 + } + + +} diff --git a/tests/auto/qmldom/domdata/domitem/checkScopes.qml b/tests/auto/qmldom/domdata/domitem/checkScopes.qml new file mode 100644 index 0000000000..39903e9d90 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/checkScopes.qml @@ -0,0 +1,11 @@ +import QtQuick + +Item { + id: root + property int myInt + property int myInt2 + + myInt: 42 + myInt2: 123 + +} diff --git a/tests/auto/qmldom/domdata/domitem/commaExpression.qml b/tests/auto/qmldom/domdata/domitem/commaExpression.qml new file mode 100644 index 0000000000..c6576b5dad --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/commaExpression.qml @@ -0,0 +1,8 @@ +import QtQuick + +Item { + function f(a, b, c) { + a, b, c; + } + +} diff --git a/tests/auto/qmldom/domdata/domitem/conditionalExpression.qml b/tests/auto/qmldom/domdata/domitem/conditionalExpression.qml new file mode 100644 index 0000000000..027078b0ef --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/conditionalExpression.qml @@ -0,0 +1,8 @@ +import QtQuick + +Item { + function f(a, b, c) { + a?b:c; + } + +} diff --git a/tests/auto/qmldom/domdata/domitem/continueStatement.qml b/tests/auto/qmldom/domdata/domitem/continueStatement.qml new file mode 100644 index 0000000000..735ded4bda --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/continueStatement.qml @@ -0,0 +1,9 @@ +import QtQuick + +Item { + function f() { + continue helloWorld; + continue; + } + +} diff --git a/tests/auto/qmldom/domdata/domitem/crashes/bracketsInBinding.qml b/tests/auto/qmldom/domdata/domitem/crashes/bracketsInBinding.qml new file mode 100644 index 0000000000..bef28ffc45 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/crashes/bracketsInBinding.qml @@ -0,0 +1,5 @@ +import QtQuick + +Item { + property int foo: {} +} diff --git a/tests/auto/qmldom/domdata/domitem/crashes/lambda.qml b/tests/auto/qmldom/domdata/domitem/crashes/lambda.qml new file mode 100644 index 0000000000..cab0fec143 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/crashes/lambda.qml @@ -0,0 +1,7 @@ +import QtQuick.Controls + +Action { + onTriggered: foo(Bla.Bar, function() { + console.log("Hello") + }) +} diff --git a/tests/auto/qmldom/domdata/domitem/crashes/templateStrings.qml b/tests/auto/qmldom/domdata/domitem/crashes/templateStrings.qml new file mode 100644 index 0000000000..feb5646496 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/crashes/templateStrings.qml @@ -0,0 +1,10 @@ +import QtQuick + + +Item { + property string verbatim1: 'A "verbatim" string!' + property string verbatim2: "A 'verbatim' string\u2757" + property string verbatim3: `400 + 300 is ${400 + 300}. + +mutliline` +} diff --git a/tests/auto/qmldom/domdata/domitem/ecmaScriptClass.qml b/tests/auto/qmldom/domdata/domitem/ecmaScriptClass.qml new file mode 100644 index 0000000000..e86ea737e5 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/ecmaScriptClass.qml @@ -0,0 +1,44 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick + +Item { + +function f() { + +var count = 0; + +class Person { + constructor(name) { + this._name = name + } +} + +class Employee extends Person{ + + + constructor(name, age) { + super(name); + this._name = name; + this._age = age; + ++count; + } + + get /* do we get the comment? */ name() { + return this._name.toUpperCase(); + } + + set name(newName){ + if (newName) { + this._name = newName; + } + } + + static get count() { return count;} +} + + +} + +} diff --git a/tests/auto/qmldom/domdata/domitem/emptyMethodBody.qml b/tests/auto/qmldom/domdata/domitem/emptyMethodBody.qml new file mode 100644 index 0000000000..d987d3e649 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/emptyMethodBody.qml @@ -0,0 +1,6 @@ +import QtQuick + +Item { + function f(x) {} + +} diff --git a/tests/auto/qmldom/domdata/domitem/enumDeclarations.qml b/tests/auto/qmldom/domdata/domitem/enumDeclarations.qml new file mode 100644 index 0000000000..260f079fd6 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/enumDeclarations.qml @@ -0,0 +1,7 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick +Item { + enum Cats { Patron, Mafya, Kivrik = -1 } +} diff --git a/tests/auto/qmldom/domdata/domitem/fieldMemberExpression.qml b/tests/auto/qmldom/domdata/domitem/fieldMemberExpression.qml new file mode 100644 index 0000000000..8890a0c8cb --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/fieldMemberExpression.qml @@ -0,0 +1,32 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick + +Item { + id: root + + property int p: 42 + + property Item property1: Item { + property bool p: 44 + property Item property2: Item { + property string p: "Hello World" + property Item property3: Item { + property real p: 123 + } + } + } + + property var p1: p + property var p1Qualified: root.p + property var p1Bracket: root["p"] + property var p1Index: root[42] + property var p1Key: root[p] + + property var p2: property1.p + property var p2Qualified: root.property1.p + + property var p3: property1.property2.p + property var p3Qualified: root.property1.property2.p +} diff --git a/tests/auto/qmldom/domdata/domitem/fileLocationRegion.qml b/tests/auto/qmldom/domdata/domitem/fileLocationRegion.qml new file mode 100644 index 0000000000..f441efb5e2 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/fileLocationRegion.qml @@ -0,0 +1,8 @@ +import QtQuick + +Item { + property int helloWorld + + // before helloWorld binding + helloWorld: 42 // after helloWorld binding +} diff --git a/tests/auto/qmldom/domdata/domitem/fileLocationRegions/comments.qml b/tests/auto/qmldom/domdata/domitem/fileLocationRegions/comments.qml new file mode 100644 index 0000000000..a69505c544 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/fileLocationRegions/comments.qml @@ -0,0 +1,12 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQml + +/* +splitting +multiline +*/ +// single line +/* another comment */ +QtObject {} diff --git a/tests/auto/qmldom/domdata/domitem/fileLocationRegions/enums.qml b/tests/auto/qmldom/domdata/domitem/fileLocationRegions/enums.qml new file mode 100644 index 0000000000..e6e0f7a205 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/fileLocationRegions/enums.qml @@ -0,0 +1,12 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick + +Item { + enum OSC { + sin = 1, + saw, + tri = 16 + } +} diff --git a/tests/auto/qmldom/domdata/domitem/fileLocationRegions/functions.qml b/tests/auto/qmldom/domdata/domitem/fileLocationRegions/functions.qml new file mode 100644 index 0000000000..e045e5a4cc --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/fileLocationRegions/functions.qml @@ -0,0 +1,15 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick + +Item { + function a() : int {} + + component A : Item { + function b(k: int) : int {} + } + + signal k(int a) + signal kk(a: int) +} diff --git a/tests/auto/qmldom/domdata/domitem/fileLocationRegions/imports.qml b/tests/auto/qmldom/domdata/domitem/fileLocationRegions/imports.qml new file mode 100644 index 0000000000..ccf012bc63 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/fileLocationRegions/imports.qml @@ -0,0 +1,11 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick +import QtQml 2.15 +import QtQuick.Controls as Patron +import "../cats" + +Item { + +} diff --git a/tests/auto/qmldom/domdata/domitem/fileLocationRegions/pragmas.qml b/tests/auto/qmldom/domdata/domitem/fileLocationRegions/pragmas.qml new file mode 100644 index 0000000000..5f34f9ae33 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/fileLocationRegions/pragmas.qml @@ -0,0 +1,11 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +pragma Singleton +pragma ComponentBehavior: Bound +pragma FunctionSignatureBehavior: Enforced +pragma ValueTypeBehavior: Copy,Addressable + +import QtQml + +QtObject {} diff --git a/tests/auto/qmldom/domdata/domitem/finalizeScriptExpressions.qml b/tests/auto/qmldom/domdata/domitem/finalizeScriptExpressions.qml new file mode 100644 index 0000000000..5a0c811396 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/finalizeScriptExpressions.qml @@ -0,0 +1,29 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick + +Item { + property var binding + binding: 42 + + property var bindingInPropertyDefinition: 123 + + function return42(aa: Item = 33, bb: string = "Hello", cc = binding): int { + return 42 + } + function empty(aa: Item, bb: string, cc) {} + function full(aa: Item, bb: string, cc) + { + const x = 42; + const formula = (x + 5) * 2 + 10 - x + return formula; + } + + id: idBinding + + property var arrayBinding + arrayBinding:[] + property var objectBinding + objectBinding: Item {} +} diff --git a/tests/auto/qmldom/domdata/domitem/forStatements.qml b/tests/auto/qmldom/domdata/domitem/forStatements.qml new file mode 100644 index 0000000000..6c06098309 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/forStatements.qml @@ -0,0 +1,15 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick + +Item { + function f() { + let sum = 0, helloWorld = "hello" + for (let i = 0; i < 100; i = i + 1) { + sum = sum + 1 + for (;;) + i = 42 + } + } +} diff --git a/tests/auto/qmldom/domdata/domitem/ifStatements.qml b/tests/auto/qmldom/domdata/domitem/ifStatements.qml new file mode 100644 index 0000000000..90d1bd3ac8 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/ifStatements.qml @@ -0,0 +1,27 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQml + +QtObject { + function conditional() { + let i = 5 + if (i) + i = 42 + + if (i == 55) + i = 32 + else + i = i - 1 + + if (i == 42) { + i = 111 + } + + if (i == 746) { + i = 123 + } else { + i = 456 + } + } +} diff --git a/tests/auto/qmldom/domdata/domitem/import.js b/tests/auto/qmldom/domdata/domitem/import.js new file mode 100644 index 0000000000..e13db4c1a4 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/import.js @@ -0,0 +1,2 @@ +.import "main.js" as Main +console.log(Main.a); diff --git a/tests/auto/qmldom/domdata/domitem/inactiveVisitorMarkerCrash.qml b/tests/auto/qmldom/domdata/domitem/inactiveVisitorMarkerCrash.qml new file mode 100644 index 0000000000..c706251e47 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/inactiveVisitorMarkerCrash.qml @@ -0,0 +1,13 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick + +Window { + width: 640 + height: 480 + visible: true + title: qsTr("Hello World") + + HelloWorld { myP: 55; myPPP: 55 } +} diff --git a/tests/auto/qmldom/domdata/domitem/inlineComponents.qml b/tests/auto/qmldom/domdata/domitem/inlineComponents.qml new file mode 100644 index 0000000000..5ae0af4eb1 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/inlineComponents.qml @@ -0,0 +1,17 @@ +import QtQuick + +Item { + id: mainComponent + + component IC1: Item { property string firstIC } + component IC2: Item { property string secondIC } + + Item { + Item { + Item { + component IC3: Item { property string thirdIC } + } + } + } + +} diff --git a/tests/auto/qmldom/domdata/domitem/inlineObject.qml b/tests/auto/qmldom/domdata/domitem/inlineObject.qml new file mode 100644 index 0000000000..2f5941f4da --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/inlineObject.qml @@ -0,0 +1,7 @@ +import QtQuick + +Item { + component IC: Item {} + property var myItem: Item {} + property var myItem2: IC {} +} diff --git a/tests/auto/qmldom/domdata/domitem/invalidAliasProperties.qml b/tests/auto/qmldom/domdata/domitem/invalidAliasProperties.qml index 266e4139b7..7998642ef5 100644 --- a/tests/auto/qmldom/domdata/domitem/invalidAliasProperties.qml +++ b/tests/auto/qmldom/domdata/domitem/invalidAliasProperties.qml @@ -1,5 +1,5 @@ // Copyright (C) 2022 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick Item { diff --git a/tests/auto/qmldom/domdata/domitem/iterationStatements.qml b/tests/auto/qmldom/domdata/domitem/iterationStatements.qml new file mode 100644 index 0000000000..e75eeb2d7d --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/iterationStatements.qml @@ -0,0 +1,64 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick + +Item { + + function whileStatement() { + const i = 10; + while (i > 0) { + i = i -1; + while ( i > 100) {} + } + + while (i > 0) i = i-1 + } + + function doWhile() { + let a = 7; + do { + const b = a; + a = a - 1; + } while (a > 0) + + do a = a-1; while (a > 0) + } + + function forOf() { + const iterable = [[1,2], [3,4],] + for (var [a,b] of iterable) { + + let t; + for (const [a1, , a2, ...rest] of array) { + + } + for (const k of [1,2,3,4,,,]) { + t += k; + } + for (t of a) { + {} + } + for (t of a) t += k + } + } + + function forIn() { + const enumerable = { + list: [1, 2, 3, 4, 5], + name: 'John', + age: 25 + }; + + for (var [a,b,c,d] in enumerable) { + let t; + for (t in enumerable) { + {} + } + for (const [a1, , a2, ...rest] in enumerable.list) { + + } + for (let t in enumerable) t += k + } + } +} diff --git a/tests/auto/qmldom/domdata/domitem/lambdas.qml b/tests/auto/qmldom/domdata/domitem/lambdas.qml new file mode 100644 index 0000000000..c241bb77ae --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/lambdas.qml @@ -0,0 +1,41 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick + +Item { + signal helloSignal + + function method() { + console.log("helloMethod"); + let myLambda = function(a, b) { return a + b }; + let myArrow = (v, w) => a + b; + } + + onHelloSignal: function(x, y, z) { console.log("HelloLambda"); } + + function testNestedFunctions() { + function nested(tic, tac, toe) { return tic + tac/3 + toe/2} + nested() + } + + function generators() { + function *myGeneratorDeclaration(a, b) { yield 5 }; + let myGenerator = function*(tic, tac, toe) { yield tic + tac - toe }; + } + + function *generatorInQmlObject() { + function nested(q,w,e,r) { return q + w + e - r; } + function *nested2(a,z,e,r) { yield a + z + e - r; yield 42; } + yield 4; + yield* nested2(1,2,3,4); + const t = (function (a) { + return a + 100; + }); + } + function traditionalLambda() { + const tradition = (function (a) { + return a + 100; + }); + } +} diff --git a/tests/auto/qmldom/domdata/domitem/module.mjs b/tests/auto/qmldom/domdata/domitem/module.mjs new file mode 100644 index 0000000000..6838766329 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/module.mjs @@ -0,0 +1,6 @@ + +import { helper } from "utils.mjs" + +export function entry() { + return helper() +} diff --git a/tests/auto/qmldom/domdata/domitem/nullStatements.qml b/tests/auto/qmldom/domdata/domitem/nullStatements.qml new file mode 100644 index 0000000000..f4be9b30de --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/nullStatements.qml @@ -0,0 +1,14 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick + +Item { + function testForNull() { + for (;;) + {} + for (;;) + x + {} {} {} {} + } +} diff --git a/tests/auto/qmldom/domdata/domitem/objectBindings.qml b/tests/auto/qmldom/domdata/domitem/objectBindings.qml new file mode 100644 index 0000000000..c02a7113a5 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/objectBindings.qml @@ -0,0 +1,13 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick +import QtQuick as QQ + +Item { + id: root + Item {} + QQ.Item {} + property var x: root. + QQ.Drag {} +} diff --git a/tests/auto/qmldom/domdata/domitem/propertyBindings.qml b/tests/auto/qmldom/domdata/domitem/propertyBindings.qml new file mode 100644 index 0000000000..3c2931cb5d --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/propertyBindings.qml @@ -0,0 +1,13 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick + +Item { + property int a: 42 + property int b + + b: a + + id: root +} diff --git a/tests/auto/qmldom/domdata/domitem/returnStatements.qml b/tests/auto/qmldom/domdata/domitem/returnStatements.qml new file mode 100644 index 0000000000..4f503244fb --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/returnStatements.qml @@ -0,0 +1,14 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQml + +QtObject { + // TODO: Add a test for returning void + function returningFunction(i) { + if (i) + return 123; + else + return 1 + 2; + } +} diff --git a/tests/auto/qmldom/domdata/domitem/simplestJSStatement.js b/tests/auto/qmldom/domdata/domitem/simplestJSStatement.js new file mode 100644 index 0000000000..d954a87fc0 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/simplestJSStatement.js @@ -0,0 +1 @@ +let v=1; diff --git a/tests/auto/qmldom/domdata/domitem/simplestJSmodule.mjs b/tests/auto/qmldom/domdata/domitem/simplestJSmodule.mjs new file mode 100644 index 0000000000..401b25314b --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/simplestJSmodule.mjs @@ -0,0 +1 @@ +export function entry() {} diff --git a/tests/auto/qmldom/domdata/domitem/switchStatement.qml b/tests/auto/qmldom/domdata/domitem/switchStatement.qml new file mode 100644 index 0000000000..b2bacec8c0 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/switchStatement.qml @@ -0,0 +1,28 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQml + +QtObject { + function switchStatement(){ + const animals = "cat"; + const no = 0; + switch (animals) { + case "cat": + switch (no) { + case 0: return "patron"; + case 1: return "mafik"; + default: return "none"; + } + case "dog": { + // check if qqmljsscope is created for this case + const name = "tekila"; + let another = "mutantx"; + return name; + } + default: return "monster"; + case "moreCases!": + return "moreCaseClauses?" + } + } +} diff --git a/tests/auto/qmldom/domdata/domitem/tryStatements.qml b/tests/auto/qmldom/domdata/domitem/tryStatements.qml new file mode 100644 index 0000000000..5bd29db058 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/tryStatements.qml @@ -0,0 +1,10 @@ +import QtQuick + +Item { + function f() { + try { insideTry; } catch(catchExpression) { insideCatch; } finally { insideFinally; } + try { insideTry; } catch(catchExpression) { insideCatch; } + try { insideTry; } finally { insideFinally; } + } + +} diff --git a/tests/auto/qmldom/domdata/domitem/unaryExpressions/decrement.qml b/tests/auto/qmldom/domdata/domitem/unaryExpressions/decrement.qml new file mode 100644 index 0000000000..fb9fe6f252 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/unaryExpressions/decrement.qml @@ -0,0 +1,7 @@ +import QtQuick 2.15 + +Item { + function f(a) { + --a; + } +} diff --git a/tests/auto/qmldom/domdata/domitem/unaryExpressions/delete.qml b/tests/auto/qmldom/domdata/domitem/unaryExpressions/delete.qml new file mode 100644 index 0000000000..39063b8c2f --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/unaryExpressions/delete.qml @@ -0,0 +1,7 @@ +import QtQuick 2.15 + +Item { + function f(a) { + delete a; + } +} diff --git a/tests/auto/qmldom/domdata/domitem/unaryExpressions/increment.qml b/tests/auto/qmldom/domdata/domitem/unaryExpressions/increment.qml new file mode 100644 index 0000000000..e7acd3dfe5 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/unaryExpressions/increment.qml @@ -0,0 +1,7 @@ +import QtQuick 2.15 + +Item { + function f(a) { + ++a; + } +} diff --git a/tests/auto/qmldom/domdata/domitem/unaryExpressions/not.qml b/tests/auto/qmldom/domdata/domitem/unaryExpressions/not.qml new file mode 100644 index 0000000000..6c3a1aa035 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/unaryExpressions/not.qml @@ -0,0 +1,7 @@ +import QtQuick 2.15 + +Item { + function f(a) { + !a; + } +} diff --git a/tests/auto/qmldom/domdata/domitem/unaryExpressions/postDecrement.qml b/tests/auto/qmldom/domdata/domitem/unaryExpressions/postDecrement.qml new file mode 100644 index 0000000000..52d170fae0 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/unaryExpressions/postDecrement.qml @@ -0,0 +1,7 @@ +import QtQuick 2.15 + +Item { + function f(a) { + a--; + } +} diff --git a/tests/auto/qmldom/domdata/domitem/unaryExpressions/postIncrement.qml b/tests/auto/qmldom/domdata/domitem/unaryExpressions/postIncrement.qml new file mode 100644 index 0000000000..30b4da8c8f --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/unaryExpressions/postIncrement.qml @@ -0,0 +1,7 @@ +import QtQuick 2.15 + +Item { + function f(a) { + a++; + } +} diff --git a/tests/auto/qmldom/domdata/domitem/unaryExpressions/tilde.qml b/tests/auto/qmldom/domdata/domitem/unaryExpressions/tilde.qml new file mode 100644 index 0000000000..b35a00bd79 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/unaryExpressions/tilde.qml @@ -0,0 +1,7 @@ +import QtQuick 2.15 + +Item { + function f(a) { + ~a; + } +} diff --git a/tests/auto/qmldom/domdata/domitem/unaryExpressions/typeof.qml b/tests/auto/qmldom/domdata/domitem/unaryExpressions/typeof.qml new file mode 100644 index 0000000000..1696c5bd27 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/unaryExpressions/typeof.qml @@ -0,0 +1,7 @@ +import QtQuick 2.15 + +Item { + function f(a) { + typeof a; + } +} diff --git a/tests/auto/qmldom/domdata/domitem/unaryExpressions/unaryMinus.qml b/tests/auto/qmldom/domdata/domitem/unaryExpressions/unaryMinus.qml new file mode 100644 index 0000000000..e711c4d2f5 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/unaryExpressions/unaryMinus.qml @@ -0,0 +1,7 @@ +import QtQuick 2.15 + +Item { + function f(a) { + -a; + } +} diff --git a/tests/auto/qmldom/domdata/domitem/unaryExpressions/unaryPlus.qml b/tests/auto/qmldom/domdata/domitem/unaryExpressions/unaryPlus.qml new file mode 100644 index 0000000000..1b9ecbf5b5 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/unaryExpressions/unaryPlus.qml @@ -0,0 +1,7 @@ +import QtQuick 2.15 + +Item { + function f(a) { + +a; + } +} diff --git a/tests/auto/qmldom/domdata/domitem/unaryExpressions/void.qml b/tests/auto/qmldom/domdata/domitem/unaryExpressions/void.qml new file mode 100644 index 0000000000..d9396e1b39 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/unaryExpressions/void.qml @@ -0,0 +1,7 @@ +import QtQuick 2.15 + +Item { + function f(a) { + void a; + } +} diff --git a/tests/auto/qmldom/domdata/domitem/variableDeclarations.qml b/tests/auto/qmldom/domdata/domitem/variableDeclarations.qml new file mode 100644 index 0000000000..7d5d2ac9a5 --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/variableDeclarations.qml @@ -0,0 +1,23 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQuick + +Item { + function count() { + let one = 1, two = 2, three = 3, four = 4, five = 5, six = 6 + let testMe = 123 + } + // for now only numeric literal and string literal is supported + function f() { + let sum = 0, helloWorld = "hello" + const a = 3; + const b = "patron"; + var aa = helloWorld, bb = aa; + + const bool1 = true; + let bool2 = false; + var nullVar = null; + return sum; + } +} diff --git a/tests/auto/qmldom/domdata/domitem/visitTreeFilter.qml b/tests/auto/qmldom/domdata/domitem/visitTreeFilter.qml new file mode 100644 index 0000000000..5d0b06f91f --- /dev/null +++ b/tests/auto/qmldom/domdata/domitem/visitTreeFilter.qml @@ -0,0 +1,4 @@ + +QtObject { + property int helloProperty +} |