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