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 def test_nscontainers_with_run_command(self): 18 """Test formatters for NS container classes.""" 19 self.appkit_tester_impl(self.nscontainers_data_formatter_commands) 20 21 def nscontainers_data_formatter_commands(self): 22 self.expect( 23 'frame variable newArray nsDictionary newDictionary nscfDictionary cfDictionaryRef newMutableDictionary newMutableDictionaryRef cfarray_ref mutable_array_ref', 24 substrs=[ 25 '(NSArray *) newArray = ', 26 ' @"50 elements"', 27 '(NSDictionary *) nsDictionary = ', 28 ' 2 key/value pairs', 29 '(NSDictionary *) newDictionary = ', 30 ' 12 key/value pairs', 31 '(NSDictionary *) nscfDictionary = ', 32 ' 4 key/value pairs', 33 '(CFDictionaryRef) cfDictionaryRef = ', 34 ' 2 key/value pairs', 35 '(NSDictionary *) newMutableDictionary = ', 36 ' 21 key/value pairs', 37 '(CFMutableDictionaryRef) newMutableDictionaryRef = ', 38 ' 21 key/value pairs', 39 '(CFArrayRef) cfarray_ref = ', 40 ' @"3 elements"', 41 '(CFMutableArrayRef) mutable_array_ref = ', 42 ' @"11 elements"', 43 ]) 44 45 self.expect( 46 'frame variable -d run-target *nscfDictionary', 47 patterns=[ 48 '\(__NSCFDictionary\) \*nscfDictionary =', 49 'key = 0x.* @"foo"', 50 'value = 0x.* @"foo"', 51 'key = 0x.* @"bar"', 52 'value = 0x.* @"bar"', 53 'key = 0x.* @"baz"', 54 'value = 0x.* @"baz"', 55 'key = 0x.* @"quux"', 56 'value = 0x.* @"quux"', 57 ]) 58 59 60 self.expect( 61 'frame variable -d run-target *cfDictionaryRef', 62 patterns=[ 63 '\(const __CFDictionary\) \*cfDictionaryRef =', 64 'key = 0x.* @"foo"', 65 'value = 0x.* @"foo"', 66 'key = 0x.* @"bar"', 67 'value = 0x.* @"bar"', 68 ]) 69 70 71 self.expect( 72 'frame var nscfSet cfSetRef', 73 substrs=[ 74 '(NSSet *) nscfSet = ', 75 '2 elements', 76 '(CFSetRef) cfSetRef = ', 77 '2 elements', 78 ]) 79 80 self.expect( 81 'frame variable -d run-target *nscfSet', 82 patterns=[ 83 '\(__NSCFSet\) \*nscfSet =', 84 '\[0\] = 0x.* @".*"', 85 '\[1\] = 0x.* @".*"', 86 ]) 87 88 self.expect( 89 'frame variable -d run-target *cfSetRef', 90 patterns=[ 91 '\(const __CFSet\) \*cfSetRef =', 92 '\[0\] = 0x.* @".*"', 93 '\[1\] = 0x.* @".*"', 94 ]) 95 96 self.expect( 97 'frame variable iset1 iset2 imset', 98 substrs=['4 indexes', '512 indexes', '10 indexes']) 99 100 self.expect( 101 'frame variable binheap_ref', 102 substrs=['(CFBinaryHeapRef) binheap_ref = ', '@"21 items"']) 103 104 self.expect( 105 'expression -d run -- (NSArray*)[NSArray new]', 106 substrs=['@"0 elements"']) 107