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    @add_test_categories(["libc++"])
13    @skipIf(compiler=no_match("clang"))
14    @skipIf(compiler="clang", compiler_version=["<", "12.0"])
15    @skipIf(macos_version=["<", "14.0"])
16    def test(self):
17        self.build()
18
19        lldbutil.run_to_source_breakpoint(
20            self, "// Set break point at this line.", lldb.SBFileSpec("main.cpp")
21        )
22
23        self.runCmd("settings set target.import-std-module true")
24
25        if self.expectedCompiler(["clang"]) and self.expectedCompilerVersion(
26            [">", "16.0"]
27        ):
28            list_type = "std::list<Foo>"
29        else:
30            list_type = "std::list<Foo, std::allocator<Foo> >"
31
32        size_type = "size_type"
33        value_type = "value_type"
34
35        self.expect_expr(
36            "a",
37            result_type=list_type,
38            result_children=[
39                ValueCheck(children=[ValueCheck(value="3")]),
40                ValueCheck(children=[ValueCheck(value="1")]),
41                ValueCheck(children=[ValueCheck(value="2")]),
42            ],
43        )
44
45        self.expect_expr("a.size()", result_type=size_type, result_value="3")
46        self.expect_expr("a.front().a", result_type="int", result_value="3")
47        self.expect_expr("a.back().a", result_type="int", result_value="2")
48
49        self.expect("expr std::reverse(a.begin(), a.end())")
50        self.expect_expr("a.front().a", result_type="int", result_value="2")
51        self.expect_expr("a.back().a", result_type="int", result_value="3")
52
53        self.expect_expr("a.begin()->a", result_type="int", result_value="2")
54        self.expect_expr("a.rbegin()->a", result_type="int", result_value="3")
55