xref: /llvm-project/lldb/test/API/lang/objcxx/cxx-bridged-po/TestObjCXXBridgedPO.py (revision a4c18137d84bc48df49ee0101bef465a955e62ac)
1import lldb
2from lldbsuite.test.lldbtest import *
3from lldbsuite.test.decorators import *
4import lldbsuite.test.lldbutil as lldbutil
5
6
7class TestObjCXXBridgedPO(TestBase):
8    @skipIfDarwinEmbedded
9    @skipIf(macos_version=[">=", "13.0"])
10    def test_bridged_type_po_old(self):
11        self.build()
12        lldbutil.run_to_source_breakpoint(
13            self, "break here", lldb.SBFileSpec("main.mm")
14        )
15        self.expect(
16            "po num",
17            "did not get the Objective-C object description",
18            substrs=["CFNumber", "0x", "42"],
19        )
20        pointer_val = str(self.frame().FindVariable("num").GetValue())
21        self.expect(
22            "po " + pointer_val,
23            "did not get the Objective-C object description",
24            substrs=["CFNumber", "0x", "42"],
25        )
26
27    @skipIfDarwinEmbedded
28    @skipIf(macos_version=["<", "13.0"])
29    def test_bridged_type_po(self):
30        """Starting on macOS 13 CoreFoundation links against Foundation,
31        so we always get the Foundation object description.
32        """
33        self.build()
34        lldbutil.run_to_source_breakpoint(
35            self, "break here", lldb.SBFileSpec("main.mm")
36        )
37        self.expect(
38            "po num", "did not get the Objective-C object description", substrs=["42"]
39        )
40        pointer_val = str(self.frame().FindVariable("num").GetValue())
41        self.expect(
42            "po " + pointer_val,
43            "did not get the Objective-C object description",
44            substrs=["42"],
45        )
46