diff options
Diffstat (limited to 'tests/auto/qml/qqmllanguage/data')
57 files changed, 811 insertions, 11 deletions
diff --git a/tests/auto/qml/qqmllanguage/data/AliasHolder.qml b/tests/auto/qml/qqmllanguage/data/AliasHolder.qml new file mode 100644 index 0000000000..42aed6ed26 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/AliasHolder.qml @@ -0,0 +1,6 @@ +import QtQml + +QtObject { + property alias strokeStyle: path.restoreMode + property Binding p: Binding { id: path } +} diff --git a/tests/auto/qml/qqmllanguage/data/CompositeTypeWithEnumSelfReference.qml b/tests/auto/qml/qqmllanguage/data/CompositeTypeWithEnumSelfReference.qml new file mode 100644 index 0000000000..0ec43bf7aa --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/CompositeTypeWithEnumSelfReference.qml @@ -0,0 +1,8 @@ +import QtQml +import Test + +QtObject { + enum A { B, C, D } + property int e: CompositeTypeWithEnumSelfReference.C + property int f: CompositeTypeWithEnumSelfReference.A.D +} diff --git a/tests/auto/qml/qqmllanguage/data/Comps/IconPropertiesGroup.qml b/tests/auto/qml/qqmllanguage/data/Comps/IconPropertiesGroup.qml new file mode 100644 index 0000000000..232c755bfb --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/Comps/IconPropertiesGroup.qml @@ -0,0 +1,5 @@ +import QtQuick + +QtObject { + function dothing() { console.log("do") } +} diff --git a/tests/auto/qml/qqmllanguage/data/Comps/OverlayDrawer.qml b/tests/auto/qml/qqmllanguage/data/Comps/OverlayDrawer.qml new file mode 100644 index 0000000000..713c760a04 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/Comps/OverlayDrawer.qml @@ -0,0 +1,5 @@ +import QtQuick + +Item { + property IconPropertiesGroup handleOpenIcon: IconPropertiesGroup {} +} diff --git a/tests/auto/qml/qqmllanguage/data/Comps/qmldir b/tests/auto/qml/qqmllanguage/data/Comps/qmldir new file mode 100644 index 0000000000..0a68a376f6 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/Comps/qmldir @@ -0,0 +1,4 @@ +module Comps +OverlayDrawer 254.0 OverlayDrawer.qml +IconPropertiesGroup 254.0 IconPropertiesGroup.qml + diff --git a/tests/auto/qml/qqmllanguage/data/DeepAliasOnIC.qml b/tests/auto/qml/qqmllanguage/data/DeepAliasOnIC.qml new file mode 100644 index 0000000000..134eacf913 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/DeepAliasOnIC.qml @@ -0,0 +1,27 @@ +import QtQml + +QtObject { + id: root + objectName: "theRoot" + + component ObjectWithColor: QtObject { + property string color + property var varvar + } + + property ObjectWithColor border: ObjectWithColor { + objectName: root.objectName + color: root.trueBorderColor + varvar: root.trueBorderVarvar + } + + readonly property rect readonlyRect: ({x: 12, y: 13, width: 14, height: 15}) + + property alias borderObjectName: root.border.objectName + property alias borderColor: root.border.color + property alias borderVarvar: root.border.varvar + property alias readonlyRectX: root.readonlyRect.x + + property string trueBorderColor: "green" + property var trueBorderVarvar: 1234 +} diff --git a/tests/auto/qml/qqmllanguage/data/SingletonWithRequiredProperties/SingletonWithRequired1.qml b/tests/auto/qml/qqmllanguage/data/SingletonWithRequiredProperties/SingletonWithRequired1.qml new file mode 100644 index 0000000000..f549e851a3 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/SingletonWithRequiredProperties/SingletonWithRequired1.qml @@ -0,0 +1,6 @@ +pragma Singleton +import QtQml + +QtObject { + required property int i +} diff --git a/tests/auto/qml/qqmllanguage/data/SingletonWithRequiredProperties/SingletonWithRequired2.qml b/tests/auto/qml/qqmllanguage/data/SingletonWithRequiredProperties/SingletonWithRequired2.qml new file mode 100644 index 0000000000..1f9e7e3a42 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/SingletonWithRequiredProperties/SingletonWithRequired2.qml @@ -0,0 +1,8 @@ +pragma Singleton +import QtQml + +QtObject { + property QtObject o: QtObject { + required property int i + } +} diff --git a/tests/auto/qml/qqmllanguage/data/SingletonWithRequiredProperties/qmldir b/tests/auto/qml/qqmllanguage/data/SingletonWithRequiredProperties/qmldir new file mode 100644 index 0000000000..46e397ca76 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/SingletonWithRequiredProperties/qmldir @@ -0,0 +1,4 @@ +module SingletonWithRequiredProperties + +singleton SingletonWithRequired1 1.0 SingletonWithRequired1.qml +singleton SingletonWithRequired2 1.0 SingletonWithRequired2.qml diff --git a/tests/auto/qml/qqmllanguage/data/TypeAnnotationCycle1.qml b/tests/auto/qml/qqmllanguage/data/TypeAnnotationCycle1.qml new file mode 100644 index 0000000000..6186faa00b --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/TypeAnnotationCycle1.qml @@ -0,0 +1,15 @@ +import QtQml + +QtObject { + id: self + property QtObject b + property Component c + function a() : TypeAnnotationCycle2 { return c.createObject() as TypeAnnotationCycle2 } + + Component.onCompleted: { + c = Qt.createComponent("TypeAnnotationCycle2.qml"); + let v = a(); + v.addTypeAnnotationCycle1(self as TypeAnnotationCycle1); + b = v.b; + } +} diff --git a/tests/auto/qml/qqmllanguage/data/TypeAnnotationCycle2.qml b/tests/auto/qml/qqmllanguage/data/TypeAnnotationCycle2.qml new file mode 100644 index 0000000000..9e3ffa86d2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/TypeAnnotationCycle2.qml @@ -0,0 +1,6 @@ +import QtQml + +QtObject { + property QtObject b + function addTypeAnnotationCycle1(c: TypeAnnotationCycle1) { b = c; } +} diff --git a/tests/auto/qml/qqmllanguage/data/UIToolBar.qml b/tests/auto/qml/qqmllanguage/data/UIToolBar.qml new file mode 100644 index 0000000000..08a22d2492 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/UIToolBar.qml @@ -0,0 +1,10 @@ +import QtQml + +QtObject { + id: root + signal doneClicked() + signal foo() + + onObjectNameChanged: foo() + Component.onCompleted: root.foo.connect(root.doneClicked) +} diff --git a/tests/auto/qml/qqmllanguage/data/alias.16.qml b/tests/auto/qml/qqmllanguage/data/alias.16.qml index 4637aec58f..335d240003 100644 --- a/tests/auto/qml/qqmllanguage/data/alias.16.qml +++ b/tests/auto/qml/qqmllanguage/data/alias.16.qml @@ -2,7 +2,7 @@ import QtQuick 2.0 import QtQuick.Window 2.0 Window { - visible: true + visible: false property alias list: repeater.model diff --git a/tests/auto/qml/qqmllanguage/data/aliasWriter.qml b/tests/auto/qml/qqmllanguage/data/aliasWriter.qml new file mode 100644 index 0000000000..4001c2af34 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/aliasWriter.qml @@ -0,0 +1,5 @@ +import QtQml + +AliasHolder { + strokeStyle: 1 +} diff --git a/tests/auto/qml/qqmllanguage/data/ambiguousComponents.qml b/tests/auto/qml/qqmllanguage/data/ambiguousComponents.qml new file mode 100644 index 0000000000..64c31b46d6 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/ambiguousComponents.qml @@ -0,0 +1,16 @@ +import QtQuick +import Comps as Comps + +Comps.OverlayDrawer { + id: self + + property var dothing + + Component.onCompleted: dothing = handleOpenIcon.dothing + + function dodo() { dothing() } + + function testInstanceOf() : bool { + return self instanceof Comps.OverlayDrawer + } +} diff --git a/tests/auto/qml/qqmllanguage/data/asCastToInlineComponent.qml b/tests/auto/qml/qqmllanguage/data/asCastToInlineComponent.qml new file mode 100644 index 0000000000..428ccd5eef --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/asCastToInlineComponent.qml @@ -0,0 +1,16 @@ +import QtQml + +QtObject { + id: root + + component MyItem: QtObject { + property int value: 10 + onValueChanged: root.objectName = "value: " + value + } + + property Instantiator i: Instantiator { + id: loader + delegate: MyItem {} + onObjectChanged: (loader.object as MyItem).value = 20 + } +} diff --git a/tests/auto/qml/qqmllanguage/data/asValueType.qml b/tests/auto/qml/qqmllanguage/data/asValueType.qml new file mode 100644 index 0000000000..b51dc9c6ec --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/asValueType.qml @@ -0,0 +1,20 @@ +pragma ValueTypeBehavior: Addressable +import QtQml +import StaticTest + +QtObject { + property var a + property rect b: a as rect + property bool c: a instanceof rect + property bool d: ({x: 10, y: 20}) instanceof point + property var e: ({x: 10, y: 20}) as point + property var f: "red" as withString + property var g: "green" as string + property rect bb + property var p: bb as size; + property var q: this as size; + property var r: ({}) as size; + property var s: 11 as size; + property var t: Component as size; + property var u: Qt as size; +} diff --git a/tests/auto/qml/qqmllanguage/data/asValueTypeGood.qml b/tests/auto/qml/qqmllanguage/data/asValueTypeGood.qml new file mode 100644 index 0000000000..777ada3848 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/asValueTypeGood.qml @@ -0,0 +1,35 @@ +pragma ValueTypeBehavior: Assertable +import QtQml as Q +import StaticTest as S + +Q.QtObject { + property var a + property rect b: a as Q.rect + property bool c: a instanceof Q.rect + property bool d: ({x: 10, y: 20}) instanceof Q.point + property var e: ({x: 10, y: 20}) as Q.point + property var f: "red" as S.withString + property var g: "green" as Q.string + + property var h: new S.withString("red") + property var i: { + let p = new Q.point; + p.x = 10 + p.y = 20 + return p + } + + property var j: 4.0 as Q.int + property var k: (4.5 / 1.5) as Q.int + property var l: 5 as Q.double + property var m: "something" as Q.var + property var n: 1 as Q.bool + property var o: Infinity as Q.int + + property var p: b as Q.size; + property var q: this as Q.size; + property var r: ({}) as Q.size; + property var s: 11 as Q.size; + property var t: Q.Component as Q.size; + property var u: Q.Qt as Q.size; +} diff --git a/tests/auto/qml/qqmllanguage/data/badICAnnotation.qml b/tests/auto/qml/qqmllanguage/data/badICAnnotation.qml new file mode 100644 index 0000000000..6f0db53f2a --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/badICAnnotation.qml @@ -0,0 +1,25 @@ +import QtQml + +QtObject { + id: self + + function doStuff(status: Binding.NotAnInlineComponent) : int { + return status + } + + function doStuff2(status: InlineComponentBase.IC) : QtObject { + return status + } + + function doStuff3(status: InlineComponentBase.NotIC) : QtObject { + return status + } + + property InlineComponentBase.IC ic: InlineComponentBase.IC {} + + property int a: doStuff(5) + property QtObject b: doStuff2(ic) + property QtObject c: doStuff3(ic) + property QtObject d: doStuff2(self) +} + diff --git a/tests/auto/qml/qqmllanguage/data/SingletonTest.qml b/tests/auto/qml/qqmllanguage/data/badSingleton/SingletonTest.qml index 70e1671754..70e1671754 100644 --- a/tests/auto/qml/qqmllanguage/data/SingletonTest.qml +++ b/tests/auto/qml/qqmllanguage/data/badSingleton/SingletonTest.qml diff --git a/tests/auto/qml/qqmllanguage/data/qmldir b/tests/auto/qml/qqmllanguage/data/badSingleton/qmldir index c946de657c..c946de657c 100644 --- a/tests/auto/qml/qqmllanguage/data/qmldir +++ b/tests/auto/qml/qqmllanguage/data/badSingleton/qmldir diff --git a/tests/auto/qml/qqmllanguage/data/qtbug_85932.qml b/tests/auto/qml/qqmllanguage/data/badSingleton/qtbug_85932.qml index aa21558220..aa21558220 100644 --- a/tests/auto/qml/qqmllanguage/data/qtbug_85932.qml +++ b/tests/auto/qml/qqmllanguage/data/badSingleton/qtbug_85932.qml diff --git a/tests/auto/qml/qqmllanguage/data/corpseInQmlList.qml b/tests/auto/qml/qqmllanguage/data/corpseInQmlList.qml new file mode 100644 index 0000000000..dc0e145064 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/corpseInQmlList.qml @@ -0,0 +1,13 @@ +import QtQml + +QtObject { + property var b; + + function returnList(a: QtObject) : list<QtObject> { + return [a] + } + + function setB(a: QtObject) { + b = { b: returnList(a) } + } +} diff --git a/tests/auto/qml/qqmllanguage/data/deepAliasOnICUser.qml b/tests/auto/qml/qqmllanguage/data/deepAliasOnICUser.qml new file mode 100644 index 0000000000..50eaa7c3e2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/deepAliasOnICUser.qml @@ -0,0 +1,9 @@ +import QtQml + +DeepAliasOnIC { + borderObjectName: "theLeaf" + borderColor: "black" + borderVarvar: "mauve" +} + + diff --git a/tests/auto/qml/qqmllanguage/data/deepAliasOnReadonly.qml b/tests/auto/qml/qqmllanguage/data/deepAliasOnReadonly.qml new file mode 100644 index 0000000000..f5ae62406b --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/deepAliasOnReadonly.qml @@ -0,0 +1,5 @@ +import QtQml + +DeepAliasOnIC { + readonlyRectX: 55 +} diff --git a/tests/auto/qml/qqmllanguage/data/derivedFromUnexposedBase.qml b/tests/auto/qml/qqmllanguage/data/derivedFromUnexposedBase.qml new file mode 100644 index 0000000000..b508474a36 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/derivedFromUnexposedBase.qml @@ -0,0 +1,6 @@ +import Test + +DerivedFromUnexposedBase { + group.value: 42 + groupGadget.value: 42 +} diff --git a/tests/auto/qml/qqmllanguage/data/dynamicGroupPropertyRejected.qml b/tests/auto/qml/qqmllanguage/data/dynamicGroupPropertyRejected.qml new file mode 100644 index 0000000000..2fffea25c6 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/dynamicGroupPropertyRejected.qml @@ -0,0 +1,5 @@ +import Test + +DerivedFromUnexposedBase { + dynamic.value: "This should fail" +} diff --git a/tests/auto/qml/qqmllanguage/data/enumPropsManyUnderlyingTypes.qml b/tests/auto/qml/qqmllanguage/data/enumPropsManyUnderlyingTypes.qml new file mode 100644 index 0000000000..b713d2aa24 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/enumPropsManyUnderlyingTypes.qml @@ -0,0 +1,10 @@ +import Test + +EnumPropsManyUnderlyingTypes { + si8prop: EnumPropsManyUnderlyingTypes.ResolvedValue + ui8prop: EnumPropsManyUnderlyingTypes.ResolvedValue + si16prop: EnumPropsManyUnderlyingTypes.ResolvedValue + ui16prop: EnumPropsManyUnderlyingTypes.ResolvedValue + si64prop: EnumPropsManyUnderlyingTypes.ResolvedValue + ui64prop: EnumPropsManyUnderlyingTypes.ResolvedValue +} diff --git a/tests/auto/qml/qqmllanguage/data/enumScopes.qml b/tests/auto/qml/qqmllanguage/data/enumScopes.qml new file mode 100644 index 0000000000..c71872387f --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/enumScopes.qml @@ -0,0 +1,16 @@ +import QtQml 2.15 +import EnumScopeTest 1.0 + +QtObject { + property NonSingleton n: NonSingleton { + id: nonSingleton + } + + property bool singletonUnscoped: Singleton.enumProperty === Singleton.EnumValue2 + property bool singletonScoped: Singleton.enumProperty === Singleton.EnumType.EnumValue2 + property bool nonSingletonUnscoped: nonSingleton.enumProperty === NonSingleton.EnumValue2 + property bool nonSingletonScoped: nonSingleton.enumProperty === NonSingleton.EnumType.EnumValue2 + + property int singletonScopedValue: EnumProviderSingleton.Expected.Value + property int singletonUnscopedValue: EnumProviderSingleton.Value +} diff --git a/tests/auto/qml/qqmllanguage/data/inlineComponentWithImplicitComponent.qml b/tests/auto/qml/qqmllanguage/data/inlineComponentWithImplicitComponent.qml new file mode 100644 index 0000000000..902dfb501d --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/inlineComponentWithImplicitComponent.qml @@ -0,0 +1,27 @@ +import QtQml + +QtObject { + component C1: QtObject { + property Component comp: null + } + + component C2: C1 { + comp: QtObject { + objectName: "green" + } + } + + component C3: C1 { + comp: Component { + QtObject { + objectName: "blue" + } + } + } + + property QtObject c1: C1 {} + property QtObject c2: C2 {} + property QtObject c3: C3 {} + + objectName: c2.comp.createObject().objectName + " " + c3.comp.createObject().objectName +} diff --git a/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.1.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.1.errors.txt index d76f18ba89..5ddb8a2e6d 100644 --- a/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.1.errors.txt +++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.1.errors.txt @@ -1 +1 @@ -5:5:Invalid grouped property access: Property "o" with type "QVariant", which is not a value type +5:7:Cannot assign to non-existent property "blah" diff --git a/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.3.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.3.errors.txt index 9a0422753f..ced96fba83 100644 --- a/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.3.errors.txt +++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.3.errors.txt @@ -1 +1 @@ -4:5:Invalid grouped property access: Property "customType" with type "MyCustomVariantType", which is not a value type +4:5:Invalid grouped property access: Property "customType" with type "MyCustomVariantType", which is neither a value nor an object type diff --git a/tests/auto/qml/qqmllanguage/data/invokableCtors.qml b/tests/auto/qml/qqmllanguage/data/invokableCtors.qml new file mode 100644 index 0000000000..35a8d7bf08 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invokableCtors.qml @@ -0,0 +1,12 @@ +import QtQml as QQ +import Test as VV + +QQ.QtObject { + property QQ.QtObject oo: new QQ.QtObject() + property QQ.QtObject pp: new QQ.QtObject(oo) + property VV.vv v: new VV.vv("green") + + property VV.InvokableSingleton i: new VV.InvokableSingleton(5, oo) + property VV.InvokableExtended k: new VV.InvokableExtended() + property VV.InvokableUncreatable l: new VV.InvokableUncreatable() +} diff --git a/tests/auto/qml/qqmllanguage/data/isNullOrUndefined_interpreter.qml b/tests/auto/qml/qqmllanguage/data/isNullOrUndefined_interpreter.qml new file mode 100644 index 0000000000..460d4667f8 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/isNullOrUndefined_interpreter.qml @@ -0,0 +1,22 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQml + +QtObject { + id: self + property int a: 3 + property var result + Component.onCompleted: { + var sum = 0 + let f = function() { + return self.notthere ?? self.a + } + + // Not enough times for the jit to kick in (should run on the interpreter) + for (let i = 0; i < 1; i++) { + sum = sum + f() + } + result = sum + } +} diff --git a/tests/auto/qml/qqmllanguage/data/isNullOrUndefined_jit.qml b/tests/auto/qml/qqmllanguage/data/isNullOrUndefined_jit.qml new file mode 100644 index 0000000000..43c82f436c --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/isNullOrUndefined_jit.qml @@ -0,0 +1,22 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtQml + +QtObject { + id: self + property int a: 3 + property int result + Component.onCompleted: { + var sum = 0 + let f = function() { + return self.notthere ?? self.a + } + + // Enough times for the jit to kick in (should run on the jit) + for (let i = 0; i < 50; i++) { + sum = sum + f() + } + result = sum + } +} diff --git a/tests/auto/qml/qqmllanguage/data/jitExceptions.qml b/tests/auto/qml/qqmllanguage/data/jitExceptions.qml new file mode 100644 index 0000000000..c5e11af31d --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/jitExceptions.qml @@ -0,0 +1,16 @@ +import QtQml + +QtObject { + function burn() { + return control.font + } + + Component.onCompleted: { + for (var a = 0; a < 10; ++a) { + try { burn() } catch(e) {} + } + + burn(); + } + +} diff --git a/tests/auto/qml/qqmllanguage/data/jsonArrayProperty.qml b/tests/auto/qml/qqmllanguage/data/jsonArrayProperty.qml new file mode 100644 index 0000000000..5bd563a288 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/jsonArrayProperty.qml @@ -0,0 +1,191 @@ +import QtQml +import TypeWithQJsonArrayProperty + +TypeWithQJsonArrayProperty { + function jsArray() { return [1, 2, 3] } + + jsonArray: jsArray() + + property list<int> concatenatedJsonArray: jsonArray.concat([4, 5, 6]) + property list<int> concatenatedJsArray: jsArray().concat([4, 5, 6]) + + property bool entriesMatch: { + var iterator = jsonArray.entries(); + for (var [index, element] of jsArray().entries()) { + var v = iterator.next().value; + if (index !== v[0] || element !== v[1]) { + console.log(index, v[0], element, v[1]); + return false; + } + } + + var iterator = jsArray().entries(); + for (var [index, element] of jsonArray.entries()) { + var v = iterator.next().value; + if (index !== v[0] || element !== v[1]) { + console.log(index, v[0], element, v[1]); + return false; + } + } + + return true; + } + + property bool jsonArrayEvery: jsonArray.every(element => element != 0) + property bool jsArrayEvery: jsArray().every(element => element != 0) + + property list<int> jsonArrayFiltered: jsonArray.filter(element => element > 2) + property list<int> jsArrayFiltered: jsArray().filter(element => element > 2) + + property int jsonArrayFind: jsonArray.find(element => element === 2) + property int jsArrayFind: jsArray().find(element => element === 2) + + property int jsonArrayFindIndex: jsonArray.findIndex(element => element === 1) + property int jsArrayFindIndex: jsArray().findIndex(element => element === 1) + + property string jsonArrayForEach + property string jsArrayForEach + + property bool jsonArrayIncludes: jsonArray.includes(3) + property bool jsArrayIncludes: jsArray().includes(3) + + property int jsonArrayIndexOf: jsonArray.indexOf(2) + property int jsArrayIndexOf: jsArray().indexOf(2) + + property string jsonArrayJoin: jsonArray.join() + property string jsArrayJoin: jsArray().join() + + property bool keysMatch: { + var iterator = jsonArray.keys(); + for (var index of jsArray().keys()) { + var v = iterator.next().value; + if (index !== v) { + console.log(index, v); + return false; + } + } + + var iterator = jsArray().keys(); + for (var index of jsonArray.keys()) { + var v = iterator.next().value; + if (index !== v) { + console.log(index, v); + return false; + } + } + + return true; + } + + property int jsonArrayLastIndexOf: jsonArray.lastIndexOf(1) + property int jsArrayLastIndexOf: jsArray().lastIndexOf(1) + + property list<string> jsonArrayMap: jsonArray.map(element => element.toString()) + property list<string> jsArrayMap: jsArray().map(element => element.toString()) + + property int jsonArrayReduce: jsonArray.reduce((acc, element) => acc - element, 40) + property int jsArrayReduce: jsArray().reduce((acc, element) => acc - element, 40) + + property string jsonArrayReduceRight: jsonArray.reduceRight((acc, element) => acc + element.toString(), "") + property string jsArrayReduceRight: jsArray().reduceRight((acc, element) => acc + element.toString(), "") + + property list<int> jsonArraySlice: jsonArray.slice(0, 1) + property list<int> jsArraySlice: jsArray().slice(0, 1) + + property bool jsonArraySome: jsonArray.some(element => element === 1) + property bool jsArraySome: jsArray().some(element => element === 1) + + property string stringifiedLocaleJsonArray: jsonArray.toLocaleString() + property string stringifiedLocaleJsArray: jsArray().toLocaleString() + + property string stringifiedJsonArray: jsonArray.toString() + property string stringifiedJsArray: jsArray().toString() + + property bool valuesMatch: { + var iterator = jsonArray.values(); + for (var obj of jsArray().values()) { + var v = iterator.next().value; + if (obj !== v) { + console.log(obj, v); + return false; + } + } + + var iterator = jsArray().values(); + for (var obj of jsonArray.values()) { + var v = iterator.next().value; + if (obj !== v) { + console.log(obj, v); + return false; + } + } + + return true; + } + + // In-place mutation methods. + // Set by onCompleted if mutating jsonArray and then accessing it + // respects the mutation and the mutation behaves as for an array. + property bool jsonArrayWasCopiedWithin: false + property bool jsonArrayWasFilled: false + property bool jsonArrayWasPopped: false + property bool jsonArrayWasPushed: false + property bool jsonArrayWasReversed: false + property bool jsonArrayWasShifted: false + property bool jsonArrayWasSpliced: false + property bool jsonArrayWasUnshifted: false + property bool jsonArrayWasSorted: false + + Component.onCompleted: { + function equals(lhs, rhs) { + return lhs.toString() === rhs.toString() + } + + jsonArray.forEach(element => jsonArrayForEach += "-" + element + "-"); + jsArray().forEach(element => jsArrayForEach += "-" + element + "-"); + + var array = jsArray() + + jsonArray.copyWithin(1, 0, 1) + array.copyWithin(1, 0, 1) + jsonArrayWasCopiedWithin = equals(jsonArray, array) + + jsonArray.fill(7, 0, 1) + array.fill(7, 0, 1) + jsonArrayWasFilled = equals(jsonArray, array) + + jsonArray.pop() + array.pop() + jsonArrayWasPopped = equals(jsonArray, array) + + jsonArray.push(23) + jsonArray.push(11) + jsonArray.push(54) + jsonArray.push(42) + array.push(23) + array.push(11) + array.push(54) + array.push(42) + jsonArrayWasPushed = equals(jsonArray, array) + + jsonArray.reverse() + array.reverse() + jsonArrayWasReversed = equals(jsonArray, array) + + jsonArray.shift() + array.shift() + jsonArrayWasShifted = equals(jsonArray, array) + + jsonArray.splice(2, 1, [1, 2], 7, [1, 5]) + array.splice(2, 1, [1, 2], 7, [1, 5]) + jsonArrayWasSpliced = equals(jsonArray, array) + + jsonArray.unshift(4, 71) + array.unshift(4, 71) + jsonArrayWasUnshifted = equals(jsonArray, array) + + jsonArray.sort() + array.sort() + jsonArrayWasSorted = equals(jsonArray, array) + } +} diff --git a/tests/auto/qml/qqmllanguage/data/longConversion.qml b/tests/auto/qml/qqmllanguage/data/longConversion.qml new file mode 100644 index 0000000000..fd9a9518ee --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/longConversion.qml @@ -0,0 +1,28 @@ +import QtQml +import Test + +QtObject { + property bool testProp: GetterObject.getFalse() + property bool testQProp: GetterObject.getQFalse() + + property bool fromLocal + property bool fromQLocal + + property bool fromBoolean + property bool fromQBoolean + + Component.onCompleted: { + let l = GetterObject.getFalse(); + fromLocal = l; + + let b = Boolean(l); + fromBoolean = b; + + let ql = GetterObject.getQFalse(); + fromQLocal = ql; + + + let qb = Boolean(ql); + fromQBoolean = qb; + } +} diff --git a/tests/auto/qml/qqmllanguage/data/manuallyCallSignalHandler.qml b/tests/auto/qml/qqmllanguage/data/manuallyCallSignalHandler.qml new file mode 100644 index 0000000000..1ee71e5fd2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/manuallyCallSignalHandler.qml @@ -0,0 +1,11 @@ +import QtQml + +QtObject { + Component.onDestruction: { + console.log("evil!"); + } + + Component.onCompleted: { + Component.onDestruction() + } +} diff --git a/tests/auto/qml/qqmllanguage/data/nestedVectors.qml b/tests/auto/qml/qqmllanguage/data/nestedVectors.qml new file mode 100644 index 0000000000..0bcea52133 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/nestedVectors.qml @@ -0,0 +1,27 @@ +import Test +import QtQml + +NestedVectors { + id: self + + property var list1 + + Component.onCompleted: { + list1 = self.getList() + + let list2 = [] + let data1 = [] + data1.push(2) + data1.push(3) + data1.push(4) + + let data2 = [] + data2.push(5) + data2.push(6) + + list2.push(data1) + list2.push(data2) + + self.setList(list2) + } +} diff --git a/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.1.qml b/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.1.qml index acd5463a3c..ac5622f9fb 100644 --- a/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.1.qml +++ b/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.1.qml @@ -10,7 +10,7 @@ Item { } } - property bool expectNull: null + property bool expectNull: { return null; } function setExpectNull(b) { success = false; diff --git a/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.2.qml b/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.2.qml index ed0e0d10f0..3c18739c32 100644 --- a/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.2.qml +++ b/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.2.qml @@ -10,7 +10,7 @@ Item { } } - property bool expectNull: null + property bool expectNull: { return null; } function setExpectNull(b) { success = false; diff --git a/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.3.qml b/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.3.qml index f5e94ba715..e2e560199f 100644 --- a/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.3.qml +++ b/tests/auto/qml/qqmllanguage/data/objectDeletionNotify.3.qml @@ -10,7 +10,7 @@ Item { } } - property bool expectNull: null + property bool expectNull: { return null; } function setExpectNull(b) { success = false; diff --git a/tests/auto/qml/qqmllanguage/data/objectInList.qml b/tests/auto/qml/qqmllanguage/data/objectInList.qml new file mode 100644 index 0000000000..53c8c3cdd1 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/objectInList.qml @@ -0,0 +1,17 @@ +import QtQml + +QtObject { + objectName: "parent" + property list<QtObject> child + property Component c: QtObject { objectName: "child" } + + function doCreate() { + child.push(c.createObject(null)); + } + + Component.onCompleted: { + // Extra function call so that the created object cannot be on the stack + doCreate(); + gc(); + } +} diff --git a/tests/auto/qml/qqmllanguage/data/objectMethodClone.qml b/tests/auto/qml/qqmllanguage/data/objectMethodClone.qml new file mode 100644 index 0000000000..e21179ea14 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/objectMethodClone.qml @@ -0,0 +1,23 @@ +import QtQml + +QtObject { + id: window + + property int doneClicks: 0 + + property UIToolBar t1: UIToolBar { + objectName: window.objectName + onDoneClicked: window.doneClicks++ + } + + property UIToolBar t2: UIToolBar { + objectName: window.objectName + onDoneClicked: window.doneClicks++ + } + + property Timer timer: Timer { + interval: 10 + running: true + onTriggered: window.objectName = "bar" + } +} diff --git a/tests/auto/qml/qqmllanguage/data/optimizedSequenceShift.qml b/tests/auto/qml/qqmllanguage/data/optimizedSequenceShift.qml new file mode 100644 index 0000000000..32765895a0 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/optimizedSequenceShift.qml @@ -0,0 +1,14 @@ +import QtQml + +QtObject { + id: root + + property int changes: 0 + + property list<int> numbers: [1, 2, 3, 4, 5] + onNumbersChanged: ++changes + + property var one: numbers.shift.bind([1,2,3])() + + Component.onCompleted: root.numbers.shift() +} diff --git a/tests/auto/qml/qqmllanguage/data/optionalChainCallOnNullProperty.qml b/tests/auto/qml/qqmllanguage/data/optionalChainCallOnNullProperty.qml new file mode 100644 index 0000000000..00029e3953 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/optionalChainCallOnNullProperty.qml @@ -0,0 +1,10 @@ +import QtQml + +QtObject { + id: root + property QtObject target: null + + Component.onCompleted: { + target?.destroy( ) + } +} diff --git a/tests/auto/qml/qqmllanguage/data/overrideDefaultProperty.qml b/tests/auto/qml/qqmllanguage/data/overrideDefaultProperty.qml new file mode 100644 index 0000000000..69f9316c51 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/overrideDefaultProperty.qml @@ -0,0 +1,6 @@ +import QtQuick + +Item { + property list<var> data: [] + Item {} +} diff --git a/tests/auto/qml/qqmllanguage/data/retainThis.qml b/tests/auto/qml/qqmllanguage/data/retainThis.qml new file mode 100644 index 0000000000..7a372ee236 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/retainThis.qml @@ -0,0 +1,49 @@ +import QmlOtherThis +import QtQml + +QtObject { + property var cppMethod: objA.greet + property var cppMethod2: objA.sum + + property Greeter a: Greeter { id: objA; objectName: "objA" } + property Greeter b: Greeter { id: objB; objectName: "objB" } + + function doCall() { + cppMethod.call(objB) + cppMethod2(5, 6) + } + + property var cppMethod3; + function doRetrieve(g) { + cppMethod3 = g.greet; + } + + function doCall2() { + cppMethod3(); + } + + property Greeter c: Greeter { + id: objC + objectName: "objC" + + property var cppMethod: objC.sum + + function doCall() { + cppMethod(7, 7) + } + } + + Component.onCompleted: { + doCall(); + doCall(); + + doRetrieve(objA); + doCall2(); + doRetrieve(objB); + doCall2(); + + objC.doCall(); + objC.cppMethod = objB.sum; + objC.doCall(); + } +} diff --git a/tests/auto/qml/qqmllanguage/data/signatureEnforced.qml b/tests/auto/qml/qqmllanguage/data/signatureEnforced.qml index e2ddd75b55..ec00d5d2b3 100644 --- a/tests/auto/qml/qqmllanguage/data/signatureEnforced.qml +++ b/tests/auto/qml/qqmllanguage/data/signatureEnforced.qml @@ -8,7 +8,7 @@ QtObject { property withLength withLength: 5 function a(r: rect) { - r.x = 77 // does not write back + r.x = 77 // does write back, but this is an evil thing to do. } function b(s: string) : int { @@ -28,8 +28,11 @@ QtObject { property int n: c(99) // creates a withLength property int o: rect.y + function bad(b: int) { return b } + Component.onCompleted: { a(rect) d(rect) + bad(15) } } diff --git a/tests/auto/qml/qqmllanguage/data/signatureIgnored.qml b/tests/auto/qml/qqmllanguage/data/signatureIgnored.qml index 0e9d0f42dc..bdb373040d 100644 --- a/tests/auto/qml/qqmllanguage/data/signatureIgnored.qml +++ b/tests/auto/qml/qqmllanguage/data/signatureIgnored.qml @@ -1,6 +1,6 @@ +pragma FunctionSignatureBehavior: Ignored import StaticTest import QtQml - QtObject { property rect rect: ({ x: 12, y: 13 }) property withLength withLength: 5 diff --git a/tests/auto/qml/qqmllanguage/data/singleton/RegisteredCompositeSingletonType.qml b/tests/auto/qml/qqmllanguage/data/singleton/RegisteredCompositeSingletonType.qml index 5359157b31..b86477e40a 100644 --- a/tests/auto/qml/qqmllanguage/data/singleton/RegisteredCompositeSingletonType.qml +++ b/tests/auto/qml/qqmllanguage/data/singleton/RegisteredCompositeSingletonType.qml @@ -1,5 +1,5 @@ // Copyright (C) 2013 BlackBerry Limited. All rights reserved. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.0 pragma Singleton diff --git a/tests/auto/qml/qqmllanguage/data/singleton/js/jspragma.js b/tests/auto/qml/qqmllanguage/data/singleton/js/jspragma.js index 6e28624bb0..50ed2b0e66 100644 --- a/tests/auto/qml/qqmllanguage/data/singleton/js/jspragma.js +++ b/tests/auto/qml/qqmllanguage/data/singleton/js/jspragma.js @@ -1,5 +1,5 @@ // Copyright (C) 2013 BlackBerry Limited. All rights reserved. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only .pragma library diff --git a/tests/auto/qml/qqmllanguage/data/singletonTest17.qml b/tests/auto/qml/qqmllanguage/data/singletonTest17.qml index 4a987e31c0..7c7bffa4ac 100644 --- a/tests/auto/qml/qqmllanguage/data/singletonTest17.qml +++ b/tests/auto/qml/qqmllanguage/data/singletonTest17.qml @@ -1,5 +1,5 @@ // Copyright (C) 2013 BlackBerry Limited. All rights reserved. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick 2.0 import org.qtproject.Test 1.0 diff --git a/tests/auto/qml/qqmllanguage/data/typedObjectList.qml b/tests/auto/qml/qqmllanguage/data/typedObjectList.qml new file mode 100644 index 0000000000..7e6f6e8dd9 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/typedObjectList.qml @@ -0,0 +1,10 @@ +import QtQml + +QtObject { + property var b; + property Component c: QtObject {} + + function returnList(a: Component) : list<Component> { return [a] } + + Component.onCompleted: b = { b: returnList(c) } +} diff --git a/tests/auto/qml/qqmllanguage/data/unregisteredValueTypeConversion.qml b/tests/auto/qml/qqmllanguage/data/unregisteredValueTypeConversion.qml new file mode 100644 index 0000000000..70484d3f0e --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/unregisteredValueTypeConversion.qml @@ -0,0 +1,10 @@ +import QtQml +import Test + +UnregisteredValueTypeHandler { + Component.onCompleted: { + consume(produce()) + consume(produceDerived()) + consume(produceGadgeted()) + } +} diff --git a/tests/auto/qml/qqmllanguage/data/variantObjectList.qml b/tests/auto/qml/qqmllanguage/data/variantObjectList.qml new file mode 100644 index 0000000000..9ec7d4f90f --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/variantObjectList.qml @@ -0,0 +1,17 @@ +import QtQml +import People + +QtObject { + id: root + + property QtObject b: QtObject { id: g1; objectName: "Leo Hodges" } + property QtObject c: QtObject { id: g2; objectName: "Jack Smith" } + property QtObject d: QtObject { id: g3; objectName: "Anne Brown" } + + property Component pc: Component { + id: partyComp + BirthdayParty {} + } + + property BirthdayParty q: partyComp.createObject(root, { guests: [g1, g2, g3] }) +} |