|
| 1 | +import lldb |
| 2 | +from lldbsuite.test.lldbtest import * |
| 3 | +from lldbsuite.test.decorators import * |
| 4 | +import lldbsuite.test.lldbutil as lldbutil |
| 5 | + |
| 6 | + |
| 7 | +@skipIf(oslist=["windows", "linux"]) |
| 8 | +class TestSwiftSteppingThroughWitness(TestBase): |
| 9 | + @swiftTest |
| 10 | + def test_step_in_and_out(self): |
| 11 | + """Test that stepping in and out of protocol methods work""" |
| 12 | + self.build() |
| 13 | + _, _, thread, _ = lldbutil.run_to_source_breakpoint( |
| 14 | + self, "break here", lldb.SBFileSpec("main.swift") |
| 15 | + ) |
| 16 | + |
| 17 | + thread.StepInto() |
| 18 | + stop_reason = thread.GetStopReason() |
| 19 | + self.assertStopReason(stop_reason, lldb.eStopReasonPlanComplete) |
| 20 | + |
| 21 | + frame0 = thread.frames[0] |
| 22 | + frame1 = thread.frames[1] |
| 23 | + self.assertIn("SlowRandomNumberGenerator.random", frame0.GetFunctionName()) |
| 24 | + self.assertIn( |
| 25 | + "protocol witness for a.RandomNumberGenerator.random", |
| 26 | + frame1.GetFunctionName(), |
| 27 | + ) |
| 28 | + |
| 29 | + thread.StepOut() |
| 30 | + stop_reason = thread.GetStopReason() |
| 31 | + self.assertStopReason(stop_reason, lldb.eStopReasonPlanComplete) |
| 32 | + frame0 = thread.frames[0] |
| 33 | + self.assertIn("doMath", frame0.GetFunctionName()) |
| 34 | + |
| 35 | + @swiftTest |
| 36 | + def test_step_over(self): |
| 37 | + """Test that stepping over protocol methods work""" |
| 38 | + self.build() |
| 39 | + _, _, thread, _ = lldbutil.run_to_source_breakpoint( |
| 40 | + self, "break here", lldb.SBFileSpec("main.swift") |
| 41 | + ) |
| 42 | + |
| 43 | + thread.StepOver() |
| 44 | + stop_reason = thread.GetStopReason() |
| 45 | + self.assertStopReason(stop_reason, lldb.eStopReasonPlanComplete) |
| 46 | + frame0 = thread.frames[0] |
| 47 | + self.assertIn("doMath", frame0.GetFunctionName()) |
| 48 | + |
| 49 | + line_entry = frame0.GetLineEntry() |
| 50 | + self.assertEqual(14, line_entry.GetLine()) |
0 commit comments