From 16337b633c82db39c0da671205ca1f23d29a4b05 Mon Sep 17 00:00:00 2001 From: s00912778 Date: Tue, 22 Oct 2024 17:10:35 +0800 Subject: [PATCH] shijiakai2@huawei.com add full ut Signed-off-by: s00912778 Change-Id: I35bc664267e28aa60f313e70fee260534901b653 --- compiler/test/error.json | 143 ++++++++++++++++-- .../v2ToV1ComponentValidate.ets | 6 +- compiler/test/transform_ut/ut.test.ts | 8 +- .../transform_ut/ut_partial_update.test.ts | 2 +- .../test/transform_ut/ut_validate.test.ts | 3 +- 5 files changed, 134 insertions(+), 28 deletions(-) diff --git a/compiler/test/error.json b/compiler/test/error.json index b89eeab6..26df63c8 100644 --- a/compiler/test/error.json +++ b/compiler/test/error.json @@ -105,7 +105,10 @@ "message": "The property 'message' must specify a type.", "type": "ERROR" }, - "validateNonObservedClassType": [], + "validateNonObservedClassType": { + "message": "The type of the @ObjectLink property 'message' can only be objects of classes decorated with @Observed class decorator in ets (not ts).", + "type": "ERROR" + }, "validateHasIllegalDecoratorInEntry": { "message": "The @Entry component 'ValidateHasIllegalDecoratorInEntryIndex' cannot have the @Prop property 'message'.", "type": "WARN" @@ -135,7 +138,7 @@ "type": "ERROR" }, "checkBuilder$$": { - "message": "The regular property 'paramA1' cannot be assigned to the @Link property 'message'.", + "message": "Unrecognized property 'paramA1', make sure it can be assigned to @Link property 'message' by yourself.", "type": "WARN" }, "validateForbiddenToInitViaParam": { @@ -554,11 +557,50 @@ "type": "ERROR" } ], - "v2DecoratorInitFromParent": { - "message": "Property 'param_value' must be initialized through the component constructor.", - "type": "ERROR" - }, - "validateParamTwoWayBind": [], + "v2DecoratorInitFromParent": [ + { + "message": "Property 'param_value' must be initialized through the component constructor.", + "type": "ERROR" + }, + { + "message": "Property 'regular_value' in the custom component 'testChild' cannot be initialized here (forbidden to specify).", + "type": "ERROR" + }, + { + "message": "Property 'local_value' in the custom component 'testChild' cannot be initialized here (forbidden to specify).", + "type": "ERROR" + }, + { + "message": "Property 'provider_value' in the custom component 'testChild' cannot be initialized here (forbidden to specify).", + "type": "ERROR" + }, + { + "message": "Property 'consumer_value' in the custom component 'testChild' cannot be initialized here (forbidden to specify).", + "type": "ERROR" + } + ], + "validateParamTwoWayBind": [ + { + "message": "When the two-way binding syntax is used, the variable 'value' must be decorated with @Param, and the @Event variable '$value' must be defined in the testParamChild1.", + "type": "ERROR" + }, + { + "message": "The optional character can not be used in the initial value of property 'paramValue'.", + "type": "ERROR" + }, + { + "message": "The optional character can not be used in the initial value of property 'paramValue'.", + "type": "ERROR" + }, + { + "message": "When the two-way binding syntax is used, the initial value of property 'paramValue' must be a variable.", + "type": "ERROR" + }, + { + "message": "When the two-way binding syntax is used, the initial value of property 'paramValue' must be a variable.", + "type": "ERROR" + } + ], "validateDifferentMethod": [ { "message": "A function can only be decorated by one of the 'AnimatableExtend, Builder, Extend, Styles, Concurrent and Sendable'.", @@ -713,14 +755,67 @@ "type": "ERROR" } ], - "v1ToV2Component": [], + "v1ToV2Component": [ + { + "message": "Property 'func_value1' in the @ComponentV2 component 'TestV2Child' are not allowed to be assigned values here.", + "type": "ERROR" + }, + { + "message": "Property 'func_value2' in the @ComponentV2 component 'TestV2Child' are not allowed to be assigned values here.", + "type": "ERROR" + } + ], "v1ToV2ComponentValidate": [ { "message": "The type of the @Param property can not be a class decorated with @Observed.", "type": "ERROR" }, { - "message": "The type of the @Prop property 'prop_value' can only be string, number or boolean.", + "message": "Property 'param_value' in the @ComponentV2 component 'TestV2Child2' are not allowed to be assigned values here.", + "type": "ERROR" + }, + { + "message": "Property 'param_value_alias_type' in the @ComponentV2 component 'TestV2Child2' are not allowed to be assigned values here.", + "type": "ERROR" + }, + { + "message": "Property 'state_value' in the @ComponentV2 component 'TestV2Child' are not allowed to be assigned values here.", + "type": "ERROR" + }, + { + "message": "Property 'prop_value' in the @ComponentV2 component 'TestV2Child' are not allowed to be assigned values here.", + "type": "ERROR" + }, + { + "message": "Property 'link_value' in the @ComponentV2 component 'TestV2Child' are not allowed to be assigned values here.", + "type": "ERROR" + }, + { + "message": "Property 'provide_value' in the @ComponentV2 component 'TestV2Child' are not allowed to be assigned values here.", + "type": "ERROR" + }, + { + "message": "Property 'consume_value' in the @ComponentV2 component 'TestV2Child' are not allowed to be assigned values here.", + "type": "ERROR" + }, + { + "message": "Property 'objectLink_value' in the @ComponentV2 component 'TestV2Child' are not allowed to be assigned values here.", + "type": "ERROR" + }, + { + "message": "Property 'storage_link_value' in the @ComponentV2 component 'TestV2Child' are not allowed to be assigned values here.", + "type": "ERROR" + }, + { + "message": "Property 'storage_prop_value' in the @ComponentV2 component 'TestV2Child' are not allowed to be assigned values here.", + "type": "ERROR" + }, + { + "message": "Property 'local_storage_link_value' in the @ComponentV2 component 'TestV2Child' are not allowed to be assigned values here.", + "type": "ERROR" + }, + { + "message": "Property 'local_storage_prop_value' in the @ComponentV2 component 'TestV2Child' are not allowed to be assigned values here.", "type": "ERROR" } ], @@ -734,11 +829,11 @@ "type": "ERROR" }, { - "message": "The type of the @Prop property 'regular_value' can only be string, number or boolean.", + "message": "Property 'set_value' in the @Component component 'TestV1Child1' are not allowed to be assigned values here.", "type": "ERROR" }, { - "message": "The type of the @Prop property 'func_value1' can only be string, number or boolean.", + "message": "Property 'set_value_alias' in the @Component component 'TestV1Child1' are not allowed to be assigned values here.", "type": "ERROR" }, { @@ -746,7 +841,27 @@ "type": "ERROR" }, { - "message": "The type of the @Prop property 'map_value' can only be string, number or boolean.", + "message": "Property 'set_value' in the @Component component 'TestV1Child' are not allowed to be assigned values here.", + "type": "ERROR" + }, + { + "message": "Property 'map_value' in the @Component component 'TestV1Child' are not allowed to be assigned values here.", + "type": "ERROR" + }, + { + "message": "Property 'arr_value' in the @Component component 'TestV1Child' are not allowed to be assigned values here.", + "type": "ERROR" + }, + { + "message": "Property 'arr_value1' in the @Component component 'TestV1Child' are not allowed to be assigned values here.", + "type": "ERROR" + }, + { + "message": "Property 'arr_value2' in the @Component component 'TestV1Child' are not allowed to be assigned values here.", + "type": "ERROR" + }, + { + "message": "Property 'arr_value3' in the @Component component 'TestV1Child' are not allowed to be assigned values here.", "type": "ERROR" } ], @@ -850,10 +965,6 @@ { "message": "The type of the @Consumer property can not be a class decorated with @Observed.", "type": "ERROR" - }, - { - "message": "The type of the @Prop property 'prop_value' can only be string, number or boolean.", - "type": "ERROR" } ] } \ No newline at end of file diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForValidate/Decorators/v1AndV2ComponentDecorators/v2ToV1ComponentValidate.ets b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForValidate/Decorators/v1AndV2ComponentDecorators/v2ToV1ComponentValidate.ets index 204156de..59c24db5 100644 --- a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForValidate/Decorators/v1AndV2ComponentDecorators/v2ToV1ComponentValidate.ets +++ b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForValidate/Decorators/v1AndV2ComponentDecorators/v2ToV1ComponentValidate.ets @@ -19,7 +19,7 @@ enum MemberType { class TestObserved { } -type newType = Set | Set +type DummyNewType = Set | Set @ComponentV2 struct TestV2Parent1 { string_value: string = "hello" @@ -32,7 +32,7 @@ struct TestV2Parent1 { @Event func_value2: () => void = () => {} @Local set_value: Set | Set = new Set() - @Local set_value_alias: newType = new Set() + @Local set_value_alias: DummyNewType = new Set() build() { Column() { TestV1Child1({ @@ -59,7 +59,7 @@ struct TestV1Child1 { @Link enum_value1: MemberType @Link enum_value: Set | MemberType @Provide set_value: Set | Set = new Set() - @State set_value_alias: newType = new Set() + @State set_value_alias: DummyNewType = new Set() @ObjectLink objectLink_value: TestObserved @Prop func_value1: Function @BuilderParam func_value2: () => void diff --git a/compiler/test/transform_ut/ut.test.ts b/compiler/test/transform_ut/ut.test.ts index e57c6214..196e2807 100644 --- a/compiler/test/transform_ut/ut.test.ts +++ b/compiler/test/transform_ut/ut.test.ts @@ -56,7 +56,7 @@ const OUTPUTS_PATH: string = path.resolve(PROJECT_ROOT, DEFAULT_PROJECT, 'entry/ const MAIN_PAGES: string[] = UT_PAGES.map((p) => `pages/ut/${p}`); mocha.describe('test UT testcases [non-preview mode]', function () { - this.timeout(7500); + this.timeout(10000); mocha.before(function () { resetUtils(); @@ -137,15 +137,9 @@ mocha.describe('test UT testcases [non-preview mode]', function () { const transform = this.etsTransformPlugin.transform.bind(this.rollup); - // expect(sourceCode !== null).to.be.true; - // done(); - transform(sourceReplace(sourceCode), sourceFilePath) .then(res => { - // console.error(`1-${index}: result: `, res.code); - expect(parseCode(res.code)).eql(parseCode(targetCode)); - // expect(res !== null).to.be.true; done(); }) .catch(err => done(err)); diff --git a/compiler/test/transform_ut/ut_partial_update.test.ts b/compiler/test/transform_ut/ut_partial_update.test.ts index f82565cf..42aa0fe7 100644 --- a/compiler/test/transform_ut/ut_partial_update.test.ts +++ b/compiler/test/transform_ut/ut_partial_update.test.ts @@ -56,7 +56,7 @@ const OUTPUTS_PATH: string = path.resolve(PROJECT_ROOT, DEFAULT_PROJECT, 'entry/ const MAIN_PAGES: string[] = UT_PARTIAL_UPFATE_PAGES.map((p) => `pages/utForPartialUpdate/${p}`); mocha.describe('test UT for partial update testcases [non-preview mode]', function () { - this.timeout(7500); + this.timeout(10000); mocha.before(function () { resetUtils(); diff --git a/compiler/test/transform_ut/ut_validate.test.ts b/compiler/test/transform_ut/ut_validate.test.ts index 68cf27fc..9be087df 100644 --- a/compiler/test/transform_ut/ut_validate.test.ts +++ b/compiler/test/transform_ut/ut_validate.test.ts @@ -57,7 +57,7 @@ const ERROR_COLLECTION_PATH: string = path.resolve(__dirname, '../../test/error. const MAIN_PAGES: string[] = UT_VALIDATE_PAGES.map((p) => `pages/utForValidate/${p}`); mocha.describe('test UT for validate testcases [non-preview mode]', function () { - this.timeout(7500); + this.timeout(10000); mocha.before(function () { resetUtils(); @@ -82,6 +82,7 @@ mocha.describe('test UT for validate testcases [non-preview mode]', function () Object.assign(projectConfig, this.globalProjectConfig); this.globalPartialUpdateConfig = new PartialUpdateConfig(); + this.globalPartialUpdateConfig.setPartialUpdateMode(true); this.globalPartialUpdateConfig.mockDisableArkTSLinter(); Object.assign(partialUpdateConfig, this.globalPartialUpdateConfig);