add test cases

Signed-off-by: s00912778 <shijiakai2@huawei.com>
Change-Id: I4d9aa2e3b0b33d87b19b038b664aae2e03caf874
This commit is contained in:
s00912778 2024-11-12 16:52:03 +08:00
parent 8fafa1ac56
commit 156750f8a2
6 changed files with 144 additions and 0 deletions

View File

@ -0,0 +1,32 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@Entry
@Component
struct Parent {
@State $arr: number[] = [1, 2, 3];
build() {
Column() {
Child({items: this.arr});
}
}
}
@Component
struct Child {
@Link items: number[];
build() {
}
}

View File

@ -0,0 +1,32 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@Entry
@Component
struct Parent {
@State $arr: number[] = [1, 2, 3];
build() {
Column() {
Child({items: this.$arr});
}
}
}
@Component
struct Child {
@Link items: number[];
build() {
}
}

View File

@ -0,0 +1,32 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@Entry
@Component
struct Parent {
@Consume $arr: number[];
build() {
Column() {
Child({items: this.$arr});
}
}
}
@Component
struct Child {
items: number[] = [1, 2, 3];
build() {
}
}

View File

@ -0,0 +1,40 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@Observed
class Info {
count: number;
constructor(count: number) {
this.count = count;
}
}
@Entry
@Component
struct Parent {
@State $arr: Info = new Info(1);
build() {
Column() {
Child({items: this.$arr});
}
}
}
@Component
struct Child {
@ObjectLink items: Info;
build() {
}
}

View File

@ -213,6 +213,10 @@ export const UT_VALIDATE_PAGES: string[] = [
'Decorators/process_custom_component/v2DecoratorInitFromParent',
'Decorators/process_custom_component/validateForbiddenToInitViaParam',
'Decorators/process_custom_component/validateIllegalInitFromParent',
'Decorators/process_custom_component/validateIllegalInitFromParent2',
'Decorators/process_custom_component/validateIllegalInitFromParent3',
'Decorators/process_custom_component/validateIllegalInitFromParent4',
'Decorators/process_custom_component/validateIllegalInitFromParent5',
'Decorators/process_custom_component/validateInitDecorator',
'Decorators/process_custom_component/validateMandatoryToInitViaParam',
'Decorators/process_custom_component/validateNonLinkWithDollar',

View File

@ -175,6 +175,10 @@
"message": "The regular property 'message' cannot be assigned to the @Link property 'message'.",
"type": "ERROR"
},
"validateIllegalInitFromParent4": {
"message": "The @Consume property '$arr' cannot be assigned to the regular property 'items'.",
"type": "ERROR"
},
"validateNonLinkWithDollar": {
"message": "Property 'message' cannot initialize using '$' to create a reference to a variable.",
"type": "ERROR"