From e72b21895f72f0936cb951fa2b836e43fa1b4d2d Mon Sep 17 00:00:00 2001 From: Ilya Zabolotin Date: Fri, 20 Oct 2023 13:32:30 +0300 Subject: [PATCH] added new tests, renamed '$' into 'dollar' and added license agreement Signed-off-by: Ilya Zabolotin --- linter-4.2/test/ESObject.ts | 24 ++++++++++++++ linter-4.2/test/sdk_and_codelinter_diff_1.ts | 23 ++++++++++++++ linter-4.2/test/sdk_and_codelinter_diff_2.ts | 24 ++++++++++++++ .../{$_operation.ets => dollar_operation.ets} | 0 .../dollar_operation_TN.ets | 31 +++++++++++++++++++ ...ration.ets => double_dollar_operation.ets} | 0 ...tion1.ets => double_dollar_operation1.ets} | 0 linter/test/ESObject.ts | 24 ++++++++++++++ linter/test/sdk_and_codelinter_diff_1.ts | 23 ++++++++++++++ linter/test/sdk_and_codelinter_diff_2.ts | 24 ++++++++++++++ 10 files changed, 173 insertions(+) create mode 100644 linter-4.2/test/ESObject.ts create mode 100644 linter-4.2/test/sdk_and_codelinter_diff_1.ts create mode 100644 linter-4.2/test/sdk_and_codelinter_diff_2.ts rename linter-4.2/test_extended_features/{$_operation.ets => dollar_operation.ets} (100%) create mode 100644 linter-4.2/test_extended_features/dollar_operation_TN.ets rename linter-4.2/test_extended_features/{$$_operation.ets => double_dollar_operation.ets} (100%) rename linter-4.2/test_extended_features/{$$_operation1.ets => double_dollar_operation1.ets} (100%) create mode 100644 linter/test/ESObject.ts create mode 100644 linter/test/sdk_and_codelinter_diff_1.ts create mode 100644 linter/test/sdk_and_codelinter_diff_2.ts diff --git a/linter-4.2/test/ESObject.ts b/linter-4.2/test/ESObject.ts new file mode 100644 index 000000000..5cbfe92da --- /dev/null +++ b/linter-4.2/test/ESObject.ts @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2022-2023 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. + */ +//test for defect 14030 +type ESObject = any + +let a1: ESObject = 1; +let a2: ESObject; + +function foo() { + let a3: ESObject =2; + let a4: ESObject; +} \ No newline at end of file diff --git a/linter-4.2/test/sdk_and_codelinter_diff_1.ts b/linter-4.2/test/sdk_and_codelinter_diff_1.ts new file mode 100644 index 000000000..b77e09dad --- /dev/null +++ b/linter-4.2/test/sdk_and_codelinter_diff_1.ts @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2022-2023 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. + */ +//test for defect 14029 + +import {getData} from "./sdk_and_codelinter_diff_2" +async function getDatas() { + try { + let data: Object[] = await getData() + } catch (err){ + } +} \ No newline at end of file diff --git a/linter-4.2/test/sdk_and_codelinter_diff_2.ts b/linter-4.2/test/sdk_and_codelinter_diff_2.ts new file mode 100644 index 000000000..7b1523e1e --- /dev/null +++ b/linter-4.2/test/sdk_and_codelinter_diff_2.ts @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2022-2023 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. + */ +//test for defect 14029 + +export async function getData() { + let datas + let data: Object[] = [] + data.forEach(()=>{ + datas.push(1); + }) + return datas +} \ No newline at end of file diff --git a/linter-4.2/test_extended_features/$_operation.ets b/linter-4.2/test_extended_features/dollar_operation.ets similarity index 100% rename from linter-4.2/test_extended_features/$_operation.ets rename to linter-4.2/test_extended_features/dollar_operation.ets diff --git a/linter-4.2/test_extended_features/dollar_operation_TN.ets b/linter-4.2/test_extended_features/dollar_operation_TN.ets new file mode 100644 index 000000000..fb14c4fba --- /dev/null +++ b/linter-4.2/test_extended_features/dollar_operation_TN.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2022-2023 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. + */ +//test for defect 14031 + +export class Foo1 { + foo1?: string[] = []; +} + +@Component +export struct SomeStruct { + @Link someStruct: Foo1[]; +} + +export class Foo { + SomeStruct({ + someStruct: $someStruct + }); +} + diff --git a/linter-4.2/test_extended_features/$$_operation.ets b/linter-4.2/test_extended_features/double_dollar_operation.ets similarity index 100% rename from linter-4.2/test_extended_features/$$_operation.ets rename to linter-4.2/test_extended_features/double_dollar_operation.ets diff --git a/linter-4.2/test_extended_features/$$_operation1.ets b/linter-4.2/test_extended_features/double_dollar_operation1.ets similarity index 100% rename from linter-4.2/test_extended_features/$$_operation1.ets rename to linter-4.2/test_extended_features/double_dollar_operation1.ets diff --git a/linter/test/ESObject.ts b/linter/test/ESObject.ts new file mode 100644 index 000000000..5cbfe92da --- /dev/null +++ b/linter/test/ESObject.ts @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2022-2023 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. + */ +//test for defect 14030 +type ESObject = any + +let a1: ESObject = 1; +let a2: ESObject; + +function foo() { + let a3: ESObject =2; + let a4: ESObject; +} \ No newline at end of file diff --git a/linter/test/sdk_and_codelinter_diff_1.ts b/linter/test/sdk_and_codelinter_diff_1.ts new file mode 100644 index 000000000..b77e09dad --- /dev/null +++ b/linter/test/sdk_and_codelinter_diff_1.ts @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2022-2023 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. + */ +//test for defect 14029 + +import {getData} from "./sdk_and_codelinter_diff_2" +async function getDatas() { + try { + let data: Object[] = await getData() + } catch (err){ + } +} \ No newline at end of file diff --git a/linter/test/sdk_and_codelinter_diff_2.ts b/linter/test/sdk_and_codelinter_diff_2.ts new file mode 100644 index 000000000..7b1523e1e --- /dev/null +++ b/linter/test/sdk_and_codelinter_diff_2.ts @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2022-2023 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. + */ +//test for defect 14029 + +export async function getData() { + let datas + let data: Object[] = [] + data.forEach(()=>{ + datas.push(1); + }) + return datas +} \ No newline at end of file -- Gitee