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 ' 2 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 variable -d run-target *cfDictionaryRef', 61 patterns=[ 62 '\(const __CFDictionary\) \*cfDictionaryRef =', 63 'key = 0x.* @"foo"', 64 'value = 0x.* @"foo"', 65 'key = 0x.* @"bar"', 66 'value = 0x.* @"bar"', 67 ]) 68 69 70 self.expect( 71 'frame var nscfSet cfSetRef', 72 substrs=[ 73 '(NSSet *) nscfSet = ', 74 '2 elements', 75 '(CFSetRef) cfSetRef = ', 76 '2 elements', 77 ]) 78 79 self.expect( 80 'frame variable -d run-target *nscfSet', 81 patterns=[ 82 '\(__NSCFSet\) \*nscfSet =', 83 '\[0\] = 0x.* @".*"', 84 '\[1\] = 0x.* @".*"', 85 ]) 86 87 self.expect( 88 'frame variable -d run-target *cfSetRef', 89 patterns=[ 90 '\(const __CFSet\) \*cfSetRef =', 91 '\[0\] = 0x.* @".*"', 92 '\[1\] = 0x.* @".*"', 93 ]) 94 95 self.expect( 96 'frame variable iset1 iset2 imset', 97 substrs=['4 indexes', '512 indexes', '10 indexes']) 98 99 self.expect( 100 'frame variable binheap_ref', 101 substrs=['(CFBinaryHeapRef) binheap_ref = ', '@"21 items"']) 102 103 self.expect( 104 'expression -d run -- (NSArray*)[NSArray new]', 105 substrs=['@"0 elements"']) 106