1"""
2Test that objective-c method returning BOOL works 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 MethodReturningBOOLTestCase(TestBase):
14
15    def setUp(self):
16        # Call super's setUp().
17        TestBase.setUp(self)
18        # We'll use the test method name as the exe_name.
19        self.exe_name = self.testMethodName
20        # Find the line number to break inside main().
21        self.main_source = "main.m"
22        self.line = line_number(self.main_source, '// Set breakpoint here.')
23
24    def test_method_ret_BOOL(self):
25        """Test that objective-c method returning BOOL works correctly."""
26        d = {'EXE': self.exe_name}
27        self.build(dictionary=d)
28        self.setTearDownCleanup(dictionary=d)
29
30        exe = self.getBuildArtifact(self.exe_name)
31        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
32
33        lldbutil.run_break_set_by_file_and_line(
34            self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
35
36        self.runCmd("run", RUN_SUCCEEDED)
37        self.expect(
38            "process status",
39            STOPPED_DUE_TO_BREAKPOINT,
40            substrs=[
41                "stop reason = breakpoint",
42                " at %s:%d" % (self.main_source, self.line),
43            ])
44
45        # rdar://problem/9691614
46        self.runCmd('p (int)[my isValid]')
47