Ejemplo n.º 1
0
def fig2b() -> None:
    h = input_high()
    l = input_low()
    x = f(h)
    y = f(l)
    #:: ExpectedOutput(call.precondition:assertion.false)
    sif_print(x)
Ejemplo n.º 2
0
def while2() -> None:
    """While with high guard."""
    Requires(LowEvent())
    x = input_low()
    while x != 0:
        x = x - 1
    sif_print(1)
Ejemplo n.º 3
0
def fig2b_low() -> None:
    Requires(LowEvent())
    h = input_high()
    l = input_low()
    x = f(h)
    y = f(l)
    sif_print(y)
Ejemplo n.º 4
0
def fig1a_low() -> None:
    Requires(LowEvent())
    x = input_low()
    if x < 1234:
        sif_print(0)
    y = x
    sif_print(y)
Ejemplo n.º 5
0
def test_high_data() -> None:
    Requires(LowEvent())
    x = input_high()
    y = input_low()
    l = [1, y]
    l.append(x)
    sif_print(l[1])
    #:: ExpectedOutput(call.precondition:assertion.false)
    sif_print(l[2])
Ejemplo n.º 6
0
def test_contains() -> None:
    Requires(LowEvent())
    x = input_high()
    y = input_low()
    l = [1, 2, 3]
    if y in l:
        sif_print(0)
    if x in l:
        #:: ExpectedOutput(call.precondition:assertion.false)
        sif_print(1)
Ejemplo n.º 7
0
def while5() -> None:
    """Nested while."""
    h = input_high()
    l = input_low()
    i = 0
    while l != 0:
        while h != 0:
            i = i + 1
            h = h - 1
        l = l - 1
    #:: ExpectedOutput(call.precondition:assertion.false)
    sif_print(i)
Ejemplo n.º 8
0
def while1() -> int:
    """While with low guard."""
    Requires(LowEvent())
    i = input_low()
    sum = 0
    while i != 0:
        Invariant(Low(i))
        Invariant(Low(sum))
        sum = sum + 1
        i = i - 1
    sif_print(sum)
    return sum