|
9 | 9 | # See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
10 | 10 | #
|
11 | 11 | # ------------------------------------------------------------------------------
|
12 |
| -import lldbsuite.test.lldbinline as lldbinline |
| 12 | +import lldb |
| 13 | +import lldbsuite.test |
| 14 | +import lldbsuite.test.lldbutil as lldbutil |
| 15 | +from lldbsuite.test.lldbtest import * |
13 | 16 | from lldbsuite.test.decorators import *
|
14 | 17 |
|
15 |
| -lldbinline.MakeInlineTest(__file__, globals(), decorators=[swiftTest]) |
| 18 | +class TestSwiftPOValueTypes(TestBase): |
| 19 | + |
| 20 | + @swiftTest |
| 21 | + def test_value_types(self): |
| 22 | + """Test 'po' on a variety of value types with and without custom descriptions.""" |
| 23 | + self.build() |
| 24 | + (_,_,_,_) = lldbutil.run_to_source_breakpoint(self, "Break here to run tests", lldb.SBFileSpec("main.swift")) |
| 25 | + |
| 26 | + self.expect("po dm", substrs=['a', '12', 'b', '24']) |
| 27 | + self.expect("po cm", substrs=['c', '36']) |
| 28 | + self.expect("po cm", substrs=['12', '24'], matching=False) |
| 29 | + self.expect("po cs", substrs=['CustomDebugStringConvertible']) |
| 30 | + self.expect("po cs", substrs=['CustomStringConvertible'], matching=False) |
| 31 | + self.expect("po cs", substrs=['a', '12', 'b', '24']) |
| 32 | + self.expect("script lldb.frame.FindVariable('cs').GetObjectDescription()", substrs=['a', '12', 'b', '24']) |
| 33 | + self.expect("po (12,24,36,48)", substrs=['12', '24', '36', '48']) |
| 34 | + self.expect("po (dm as Any, cm as Any,48 as Any)", substrs=['12', '24', '36', '48']) |
| 35 | + self.expect("po patatino", substrs=['foo']) |
| 36 | + |
| 37 | + @swiftTest |
| 38 | + def test_ignore_bkpts_in_po(self): |
| 39 | + """Run a po expression with a breakpoint in the debugDescription, make sure we don't hit it.""" |
| 40 | + |
| 41 | + self.build() |
| 42 | + main_spec = lldb.SBFileSpec("main.swift") |
| 43 | + (target, process, thread, _) = lldbutil.run_to_source_breakpoint(self, "Break here to run tests", main_spec) |
| 44 | + po_bkpt = target.BreakpointCreateBySourceRegex("Breakpoint in debugDescription", main_spec) |
| 45 | + |
| 46 | + # As part of the po expression we should auto-continue past the breakpoint so this succeeds: |
| 47 | + self.expect("po cs", substrs=['CustomDebugStringConvertible']) |
| 48 | + self.assertEqual(po_bkpt.GetHitCount(), 1, "Did hit the breakpoint") |
| 49 | + |
| 50 | + |
| 51 | + |
0 commit comments