xref: /llvm-project/lldb/test/API/commands/expression/import-std-module/pair/TestPairFromStdModule.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
1b8522252SRaphael Isemann"""
2b8522252SRaphael IsemannTest basic std::pair functionality.
3b8522252SRaphael Isemann"""
4b8522252SRaphael Isemann
5b8522252SRaphael Isemannfrom lldbsuite.test.decorators import *
6b8522252SRaphael Isemannfrom lldbsuite.test.lldbtest import *
7b8522252SRaphael Isemannfrom lldbsuite.test import lldbutil
8b8522252SRaphael Isemann
9cabee89bSRaphael Isemann
10b8522252SRaphael Isemannclass TestCase(TestBase):
11b8522252SRaphael Isemann    @add_test_categories(["libc++"])
12b8522252SRaphael Isemann    @skipIf(compiler=no_match("clang"))
13c0003232SRaphael Isemann    # FIXME: This regressed in 69d5a6662115499198ebfa07a081e98a6ce4b915
14c0003232SRaphael Isemann    # but needs further investigation for what underlying Clang/LLDB bug can't
15c0003232SRaphael Isemann    # handle that code change.
16c0003232SRaphael Isemann    @skipIf
17b8522252SRaphael Isemann    def test(self):
18b8522252SRaphael Isemann        self.build()
19b8522252SRaphael Isemann
20*2238dcc3SJonas Devlieghere        lldbutil.run_to_source_breakpoint(
21*2238dcc3SJonas Devlieghere            self, "// Set break point at this line.", lldb.SBFileSpec("main.cpp")
22*2238dcc3SJonas Devlieghere        )
23b8522252SRaphael Isemann
24b8522252SRaphael Isemann        self.runCmd("settings set target.import-std-module true")
25b8522252SRaphael Isemann
26*2238dcc3SJonas Devlieghere        self.expect_expr("pair_int.first", result_type="int", result_value="1234")
27*2238dcc3SJonas Devlieghere        self.expect_expr("pair_int.second", result_type="int", result_value="5678")
28*2238dcc3SJonas Devlieghere        self.expect_expr(
29*2238dcc3SJonas Devlieghere            "pair_int",
30cabee89bSRaphael Isemann            result_type="std::pair<int, int>",
31cabee89bSRaphael Isemann            result_children=[
32cabee89bSRaphael Isemann                ValueCheck(name="first", value="1234"),
33cabee89bSRaphael Isemann                ValueCheck(name="second", value="5678"),
34*2238dcc3SJonas Devlieghere            ],
35*2238dcc3SJonas Devlieghere        )
36cabee89bSRaphael Isemann        self.expect_expr(
37cabee89bSRaphael Isemann            "std::pair<long, long> lp; lp.first = 3333; lp.second = 2344; lp",
38cabee89bSRaphael Isemann            result_type="std::pair<long, long>",
39cabee89bSRaphael Isemann            result_children=[
40cabee89bSRaphael Isemann                ValueCheck(name="first", value="3333"),
41cabee89bSRaphael Isemann                ValueCheck(name="second", value="2344"),
42*2238dcc3SJonas Devlieghere            ],
43*2238dcc3SJonas Devlieghere        )
44