1 /**
2  * Copyright (c) 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 <cstddef>
17 #include <cstdint>
18 #include <gtest/gtest.h>
19 #include <sstream>
20 #include <type_traits>
21 
22 #include "bytecode_instruction-inl.h"
23 
24 namespace panda::test {
25 
TEST(BytecodeInstruction, IsReturnOrThrowInstruction)26 TEST(BytecodeInstruction, IsReturnOrThrowInstruction)
27 {
28     {
29         // return
30         const uint8_t bytecode[] = {0x65};
31         BytecodeInstruction inst(bytecode);
32         EXPECT_EQ(inst.IsReturnOrThrowInstruction(), true);
33     }
34     {
35         // throw
36         const uint8_t bytecode[] = {0xfe};
37         BytecodeInstruction inst(bytecode);
38         EXPECT_EQ(inst.IsReturnOrThrowInstruction(), true);
39     }
40     {
41         // not return, not throw
42         const uint8_t bytecode[] = {0x3f, 0x00, 0x0c, 0x00};
43         BytecodeInstruction inst(bytecode);
44         EXPECT_EQ(inst.IsReturnOrThrowInstruction(), false);
45     }
46 }
47 }