2 Test lldb data formatter subsystem.
5 from __future__ import print_function
11 from lldbsuite.test.lldbtest import *
13 import lldbsuite.test.lldbutil as lldbutil
15 class NSDictionarySyntheticTestCase(TestBase):
17 mydir = TestBase.compute_mydir(__file__)
20 # Call super's setUp().
22 # Find the line number to break at.
23 self.line = line_number('main.m', '// Set break point at this line.')
26 def test_rdar11988289_with_run_command(self):
27 """Test that NSDictionary reports its synthetic children properly."""
29 self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
31 lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
33 self.runCmd("run", RUN_SUCCEEDED)
35 # The stop reason of the thread should be breakpoint.
36 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
38 'stop reason = breakpoint'])
40 # This is the function to remove the custom formats in order to have a
41 # clean slate for the next test case.
43 self.runCmd('type format clear', check=False)
44 self.runCmd('type summary clear', check=False)
45 self.runCmd('type synth clear', check=False)
47 # Execute the cleanup function during test case tear down.
48 self.addTearDownHook(cleanup)
50 # Now check that we are displaying Cocoa classes correctly
51 self.expect('frame variable dictionary',
52 substrs = ['3 key/value pairs'])
53 self.expect('frame variable mutabledict',
54 substrs = ['4 key/value pairs'])
55 self.expect('frame variable dictionary --ptr-depth 1',
56 substrs = ['3 key/value pairs','[0] = ','key = 0x','value = 0x','[1] = ','[2] = '])
57 self.expect('frame variable mutabledict --ptr-depth 1',
58 substrs = ['4 key/value pairs','[0] = ','key = 0x','value = 0x','[1] = ','[2] = ','[3] = '])
59 self.expect('frame variable dictionary --ptr-depth 1 --dynamic-type no-run-target',
60 substrs = ['3 key/value pairs','@"bar"','@"2 elements"','@"baz"','2 key/value pairs'])
61 self.expect('frame variable mutabledict --ptr-depth 1 --dynamic-type no-run-target',
62 substrs = ['4 key/value pairs','(int)23','@"123"','@"http://www.apple.com"','@"sourceofstuff"','3 key/value pairs'])
63 self.expect('frame variable mutabledict --ptr-depth 2 --dynamic-type no-run-target',
64 substrs = ['4 key/value pairs','(int)23','@"123"','@"http://www.apple.com"','@"sourceofstuff"','3 key/value pairs','@"bar"','@"2 elements"'])
65 self.expect('frame variable mutabledict --ptr-depth 3 --dynamic-type no-run-target',
66 substrs = ['4 key/value pairs','(int)23','@"123"','@"http://www.apple.com"','@"sourceofstuff"','3 key/value pairs','@"bar"','@"2 elements"','(int)1','@"two"'])
68 self.assertTrue(self.frame().FindVariable("dictionary").MightHaveChildren(), "dictionary says it does not have children!")
69 self.assertTrue(self.frame().FindVariable("mutabledict").MightHaveChildren(), "mutable says it does not have children!")