xref: /llvm-project/lldb/test/API/lang/cpp/scope/TestCppScope.py (revision 4cc8f2a017c76af25234afc7c380550e9c93135c)
1import lldb
2from lldbsuite.test.decorators import *
3from lldbsuite.test.lldbtest import *
4from lldbsuite.test import lldbutil
5
6class TestCase(TestBase):
7
8    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
9    def test(self):
10        self.build()
11        lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.cpp"))
12
13        # Test that global variables contain the right scope operators.
14        global_vars = self.frame().GetVariables(False, False, True, False)
15        # ManualDWARFIndex using NameToDIE does not sort alphabetically.
16        global_var_names = sorted([v.GetName() for v in global_vars])
17        expected_var_names = ["::a", "A::a", "B::a", "C::a"]
18        self.assertEqual(global_var_names, expected_var_names)
19
20        # Test lookup in scopes.
21        self.expect_expr("A::a", result_value="1111")
22        self.expect_expr("B::a", result_value="2222")
23        self.expect_expr("C::a", result_value="3333")
24        self.expect_expr("::a", result_value="4444")
25        # Check that lookup without scope returns the same result.
26        self.expect_expr("a", result_value="4444")
27