brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.9 KiB · e6fb549 Raw
122 lines · python
1# encoding: utf-82"""3Test lldb data formatter subsystem.4"""5 6 7import lldb8from lldbsuite.test.decorators import *9from lldbsuite.test.lldbtest import *10from lldbsuite.test import lldbutil11 12from ObjCDataFormatterTestCase import ObjCDataFormatterTestCase13 14 15class ObjCDataFormatterNSContainer(ObjCDataFormatterTestCase):16    def test_nscontainers_with_run_command(self):17        """Test formatters for  NS container classes."""18        self.appkit_tester_impl(self.nscontainers_data_formatter_commands, False)19 20    def nscontainers_data_formatter_commands(self):21        self.runCmd("settings set target.prefer-dynamic-value no-dynamic-values")22 23        self.expect(24            "frame variable newArray nsDictionary newDictionary nscfDictionary cfDictionaryRef newMutableDictionary copyDictionary newMutableDictionaryRef 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                "(NSMutableDictionary *) copyDictionary = ",39                " 21 key/value pairs",40                "(CFMutableDictionaryRef) newMutableDictionaryRef = ",41                " 21 key/value pairs",42                "(CFArrayRef) cfarray_ref = ",43                ' @"3 elements"',44                "(CFMutableArrayRef) mutable_array_ref = ",45                ' @"11 elements"',46            ],47        )48 49        self.expect(50            "frame var -d run-target copyDictionary[10]", substrs=['@"bar9"', '@"foo"']51        )52 53        self.expect(54            "frame variable -d run-target *nscfDictionary",55            ordered=False,56            patterns=[57                r"\(__NSCFDictionary\) \*nscfDictionary =",58                'key = 0x.* @"foo"',59                'value = 0x.* @"foo"',60                'key = 0x.* @"bar"',61                'value = 0x.* @"bar"',62                'key = 0x.* @"baz"',63                'value = 0x.* @"baz"',64                'key = 0x.* @"quux"',65                'value = 0x.* @"quux"',66            ],67        )68 69        self.expect(70            "frame variable -d run-target *cfDictionaryRef",71            ordered=False,72            patterns=[73                r"\(const __CFDictionary\) \*cfDictionaryRef =",74                'key = 0x.* @"foo"',75                'value = 0x.* @"foo"',76                'key = 0x.* @"bar"',77                'value = 0x.* @"bar"',78            ],79        )80 81        self.expect(82            "frame var nscfSet cfSetRef",83            substrs=[84                "(NSSet *) nscfSet = ",85                "2 elements",86                "(CFSetRef) cfSetRef = ",87                "2 elements",88            ],89        )90 91        self.expect(92            "frame variable -d run-target *nscfSet",93            patterns=[94                r"\(__NSCFSet\) \*nscfSet =",95                r'\[0\] = 0x.* @".*"',96                r'\[1\] = 0x.* @".*"',97            ],98        )99 100        self.expect(101            "frame variable -d run-target *cfSetRef",102            patterns=[103                r"\(const __CFSet\) \*cfSetRef =",104                r'\[0\] = 0x.* @".*"',105                r'\[1\] = 0x.* @".*"',106            ],107        )108 109        self.expect(110            "frame variable iset1 iset2 imset",111            substrs=["4 indexes", "512 indexes", "10 indexes"],112        )113 114        self.expect(115            "frame variable binheap_ref",116            substrs=["(CFBinaryHeapRef) binheap_ref = ", '@"21 items"'],117        )118 119        self.expect(120            "expression -d run -- (NSArray*)[NSArray new]", substrs=['@"0 elements"']121        )122