xref: /llvm-project/lldb/test/API/lang/cpp/scope/TestCppScope.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
199451b44SJordan Rupprechtimport lldb
299451b44SJordan Rupprechtfrom lldbsuite.test.decorators import *
399451b44SJordan Rupprechtfrom lldbsuite.test.lldbtest import *
499451b44SJordan Rupprechtfrom lldbsuite.test import lldbutil
599451b44SJordan Rupprecht
699451b44SJordan Rupprecht
7*2238dcc3SJonas Devlieghereclass TestCase(TestBase):
899451b44SJordan Rupprecht    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
9acb0b99cSRaphael Isemann    def test(self):
1099451b44SJordan Rupprecht        self.build()
11*2238dcc3SJonas Devlieghere        lldbutil.run_to_source_breakpoint(
12*2238dcc3SJonas Devlieghere            self, "// break here", lldb.SBFileSpec("main.cpp")
13*2238dcc3SJonas Devlieghere        )
1499451b44SJordan Rupprecht
15acb0b99cSRaphael Isemann        # Test that global variables contain the right scope operators.
16acb0b99cSRaphael Isemann        global_vars = self.frame().GetVariables(False, False, True, False)
17239093f3SJan Kratochvil        # ManualDWARFIndex using NameToDIE does not sort alphabetically.
18239093f3SJan Kratochvil        global_var_names = sorted([v.GetName() for v in global_vars])
19239093f3SJan Kratochvil        expected_var_names = ["::a", "A::a", "B::a", "C::a"]
20acb0b99cSRaphael Isemann        self.assertEqual(global_var_names, expected_var_names)
2199451b44SJordan Rupprecht
22acb0b99cSRaphael Isemann        # Test lookup in scopes.
23acb0b99cSRaphael Isemann        self.expect_expr("A::a", result_value="1111")
24acb0b99cSRaphael Isemann        self.expect_expr("B::a", result_value="2222")
25acb0b99cSRaphael Isemann        self.expect_expr("C::a", result_value="3333")
26acb0b99cSRaphael Isemann        self.expect_expr("::a", result_value="4444")
27acb0b99cSRaphael Isemann        # Check that lookup without scope returns the same result.
28acb0b99cSRaphael Isemann        self.expect_expr("a", result_value="4444")
29