199451b44SJordan Rupprecht"""
299451b44SJordan RupprechtTest basic std::list functionality.
399451b44SJordan Rupprecht"""
499451b44SJordan Rupprecht
599451b44SJordan Rupprechtfrom lldbsuite.test.decorators import *
699451b44SJordan Rupprechtfrom lldbsuite.test.lldbtest import *
799451b44SJordan Rupprechtfrom lldbsuite.test import lldbutil
899451b44SJordan Rupprecht
9cabee89bSRaphael Isemann
1099451b44SJordan Rupprechtclass TestBasicDeque(TestBase):
1199451b44SJordan Rupprecht    @add_test_categories(["libc++"])
1299451b44SJordan Rupprecht    @skipIf(compiler=no_match("clang"))
1399451b44SJordan Rupprecht    def test(self):
1499451b44SJordan Rupprecht        self.build()
1599451b44SJordan Rupprecht
16*2238dcc3SJonas Devlieghere        lldbutil.run_to_source_breakpoint(
17*2238dcc3SJonas Devlieghere            self, "// Set break point at this line.", lldb.SBFileSpec("main.cpp")
18*2238dcc3SJonas Devlieghere        )
1999451b44SJordan Rupprecht
2099451b44SJordan Rupprecht        self.runCmd("settings set target.import-std-module true")
2199451b44SJordan Rupprecht
22*2238dcc3SJonas Devlieghere        if self.expectedCompiler(["clang"]) and self.expectedCompilerVersion(
23*2238dcc3SJonas Devlieghere            [">", "16.0"]
24*2238dcc3SJonas Devlieghere        ):
253f6c856bSRaphael Isemann            deque_type = "std::deque<int>"
263c667298SMichael Buch        else:
273c667298SMichael Buch            deque_type = "std::deque<int, std::allocator<int> >"
283c667298SMichael Buch
2915f3cd6bSMatheus Izvekov        size_type = "size_type"
3015f3cd6bSMatheus Izvekov        value_type = "value_type"
3115f3cd6bSMatheus Izvekov        iterator = "iterator"
32*2238dcc3SJonas Devlieghere        iterator_children = [ValueCheck(name="__m_iter_"), ValueCheck(name="__ptr_")]
3315f3cd6bSMatheus Izvekov        riterator = "reverse_iterator"
34cabee89bSRaphael Isemann        riterator_children = [
357ccfaecbSMichael Buch            ValueCheck(),  # Deprecated __t_ member; no need to check
36*2238dcc3SJonas Devlieghere            ValueCheck(name="current"),
37cabee89bSRaphael Isemann        ]
38cabee89bSRaphael Isemann
39*2238dcc3SJonas Devlieghere        self.expect_expr(
40*2238dcc3SJonas Devlieghere            "a",
41cabee89bSRaphael Isemann            result_type=deque_type,
42cabee89bSRaphael Isemann            result_children=[
43*2238dcc3SJonas Devlieghere                ValueCheck(value="3"),
44*2238dcc3SJonas Devlieghere                ValueCheck(value="1"),
45*2238dcc3SJonas Devlieghere                ValueCheck(value="2"),
46*2238dcc3SJonas Devlieghere            ],
47*2238dcc3SJonas Devlieghere        )
48cabee89bSRaphael Isemann
49cabee89bSRaphael Isemann        self.expect_expr("a.size()", result_type=size_type, result_value="3")
50cabee89bSRaphael Isemann        self.expect_expr("a.front()", result_type=value_type, result_value="3")
51cabee89bSRaphael Isemann        self.expect_expr("a.back()", result_type=value_type, result_value="2")
5299451b44SJordan Rupprecht
5399451b44SJordan Rupprecht        self.expect("expr std::sort(a.begin(), a.end())")
54cabee89bSRaphael Isemann        self.expect_expr("a.front()", result_type=value_type, result_value="1")
55cabee89bSRaphael Isemann        self.expect_expr("a.back()", result_type=value_type, result_value="3")
5699451b44SJordan Rupprecht
5799451b44SJordan Rupprecht        self.expect("expr std::reverse(a.begin(), a.end())")
58cabee89bSRaphael Isemann        self.expect_expr("a.front()", result_type=value_type, result_value="3")
59cabee89bSRaphael Isemann        self.expect_expr("a.back()", result_type=value_type, result_value="1")
6099451b44SJordan Rupprecht
61cabee89bSRaphael Isemann        self.expect_expr("*a.begin()", result_type="int", result_value="3")
62cabee89bSRaphael Isemann        self.expect_expr("*a.rbegin()", result_type="int", result_value="1")
63*2238dcc3SJonas Devlieghere        self.expect_expr(
64*2238dcc3SJonas Devlieghere            "a.begin()", result_type=iterator, result_children=iterator_children
65*2238dcc3SJonas Devlieghere        )
66*2238dcc3SJonas Devlieghere        self.expect_expr(
67*2238dcc3SJonas Devlieghere            "a.rbegin()", result_type=riterator, result_children=riterator_children
68*2238dcc3SJonas Devlieghere        )
69