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