1 /*
2 * Copyright (c) 2023-2024 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 #include "check_resolver.h"
17 #include "common.h"
18
19 namespace ark::bytecodeopt::test {
20
21 // NOLINTBEGIN(readability-magic-numbers)
22
TEST_F(CommonTest,CheckResolverLenArray)23 TEST_F(CommonTest, CheckResolverLenArray)
24 {
25 auto graph = CreateEmptyGraph();
26 GRAPH(graph)
27 {
28 PARAMETER(0U, 0U).s32();
29 PARAMETER(1U, 1U).ref();
30
31 BASIC_BLOCK(2U, -1L)
32 {
33 INST(2U, Opcode::SaveState).NoVregs();
34 INST(3U, Opcode::NullCheck).ref().Inputs(1U, 2U);
35 INST(4U, Opcode::LenArray).s32().Inputs(3U);
36 INST(5U, Opcode::BoundsCheck).s32().Inputs(4U, 0U, 2U);
37 INST(6U, Opcode::LoadArray).s32().Inputs(3U, 5U);
38 INST(7U, Opcode::Return).s32().Inputs(6U);
39 }
40 }
41
42 EXPECT_TRUE(graph->RunPass<CheckResolver>());
43 }
44
45 // NOLINTEND(readability-magic-numbers)
46
47 } // namespace ark::bytecodeopt::test
48