From 2474ecabbf687f6eb9466c45233995198d5978d5 Mon Sep 17 00:00:00 2001 From: lirismankarina Date: Tue, 6 May 2025 20:58:46 +0300 Subject: [PATCH] Fix clang-tidy, lightweight, union normalization tests Signed-off-by: lirismankarina --- ets2panda/checker/ets/object.cpp | 2 +- ets2panda/checker/types/ets/byteType.cpp | 2 +- ets2panda/checker/types/ets/charType.cpp | 2 +- ets2panda/checker/types/ets/doubleType.cpp | 2 +- ets2panda/checker/types/ets/floatType.cpp | 2 +- ets2panda/checker/types/ets/longType.cpp | 2 +- ets2panda/checker/types/ets/shortType.cpp | 2 +- .../test/unit/lsp/get_type_of_symbol_at_location_test.cpp | 2 +- ets2panda/test/unit/public/ast_builder_test.cpp | 2 ++ ets2panda/test/unit/union_normalization_test_1.cpp | 6 +++--- ets2panda/test/unit/union_normalization_test_2.cpp | 4 ++-- 11 files changed, 15 insertions(+), 13 deletions(-) diff --git a/ets2panda/checker/ets/object.cpp b/ets2panda/checker/ets/object.cpp index be5c85e5a..bb9dda724 100644 --- a/ets2panda/checker/ets/object.cpp +++ b/ets2panda/checker/ets/object.cpp @@ -1524,7 +1524,7 @@ bool ETSChecker::ValidateArrayIndex(ir::Expression *const expr, bool relaxed) return true; } - ASSERT(expr->IsNumberLiteral()); + ES2PANDA_ASSERT(expr->IsNumberLiteral()); double value = expr->AsNumberLiteral()->Number().GetDouble(); double intPart; diff --git a/ets2panda/checker/types/ets/byteType.cpp b/ets2panda/checker/types/ets/byteType.cpp index 785bb846f..e69f7aff8 100644 --- a/ets2panda/checker/types/ets/byteType.cpp +++ b/ets2panda/checker/types/ets/byteType.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - 2024 Huawei Device Co., Ltd. + * Copyright (c) 2021 - 2025 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 diff --git a/ets2panda/checker/types/ets/charType.cpp b/ets2panda/checker/types/ets/charType.cpp index 833cb3fc0..c127dc483 100644 --- a/ets2panda/checker/types/ets/charType.cpp +++ b/ets2panda/checker/types/ets/charType.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - 2024 Huawei Device Co., Ltd. + * Copyright (c) 2021 - 2025 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 diff --git a/ets2panda/checker/types/ets/doubleType.cpp b/ets2panda/checker/types/ets/doubleType.cpp index 1f28076d5..ad58d7bc8 100644 --- a/ets2panda/checker/types/ets/doubleType.cpp +++ b/ets2panda/checker/types/ets/doubleType.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - 2024 Huawei Device Co., Ltd. + * Copyright (c) 2021 - 2025 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 diff --git a/ets2panda/checker/types/ets/floatType.cpp b/ets2panda/checker/types/ets/floatType.cpp index 27e1ce463..958f33848 100644 --- a/ets2panda/checker/types/ets/floatType.cpp +++ b/ets2panda/checker/types/ets/floatType.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - 2024 Huawei Device Co., Ltd. + * Copyright (c) 2021 - 2025 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 diff --git a/ets2panda/checker/types/ets/longType.cpp b/ets2panda/checker/types/ets/longType.cpp index 248c36709..7b8c5b34f 100644 --- a/ets2panda/checker/types/ets/longType.cpp +++ b/ets2panda/checker/types/ets/longType.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - 2024 Huawei Device Co., Ltd. + * Copyright (c) 2021 - 2025 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 diff --git a/ets2panda/checker/types/ets/shortType.cpp b/ets2panda/checker/types/ets/shortType.cpp index 7736e66bb..c7f79a229 100644 --- a/ets2panda/checker/types/ets/shortType.cpp +++ b/ets2panda/checker/types/ets/shortType.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - 2024 Huawei Device Co., Ltd. + * Copyright (c) 2021 - 2025 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 diff --git a/ets2panda/test/unit/lsp/get_type_of_symbol_at_location_test.cpp b/ets2panda/test/unit/lsp/get_type_of_symbol_at_location_test.cpp index 69839da31..07d819f8b 100644 --- a/ets2panda/test/unit/lsp/get_type_of_symbol_at_location_test.cpp +++ b/ets2panda/test/unit/lsp/get_type_of_symbol_at_location_test.cpp @@ -26,7 +26,7 @@ namespace { using ark::es2panda::lsp::Initializer; -static auto g_fileSource = +auto g_fileSource = "let a: number;\nlet b: byte;\nlet c: short;\nlet d: int;\nlet e: long;\nlet f: " "float;\nlet g: double;\nlet h: char;\nlet i: boolean;"; diff --git a/ets2panda/test/unit/public/ast_builder_test.cpp b/ets2panda/test/unit/public/ast_builder_test.cpp index 7bc7a7df8..559f1ed6f 100644 --- a/ets2panda/test/unit/public/ast_builder_test.cpp +++ b/ets2panda/test/unit/public/ast_builder_test.cpp @@ -99,6 +99,7 @@ using ark::es2panda::ir::VariableDeclarationBuilder; using ark::es2panda::ir::VariableDeclaratorBuilder; using ark::es2panda::ir::WhileStatementBuilder; +// NOLINTBEGIN(readability-magic-numbers) namespace { TEST_F(ASTVerifierTest, arrowFunctionExpressionBuild) { @@ -429,3 +430,4 @@ TEST_F(ASTVerifierTest, multipleImportTest) ASSERT_TRUE(classDecl->IsClassDeclaration()); } } // anonymous namespace +// NOLINTEND(readability-magic-numbers) diff --git a/ets2panda/test/unit/union_normalization_test_1.cpp b/ets2panda/test/unit/union_normalization_test_1.cpp index 733ebbbc6..d4cbe2fb7 100644 --- a/ets2panda/test/unit/union_normalization_test_1.cpp +++ b/ets2panda/test/unit/union_normalization_test_1.cpp @@ -47,7 +47,7 @@ TEST_F(UnionNormalizationTest, UnionWithObject) ASSERT(checker); ArenaVector unionConstituents(checker->Allocator()->Adapter()); - unionConstituents.emplace_back(checker->GlobalIntType()); + unionConstituents.emplace_back(checker->GlobalIntBuiltinType()); unionConstituents.emplace_back(checker->GetGlobalTypesHolder()->GlobalETSObjectType()); unionConstituents.emplace_back(checker->GetGlobalTypesHolder()->GlobalETSStringBuiltinType()); @@ -73,10 +73,10 @@ TEST_F(UnionNormalizationTest, UnionWithIdenticalTypes1) ASSERT(checker); ArenaVector unionConstituents(checker->Allocator()->Adapter()); - unionConstituents.emplace_back(checker->GlobalDoubleType()); + unionConstituents.emplace_back(checker->GlobalDoubleBuiltinType()); unionConstituents.emplace_back(baseType); unionConstituents.emplace_back(checker->GlobalBuiltinETSStringType()); - unionConstituents.emplace_back(checker->GlobalDoubleType()); + unionConstituents.emplace_back(checker->GlobalDoubleBuiltinType()); // Create union type, which will be normalized inside creation function auto *const normalizedType = checker->CreateETSUnionType(std::move(unionConstituents)); diff --git a/ets2panda/test/unit/union_normalization_test_2.cpp b/ets2panda/test/unit/union_normalization_test_2.cpp index 44f8002c3..59715ca07 100644 --- a/ets2panda/test/unit/union_normalization_test_2.cpp +++ b/ets2panda/test/unit/union_normalization_test_2.cpp @@ -203,7 +203,7 @@ TEST_F(UnionNormalizationTest, UnionStringLiterals1) // Test normalization: number | "abc" | string | "xy" ==> number | string ArenaVector unionConstituents3(checker->Allocator()->Adapter()); - unionConstituents3.emplace_back(checker->GlobalDoubleType()); + unionConstituents3.emplace_back(checker->GlobalDoubleBuiltinType()); unionConstituents3.emplace_back(checker->CreateETSStringLiteralType("abc")); unionConstituents3.emplace_back(checker->GlobalBuiltinETSStringType()); unionConstituents3.emplace_back(checker->CreateETSStringLiteralType("xy")); @@ -279,7 +279,7 @@ TEST_F(UnionNormalizationTest, UnionStringLiterals2) unionConstituents3.emplace_back(checker->CreateETSStringLiteralType("bc2")); unionConstituents3.emplace_back(checker->CreateETSStringLiteralType("cd3")); unionConstituents3.emplace_back(checker->GlobalBuiltinETSStringType()); - unionConstituents3.emplace_back(checker->GlobalIntType()); + unionConstituents3.emplace_back(checker->GlobalIntBuiltinType()); // Create union type, which will be normalized inside creation function auto *const normalizedType3 = checker->CreateETSUnionType(std::move(unionConstituents3)); -- Gitee