xref: /llvm-project/lldb/test/API/lang/cpp/const_this/TestConstThis.py (revision 4cc8f2a017c76af25234afc7c380550e9c93135c)
1import lldb
2from lldbsuite.test.decorators import *
3from lldbsuite.test.lldbtest import *
4from lldbsuite.test import lldbutil
5
6
7class TestCase(TestBase):
8    NO_DEBUG_INFO_TESTCASE = True
9
10    def run_class_tests(self):
11        # Expression not referencing context class.
12        self.expect_expr("1 + 1", result_type="int", result_value="2")
13        # Referencing context class.
14        # FIXME: This and the expression below should return const types.
15        self.expect_expr("member", result_type="int", result_value="3")
16        # Check the type of context class.
17        self.expect_expr("this", result_type="ContextClass *")
18
19    def test_member_func(self):
20        self.build()
21        lldbutil.run_to_source_breakpoint(
22            self, "// break in function in class.", lldb.SBFileSpec("main.cpp")
23        )
24        self.run_class_tests()
25
26    def test_templated_member_func(self):
27        self.build()
28        lldbutil.run_to_source_breakpoint(
29            self,
30            "// break in templated function in class.",
31            lldb.SBFileSpec("main.cpp"),
32        )
33        self.run_class_tests()
34
35    def run_template_class_tests(self):
36        # Expression not referencing context class.
37        self.expect_expr("1 + 1", result_type="int", result_value="2")
38        # Referencing context class.
39        # FIXME: This and the expression below should return const types.
40        self.expect_expr("member", result_type="int", result_value="4")
41        # Check the type of context class.
42        self.expect_expr("this", result_type="TemplatedContextClass<int> *")
43
44    def test_template_member_func(self):
45        self.build()
46        lldbutil.run_to_source_breakpoint(
47            self,
48            "// break in function in templated class.",
49            lldb.SBFileSpec("main.cpp"),
50        )
51        self.run_template_class_tests()
52
53    def test_template_templated_member_func(self):
54        self.build()
55        lldbutil.run_to_source_breakpoint(
56            self,
57            "// break in templated function in templated class.",
58            lldb.SBFileSpec("main.cpp"),
59        )
60        self.run_template_class_tests()
61