Ejemplo n.º 1
0
    def format_int(self, v: int, spec: str) -> str:
        if not spec:
            spec = DEFAULT_SPEC

        if "l" in spec:
            spec = spec.replace("l", "")
            loc = True
        else:
            loc = False

        if loc:
            try:
                label = self.debugger.instruction_number_to_location(
                    v, append_label=False
                )
            except IndexError:
                return format_int(v, spec=spec)
            else:
                return format_int(v, spec=spec) + " [" + label + "]"
        else:
            return format_int(v, spec=spec)
Ejemplo n.º 2
0
def test_format_int_with_non_default_format():
    assert format_int(2, spec="bds") == "0b0000000000000010 = 2"
Ejemplo n.º 3
0
def test_format_int_with_negative():
    assert format_int(65535) == "0xffff = 65535 = -1"
Ejemplo n.º 4
0
def test_format_int_with_large_positive():
    assert format_int(4000) == "0x0fa0 = 4000"
Ejemplo n.º 5
0
def test_format_int_with_ASCII_value():
    assert format_int(65) == "0x0041 = 65 = 'A'"
Ejemplo n.º 6
0
def test_format_int_with_small_positive():
    assert format_int(5) == "0x0005 = 5"