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