• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1"""
2Test more expression command sequences with objective-c.
3"""
4
5
6
7import lldb
8from lldbsuite.test.decorators import *
9from lldbsuite.test.lldbtest import *
10from lldbsuite.test import lldbutil
11
12
13class FoundationTestCaseNSError(TestBase):
14
15    mydir = TestBase.compute_mydir(__file__)
16
17    @expectedFailureAll(archs=["i[3-6]86"], bugnumber="<rdar://problem/28814052>")
18    def test_runtime_types(self):
19        """Test commands that require runtime types"""
20        self.build()
21        self.target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
22                self, '// Break here for NSString tests',
23                lldb.SBFileSpec('main.m', False))
24
25        # Test_NSString:
26        self.runCmd("thread backtrace")
27        self.expect("expression [str length]",
28                    patterns=["\(NSUInteger\) \$.* ="])
29        self.expect("expression str.length")
30        self.expect('expression str = [NSString stringWithCString: "new"]')
31        self.expect(
32            'po [NSError errorWithDomain:@"Hello" code:35 userInfo:@{@"NSDescription" : @"be completed."}]',
33            substrs=[
34                "Error Domain=Hello",
35                "Code=35",
36                "be completed."])
37        self.runCmd("process continue")
38
39    @expectedFailureAll(archs=["i[3-6]86"], bugnumber="<rdar://problem/28814052>")
40    def test_NSError_p(self):
41        """Test that p of the result of an unknown method does require a cast."""
42        self.build()
43        self.target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
44                self, '// Set break point at this line',
45                lldb.SBFileSpec('main.m', False))
46        self.expect("p [NSError thisMethodIsntImplemented:0]", error=True, patterns=[
47                    "no known method", "cast the message send to the method's return type"])
48        self.runCmd("process continue")
49