Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / test / API / lang / objc / single-entry-dictionary / TestObjCSingleEntryDictionary.py
blob68c0af76b8e3b846e070873cf6b033c2c8be14bb
1 """Test that we properly vend children for a single entry NSDictionary"""
4 import lldb
5 from lldbsuite.test.decorators import *
6 from lldbsuite.test.lldbtest import *
7 from lldbsuite.test import lldbutil
10 class ObjCSingleEntryDictionaryTestCase(TestBase):
11 def setUp(self):
12 # Call super's setUp().
13 TestBase.setUp(self)
14 # Find the line number to break inside main().
15 self.line = line_number("main.m", "// break here")
17 @skipUnlessDarwin
18 @expectedFailureAll(
19 oslist=["watchos"], bugnumber="rdar://problem/34642736"
20 ) # bug in NSDictionary formatting on watchos
21 def test_single_entry_dict(self):
22 self.build()
23 self.run_tests()
25 @skipUnlessDarwin
26 @expectedFailureAll(
27 oslist=["watchos"], bugnumber="rdar://problem/34642736"
28 ) # bug in NSDictionary formatting on watchos
29 def test_single_entry_dict_no_const(self):
30 disable_constant_classes = {
31 "CC": "xcrun clang", # FIXME: Remove when flags are available upstream.
32 "CFLAGS_EXTRAS": "-fno-constant-nsnumber-literals "
33 + "-fno-constant-nsarray-literals "
34 + "-fno-constant-nsdictionary-literals",
36 self.build(dictionary=disable_constant_classes)
37 self.run_tests()
39 def run_tests(self):
40 exe = self.getBuildArtifact("a.out")
41 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
43 # Break inside the foo function which takes a bar_ptr argument.
44 lldbutil.run_break_set_by_file_and_line(
45 self, "main.m", self.line, num_expected_locations=1, loc_exact=True
48 self.runCmd("run", RUN_SUCCEEDED)
50 # The stop reason of the thread should be breakpoint.
51 self.expect(
52 "thread list",
53 STOPPED_DUE_TO_BREAKPOINT,
54 substrs=["stopped", "stop reason = breakpoint"],
57 # The breakpoint should have a hit count of 1.
58 lldbutil.check_breakpoint(self, bpno=1, expected_hit_count=1)
60 d1 = self.frame().FindVariable("d1")
61 d1.SetPreferSyntheticValue(True)
62 d1.SetPreferDynamicValue(lldb.eDynamicCanRunTarget)
64 self.assertEqual(d1.GetNumChildren(), 1, "dictionary has != 1 child elements")
65 pair = d1.GetChildAtIndex(0)
66 pair.SetPreferSyntheticValue(True)
67 pair.SetPreferDynamicValue(lldb.eDynamicCanRunTarget)
69 self.assertEqual(pair.GetNumChildren(), 2, "pair has != 2 child elements")
71 key = pair.GetChildMemberWithName("key")
72 value = pair.GetChildMemberWithName("value")
74 key.SetPreferSyntheticValue(True)
75 key.SetPreferDynamicValue(lldb.eDynamicCanRunTarget)
76 value.SetPreferSyntheticValue(True)
77 value.SetPreferDynamicValue(lldb.eDynamicCanRunTarget)
79 self.assertEqual(key.GetSummary(), '@"key"', "key doesn't contain key")
80 self.assertEqual(value.GetSummary(), '@"value"', "value doesn't contain value")