|
| 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 | +class TestCase(TestBase): |
| 8 | + @swiftTest |
| 9 | + def test_scalar_types(self): |
| 10 | + self.build() |
| 11 | + _, _, thread, _ = lldbutil.run_to_source_breakpoint( |
| 12 | + self, "break here", lldb.SBFileSpec("main.swift") |
| 13 | + ) |
| 14 | + frame = thread.selected_frame |
| 15 | + |
| 16 | + child = frame.var("name") |
| 17 | + for t in ("String", "$sSSD"): |
| 18 | + self.expect( |
| 19 | + f"memory read -t {t} {child.load_addr}", |
| 20 | + substrs=[f'(String) 0x{child.load_addr:x} = "dirk"'], |
| 21 | + ) |
| 22 | + |
| 23 | + child = frame.var("number") |
| 24 | + for t in ("Int", "$sSiD"): |
| 25 | + self.expect( |
| 26 | + f"memory read -t {t} {child.load_addr}", |
| 27 | + substrs=[f"(Int) 0x{child.load_addr:x} = 41"], |
| 28 | + ) |
| 29 | + |
| 30 | + child = frame.var("fact") |
| 31 | + for t in ("Bool", "$sSbD"): |
| 32 | + self.expect( |
| 33 | + f"memory read -t {t} {child.load_addr}", |
| 34 | + substrs=[f"(Bool) 0x{child.load_addr:x} = true"], |
| 35 | + ) |
| 36 | + |
| 37 | + @swiftTest |
| 38 | + @expectedFailureAll |
| 39 | + def test_generic_types(self): |
| 40 | + self.build() |
| 41 | + _, _, thread, _ = lldbutil.run_to_source_breakpoint( |
| 42 | + self, "break here", lldb.SBFileSpec("main.swift") |
| 43 | + ) |
| 44 | + frame = thread.selected_frame |
| 45 | + |
| 46 | + child = frame.var("maybe") |
| 47 | + for t in ("UInt64?", "$ss6UInt64VSgD"): |
| 48 | + self.expect( |
| 49 | + f"memory read -t {t} {child.load_addr}", |
| 50 | + substrs=[f"(UInt64?) 0x{child.load_addr:x} = nil"], |
| 51 | + ) |
| 52 | + |
| 53 | + child = frame.var("bytes") |
| 54 | + for t in ("[UInt8]", "$sSays5UInt8VGD"): |
| 55 | + self.expect( |
| 56 | + f"memory read -t {t} {child.load_addr}", |
| 57 | + substrs=[f"([UInt8]) 0x{child.load_addr:x} = [1, 2, 4, 8]"], |
| 58 | + ) |
0 commit comments