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