1# encoding: utf-8 2""" 3Test lldb data formatter subsystem. 4""" 5 6 7import lldb 8from lldbsuite.test.decorators import * 9from lldbsuite.test.lldbtest import * 10from lldbsuite.test import lldbutil 11 12from ObjCDataFormatterTestCase import ObjCDataFormatterTestCase 13 14 15class ObjCDataFormatterNSContainer(ObjCDataFormatterTestCase): 16 17 @skipUnlessDarwin 18 def test_nscontainers_with_run_command(self): 19 """Test formatters for NS container classes.""" 20 self.appkit_tester_impl(self.nscontainers_data_formatter_commands) 21 22 def nscontainers_data_formatter_commands(self): 23 self.expect( 24 'frame variable newArray nsDictionary newDictionary nscfDictionary cfDictionaryRef newMutableDictionary cfarray_ref mutable_array_ref', 25 substrs=[ 26 '(NSArray *) newArray = ', 27 ' @"50 elements"', 28 '(NSDictionary *) nsDictionary = ', 29 ' 2 key/value pairs', 30 '(NSDictionary *) newDictionary = ', 31 ' 12 key/value pairs', 32 '(NSDictionary *) nscfDictionary = ', 33 ' 4 key/value pairs', 34 '(CFDictionaryRef) cfDictionaryRef = ', 35 ' 3 key/value pairs', 36 '(NSDictionary *) newMutableDictionary = ', 37 ' 21 key/value pairs', 38 '(CFArrayRef) cfarray_ref = ', 39 ' @"3 elements"', 40 '(CFMutableArrayRef) mutable_array_ref = ', 41 ' @"11 elements"', 42 ]) 43 44 self.expect( 45 'frame variable -d run-target *nscfDictionary', 46 patterns=[ 47 '\(__NSCFDictionary\) \*nscfDictionary =', 48 'key = 0x.* @"foo"', 49 'value = 0x.* @"foo"', 50 'key = 0x.* @"bar"', 51 'value = 0x.* @"bar"', 52 'key = 0x.* @"baz"', 53 'value = 0x.* @"baz"', 54 'key = 0x.* @"quux"', 55 'value = 0x.* @"quux"', 56 ]) 57 58 59 self.expect( 60 'frame var nscfSet', 61 substrs=[ 62 '(NSSet *) nscfSet = ', 63 '2 elements', 64 ]) 65 66 self.expect( 67 'frame variable -d run-target *nscfSet', 68 patterns=[ 69 '\(__NSCFSet\) \*nscfSet =', 70 '\[0\] = 0x.* @".*"', 71 '\[1\] = 0x.* @".*"', 72 ]) 73 74 self.expect( 75 'frame variable iset1 iset2 imset', 76 substrs=['4 indexes', '512 indexes', '10 indexes']) 77 78 self.expect( 79 'frame variable binheap_ref', 80 substrs=['(CFBinaryHeapRef) binheap_ref = ', '@"21 items"']) 81 82 self.expect( 83 'expression -d run -- (NSArray*)[NSArray new]', 84 substrs=['@"0 elements"']) 85