xref: /llvm-project/lldb/test/API/lang/cpp/crtp/TestCppCRTP.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
1"""
2A test for the curiously recurring template pattern (or CRTP).
3
4Note that the derived class is referenced directly from the parent class in the
5test. If this fails then there is a good chance that LLDB tried to eagerly
6resolve the definition of the derived class while constructing the base class.
7"""
8
9import lldb
10from lldbsuite.test.decorators import *
11from lldbsuite.test.lldbtest import *
12from lldbsuite.test import lldbutil
13
14
15class TestCase(TestBase):
16    @no_debug_info_test
17    def test(self):
18        self.build()
19        self.createTestTarget()
20
21        # Try using the class in the expression evaluator.
22        self.expect_expr(
23            "derived",
24            result_type="Derived",
25            result_children=[
26                ValueCheck(name="Base<Derived>"),
27                ValueCheck(name="member", value="0"),
28            ],
29        )
30
31        # Try accessing the members of the class and base class.
32        self.expect_expr("derived.pointer", result_type="Derived *")
33        self.expect_expr("derived.member", result_type="int", result_value="0")
34