1"""
2Test that the po command acts correctly.
3"""
4
5
6
7import lldb
8from lldbsuite.test.decorators import *
9from lldbsuite.test.lldbtest import *
10from lldbsuite.test import lldbutil
11
12
13class PoVerbosityTestCase(TestBase):
14
15    def setUp(self):
16        # Call super's setUp().
17        TestBase.setUp(self)
18        # Find the line number to break for main.cpp.
19        self.line = line_number('main.m',
20                                '// Stop here')
21
22    @add_test_categories(["objc"])
23    def test(self):
24        """Test that the po command acts correctly."""
25        self.build()
26
27        # This is the function to remove the custom formats in order to have a
28        # clean slate for the next test case.
29        def cleanup():
30            self.runCmd('type summary clear', check=False)
31            self.runCmd('type synthetic clear', check=False)
32
33        # Execute the cleanup function during test case tear down.
34        self.addTearDownHook(cleanup)
35
36        """Test expr + formatters for good interoperability."""
37        self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
38
39        lldbutil.run_break_set_by_file_and_line(
40            self, "main.m", self.line, loc_exact=True)
41
42        self.runCmd("run", RUN_SUCCEEDED)
43
44        self.expect("expr -O -v -- foo",
45                    substrs=['(id) $', ' = 0x', '1 = 2', '2 = 3;'])
46        self.expect("expr -O -vfull -- foo",
47                    substrs=['(id) $', ' = 0x', '1 = 2', '2 = 3;'])
48        self.expect("expr -O -- foo", matching=False,
49                    substrs=['(id) $'])
50
51        self.expect("expr -O -- 22", matching=False,
52                    substrs=['(int) $'])
53        self.expect("expr -O -- 22",
54                    substrs=['22'])
55
56        self.expect("expr -O -vfull -- 22",
57                    substrs=['(int) $', ' = 22'])
58
59        self.expect("expr -O -v -- 22",
60                    substrs=['(int) $', ' = 22'])
61