1"""
2Test basic std::list functionality but with a declaration from
3the debug info (the Foo struct) as content.
4"""
5
6from lldbsuite.test.decorators import *
7from lldbsuite.test.lldbtest import *
8from lldbsuite.test import lldbutil
9
10
11class TestDbgInfoContentList(TestBase):
12
13    @add_test_categories(["libc++"])
14    @skipIf(compiler=no_match("clang"))
15    def test(self):
16        self.build()
17
18        lldbutil.run_to_source_breakpoint(self,
19                                          "// Set break point at this line.",
20                                          lldb.SBFileSpec("main.cpp"))
21
22        self.runCmd("settings set target.import-std-module true")
23
24        list_type = "std::list<Foo>"
25        size_type = list_type + "::size_type"
26        value_type = list_type + "::value_type"
27
28        self.expect_expr("a",
29                         result_type=list_type,
30                         result_children=[
31                             ValueCheck(children=[ValueCheck(value="3")]),
32                             ValueCheck(children=[ValueCheck(value="1")]),
33                             ValueCheck(children=[ValueCheck(value="2")])
34                         ])
35
36        self.expect_expr("a.size()", result_type=size_type, result_value="3")
37        self.expect_expr("a.front().a", result_type="int", result_value="3")
38        self.expect_expr("a.back().a", result_type="int", result_value="2")
39
40        self.expect("expr std::reverse(a.begin(), a.end())")
41        self.expect_expr("a.front().a", result_type="int", result_value="2")
42        self.expect_expr("a.back().a", result_type="int", result_value="3")
43
44        self.expect_expr("a.begin()->a", result_type="int", result_value="2")
45        self.expect_expr("a.rbegin()->a", result_type="int", result_value="3")
46