199451b44SJordan Rupprecht"""
299451b44SJordan RupprechtTest std::deque functionality with a decl from dbg info as content.
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 TestDbgInfoContentDeque(TestBase):
1199451b44SJordan Rupprecht
1299451b44SJordan Rupprecht    @add_test_categories(["libc++"])
1399451b44SJordan Rupprecht    @skipIf(compiler=no_match("clang"))
1499451b44SJordan Rupprecht    def test(self):
1599451b44SJordan Rupprecht        self.build()
1699451b44SJordan Rupprecht
1799451b44SJordan Rupprecht        lldbutil.run_to_source_breakpoint(self,
18cabee89bSRaphael Isemann                                          "// Set break point at this line.",
19cabee89bSRaphael Isemann                                          lldb.SBFileSpec("main.cpp"))
2099451b44SJordan Rupprecht
2199451b44SJordan Rupprecht        self.runCmd("settings set target.import-std-module true")
2299451b44SJordan Rupprecht
23*3f6c856bSRaphael Isemann        deque_type = "std::deque<Foo>"
24cabee89bSRaphael Isemann        size_type = deque_type + "::size_type"
25cabee89bSRaphael Isemann        value_type = "std::__deque_base<Foo, std::allocator<Foo> >::value_type"
26cabee89bSRaphael Isemann
27cabee89bSRaphael Isemann        iterator_type = deque_type + "::iterator"
28cabee89bSRaphael Isemann        iterator_children = [
29cabee89bSRaphael Isemann            ValueCheck(name="__m_iter_"),
30cabee89bSRaphael Isemann            ValueCheck(name="__ptr_")
31cabee89bSRaphael Isemann        ]
32cabee89bSRaphael Isemann
33cabee89bSRaphael Isemann        riterator_type = deque_type + "::reverse_iterator"
34cabee89bSRaphael Isemann        riterator_children = [
35cabee89bSRaphael Isemann            ValueCheck(name="__t"),
36cabee89bSRaphael Isemann            ValueCheck(name="current")
37cabee89bSRaphael Isemann        ]
38cabee89bSRaphael Isemann
39cabee89bSRaphael Isemann        self.expect_expr("a",
40cabee89bSRaphael Isemann                         result_type=deque_type,
41cabee89bSRaphael Isemann                         result_children=[
42cabee89bSRaphael Isemann                             ValueCheck(children=[ValueCheck(value="3")]),
43cabee89bSRaphael Isemann                             ValueCheck(children=[ValueCheck(value="1")]),
44cabee89bSRaphael Isemann                             ValueCheck(children=[ValueCheck(value="2")])
45cabee89bSRaphael Isemann                         ])
46cabee89bSRaphael Isemann
47cabee89bSRaphael Isemann        self.expect_expr("a.size()", result_type=size_type, result_value="3")
48cabee89bSRaphael Isemann        self.expect_expr("a.front()",
49cabee89bSRaphael Isemann                         result_type=value_type,
50cabee89bSRaphael Isemann                         result_children=[ValueCheck(value="3")])
51cabee89bSRaphael Isemann        self.expect_expr("a.back()",
52cabee89bSRaphael Isemann                         result_type=value_type,
53cabee89bSRaphael Isemann                         result_children=[ValueCheck(value="2")])
54cabee89bSRaphael Isemann        self.expect_expr("a.front().a", result_type="int", result_value="3")
55cabee89bSRaphael Isemann        self.expect_expr("a.back().a", result_type="int", result_value="2")
5699451b44SJordan Rupprecht
5799451b44SJordan Rupprecht        self.expect("expr std::reverse(a.begin(), a.end())")
58cabee89bSRaphael Isemann        self.expect_expr("a.front().a", result_type="int", result_value="2")
59cabee89bSRaphael Isemann        self.expect_expr("a.back().a", result_type="int", result_value="3")
6099451b44SJordan Rupprecht
61cabee89bSRaphael Isemann        self.expect_expr("a.begin()",
62cabee89bSRaphael Isemann                         result_type=iterator_type,
63cabee89bSRaphael Isemann                         result_children=iterator_children)
64cabee89bSRaphael Isemann        self.expect_expr("a.rbegin()",
65cabee89bSRaphael Isemann                         result_type=riterator_type,
66cabee89bSRaphael Isemann                         result_children=riterator_children)
67cabee89bSRaphael Isemann        self.expect_expr("a.begin()->a", result_type="int", result_value="2")
68cabee89bSRaphael Isemann        self.expect_expr("a.rbegin()->a", result_type="int", result_value="3")
69