brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.4 KiB · 4aea800 Raw
97 lines · python
1"""2Test basic std::array functionality.3"""4 5from lldbsuite.test.decorators import *6from lldbsuite.test.lldbtest import *7from lldbsuite.test import lldbutil8 9 10class TestCase(TestBase):11    @add_test_categories(["libc++"])12    @skipIf(compiler=no_match("clang"))13    @skipIf(macos_version=["<", "15.0"])14    @skipIf(15        bugnumber="ASTImport of lambdas not supported: https://github.com/llvm/llvm-project/issues/149477"16    )17    def test(self):18        self.build()19 20        lldbutil.run_to_source_breakpoint(21            self, "// Set break point at this line.", lldb.SBFileSpec("main.cpp")22        )23 24        self.runCmd("settings set target.import-std-module true")25 26        size_type = "size_type"27        value_type = "value_type"28        iterator = "iterator"29        riterator = "reverse_iterator"30 31        # Test inspecting an array of integers.32        array_type = "std::array<int, 3>"33        self.expect_expr(34            "a",35            result_type=array_type,36            result_children=[37                ValueCheck(38                    name="__elems_",39                    children=[40                        ValueCheck(value="3"),41                        ValueCheck(value="1"),42                        ValueCheck(value="2"),43                    ],44                )45            ],46        )47        self.expect_expr("a.size()", result_type=size_type, result_value="3")48        self.expect_expr("a.front()", result_type=value_type, result_value="3")49        self.expect_expr("a[1]", result_type=value_type, result_value="1")50        self.expect_expr("a.back()", result_type=value_type, result_value="2")51 52        # Both are just pointers to the underlying elements.53        self.expect_expr("a.begin()", result_type=iterator)54        self.expect_expr("a.rbegin()", result_type=riterator)55 56        self.expect_expr("*a.begin()", result_type=value_type, result_value="3")57        self.expect_expr("*a.rbegin()", result_type="int", result_value="2")58 59        self.expect_expr("a.at(0)", result_type=value_type, result_value="3")60 61        # Same again with an array that has an element type from debug info.62        array_type = "std::array<DbgInfo, 1>"63 64        dbg_info_elem_children = [ValueCheck(value="4")]65        dbg_info_elem = [ValueCheck(children=dbg_info_elem_children)]66 67        self.expect_expr(68            "b",69            result_type=array_type,70            result_children=[ValueCheck(name="__elems_", children=dbg_info_elem)],71        )72        self.expect_expr("b.size()", result_type=size_type, result_value="1")73        self.expect_expr(74            "b.front()", result_type=value_type, result_children=dbg_info_elem_children75        )76        self.expect_expr(77            "b[0]", result_type=value_type, result_children=dbg_info_elem_children78        )79        self.expect_expr(80            "b.back()", result_type=value_type, result_children=dbg_info_elem_children81        )82 83        # Both are just pointers to the underlying elements.84        self.expect_expr("b.begin()", result_type=iterator)85        self.expect_expr("b.rbegin()", result_type=riterator)86 87        self.expect_expr(88            "*b.begin()", result_type=value_type, result_children=dbg_info_elem_children89        )90        self.expect_expr(91            "*b.rbegin()", result_type="DbgInfo", result_children=dbg_info_elem_children92        )93 94        self.expect_expr(95            "b.at(0)", result_type=value_type, result_children=dbg_info_elem_children96        )97