1 /** 2 * Copyright (c) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef ES2PANDA_TEST_CFG_CFG_TEST_H 17 #define ES2PANDA_TEST_CFG_CFG_TEST_H 18 19 #include <gtest/gtest.h> 20 #include "compiler/core/CFG.h" 21 #include "parser/program/program.h" 22 #include "test/utils/ast_verifier_test.h" 23 24 namespace ark::es2panda::compiler { 25 26 class CFGTest : public test::utils::AstVerifierTest { 27 public: GetBBByID(const ArenaSet<CFG::BasicBlock * > & basicBlocks,size_t id)28 [[nodiscard]] static const CFG::BasicBlock *GetBBByID(const ArenaSet<CFG::BasicBlock *> &basicBlocks, size_t id) 29 { 30 for (auto bb : basicBlocks) { 31 if (bb->GetIndex() == id) { 32 return bb; 33 } 34 } 35 return nullptr; 36 } 37 }; 38 39 constexpr size_t ID_01 = 1; 40 constexpr size_t ID_02 = 2; 41 constexpr size_t ID_03 = 3; 42 constexpr size_t ID_04 = 4; 43 constexpr size_t ID_05 = 5; 44 constexpr size_t ID_06 = 6; 45 constexpr size_t ID_07 = 7; 46 constexpr size_t ID_13 = 13; 47 48 constexpr size_t EXPECTED_ZERO = 0; 49 constexpr size_t EXPECTED_ONE = 1; 50 constexpr size_t EXPECTED_TWO = 2; 51 constexpr size_t EXPECTED_THREE = 3; 52 constexpr size_t EXPECTED_FOUR = 4; 53 constexpr size_t EXPECTED_FIVE = 5; 54 constexpr size_t EXPECTED_FIFTEEN = 15; 55 56 } // namespace ark::es2panda::compiler 57 58 #endif // ES2PANDA_TEST_CFG_CFG_TEST_H 59