@@ -16,7 +16,7 @@ def _run_cmd(self, cmd: str) -> str:
1616 self .ci .HandleCommand (cmd , result )
1717 return result .GetOutput ().rstrip ()
1818
19- VAR_IDENT = re .compile (r"(?:\$\d+|\w +) = " )
19+ VAR_IDENT = re .compile (r"(?:\$\d+|[\w.] +) = " )
2020
2121 def _strip_result_var (self , string : str ) -> str :
2222 """
@@ -121,30 +121,39 @@ def test_empty_expression(self):
121121 def test_nested_values (self ):
122122 """Test dwim-print with nested values (structs, etc)."""
123123 self .build ()
124- lldbutil .run_to_source_breakpoint (self , "break here" , lldb .SBFileSpec ("main.c" ))
124+ lldbutil .run_to_source_breakpoint (
125+ self , "break here" , lldb .SBFileSpec ("main.cpp" )
126+ )
125127 self .runCmd ("settings set auto-one-line-summaries false" )
126128 self ._expect_cmd (f"dwim-print s" , "frame variable" )
127129 self ._expect_cmd (f"dwim-print (struct Structure)s" , "expression" )
128130
129131 def test_summary_strings (self ):
130- """Test dwim-print with nested values (structs, etc) ."""
132+ """Test dwim-print with type summaries ."""
131133 self .build ()
132- lldbutil .run_to_source_breakpoint (self , "break here" , lldb .SBFileSpec ("main.c" ))
134+ lldbutil .run_to_source_breakpoint (
135+ self , "break here" , lldb .SBFileSpec ("main.cpp" )
136+ )
133137 self .runCmd ("settings set auto-one-line-summaries false" )
134138 self .runCmd ("type summary add -e -s 'stub summary' Structure" )
135139 self ._expect_cmd (f"dwim-print s" , "frame variable" )
136140 self ._expect_cmd (f"dwim-print (struct Structure)s" , "expression" )
141+ self .runCmd ("type summary delete Structure" )
137142
138143 def test_void_result (self ):
139144 """Test dwim-print does not surface an error message for void expressions."""
140145 self .build ()
141- lldbutil .run_to_source_breakpoint (self , "break here" , lldb .SBFileSpec ("main.c" ))
146+ lldbutil .run_to_source_breakpoint (
147+ self , "break here" , lldb .SBFileSpec ("main.cpp" )
148+ )
142149 self .expect ("dwim-print (void)15" , matching = False , patterns = ["(?i)error" ])
143150
144151 def test_preserves_persistent_variables (self ):
145152 """Test dwim-print does not delete persistent variables."""
146153 self .build ()
147- lldbutil .run_to_source_breakpoint (self , "break here" , lldb .SBFileSpec ("main.c" ))
154+ lldbutil .run_to_source_breakpoint (
155+ self , "break here" , lldb .SBFileSpec ("main.cpp" )
156+ )
148157 self .expect ("dwim-print int $i = 15" )
149158 # Run the same expression twice and verify success. This ensures the
150159 # first command does not delete the persistent variable.
@@ -154,5 +163,25 @@ def test_preserves_persistent_variables(self):
154163 def test_missing_type (self ):
155164 """The expected output of po opaque is its address (no error)"""
156165 self .build ()
157- lldbutil .run_to_source_breakpoint (self , "break here" , lldb .SBFileSpec ("main.c" ))
166+ lldbutil .run_to_source_breakpoint (
167+ self , "break here" , lldb .SBFileSpec ("main.cpp" )
168+ )
158169 self .expect ("dwim-print -O -- opaque" , substrs = ["0x" ])
170+
171+ def test_variable_expression_path (self ):
172+ """Test dwim-print supports certain variable expression paths."""
173+ self .build ()
174+ lldbutil .run_to_source_breakpoint (
175+ self , "break here" , lldb .SBFileSpec ("main.cpp" )
176+ )
177+ self .runCmd ("settings set auto-one-line-summaries false" )
178+ self ._expect_cmd ("dwim-print w.s" , "frame variable" )
179+ self ._expect_cmd ("dwim-print wp->s" , "expression" )
180+
181+ def test_direct_child_access (self ):
182+ """Test dwim-print supports accessing members/ivars without qualification."""
183+ self .build ()
184+ lldbutil .run_to_source_breakpoint (
185+ self , "break inside" , lldb .SBFileSpec ("main.cpp" )
186+ )
187+ self ._expect_cmd ("dwim-print number" , "frame variable" )
0 commit comments