Ejemplo n.º 1
0
Archivo: test.py Proyecto: mjyc/ltlpy
def test_eventually_nested_3() -> None:
    formula = LTLEventually(
        LTLAnd(
            LTLVariable("a"),
            LTLEventually(
                LTLVariable("b"),
            ),
        ),
    )

    def get_lookup_table_a_false() -> Dict[str, Union[bool, Callable[[], bool]]]:
        return {"a": False}

    def get_lookup_table_a_true() -> Dict[str, Union[bool, Callable[[], bool]]]:
        return {"a": True}

    def get_lookup_table_b_true() -> Dict[str, Union[bool, Callable[[], bool]]]:
        return {"b": True}

    f: Union[LTLFormula, bool] = formula
    f = ltl_interpret(cast(LTLFormula, f), get_lookup_table_a_false)
    f = ltl_interpret(cast(LTLFormula, f), get_lookup_table_a_false)
    f = ltl_interpret(cast(LTLFormula, f), get_lookup_table_a_true)
    f = ltl_interpret(cast(LTLFormula, f), get_lookup_table_a_true)
    f = ltl_interpret(cast(LTLFormula, f), get_lookup_table_b_true)
    assert f
Ejemplo n.º 2
0
Archivo: test.py Proyecto: mjyc/ltlpy
def test_until_2() -> None:
    formula = LTLUntil(
        LTLVariable("a"),
        LTLVariable("b"),
    )

    def get_lookup_table() -> Dict[str, Union[bool, Callable[[], bool]]]:
        return {"a": False, "b": True}

    f: Union[LTLFormula, bool] = formula
    f = ltl_interpret(cast(LTLFormula, f), get_lookup_table)
    assert f
Ejemplo n.º 3
0
Archivo: test.py Proyecto: mjyc/ltlpy
def test_get_variable_names() -> None:
    expected = ["a", "b"]

    formula: LTLFormula = LTLEventually(
        LTLAnd(
            LTLVariable("a"),
            LTLEventually(
                LTLVariable("b"),
            ),
        ),
    )
    actual = get_variable_names(formula)

    assert actual == expected
Ejemplo n.º 4
0
Archivo: test.py Proyecto: mjyc/ltlpy
def test_var(b: bool) -> None:
    formula = LTLVariable("a")

    def get_lookup_table() -> Dict[str, Union[bool, Callable[[], bool]]]:
        lookup_table: Dict[str, Union[bool, Callable[[], bool]]] = {"a": b}
        return lookup_table

    f = ltl_interpret(formula, get_lookup_table)
    assert f is b
Ejemplo n.º 5
0
Archivo: test.py Proyecto: mjyc/ltlpy
def test_eventually(lst: List[bool]) -> None:
    expected = any(lst)

    f: Union[LTLFormula, bool] = LTLEventually(LTLVariable("a"))
    for b in lst:
        if type(f) is bool:
            break

        def get_lookup_table() -> Dict[str, Union[bool, Callable[[], bool]]]:
            lookup_table: Dict[str, Union[bool, Callable[[], bool]]] = {"a": b}
            return lookup_table

        f = ltl_interpret(cast(LTLFormula, f), get_lookup_table)

    if type(f) is LTLEventually:
        f = False

    assert f is expected
Ejemplo n.º 6
0
Archivo: test.py Proyecto: mjyc/ltlpy
def test_next(b: bool) -> None:
    f = ltl_interpret(LTLNext(LTLVariable(b)), fail_get_lookup_table)
    assert f == LTLVariable(b)
Ejemplo n.º 7
0
Archivo: test.py Proyecto: mjyc/ltlpy
def test_if(b0: bool, b1: bool) -> None:
    f = ltl_interpret(
        LTLIf(LTLVariable(b0), LTLVariable(b1)),
        fail_get_lookup_table,
    )
    assert f is (not b0 or b1)
Ejemplo n.º 8
0
Archivo: test.py Proyecto: mjyc/ltlpy
def test_and(b0: bool, b1: bool) -> None:
    f = ltl_interpret(
        LTLAnd(LTLVariable(b0), LTLVariable(b1)),
        fail_get_lookup_table,
    )
    assert f is (b0 and b1)
Ejemplo n.º 9
0
Archivo: test.py Proyecto: mjyc/ltlpy
def test_bool(b: bool) -> None:
    f = ltl_interpret(LTLVariable(b), fail_get_lookup_table)
    assert f is b
Ejemplo n.º 10
0
Archivo: test.py Proyecto: mjyc/ltlpy
def test_always_with_is_final_2() -> None:
    formula = LTLAlways(LTLAlways(LTLVariable("a")))
    f = ltl_interpret(formula, lambda: {"a": True}, is_final=True)
    assert f is True
Ejemplo n.º 11
0
Archivo: test.py Proyecto: mjyc/ltlpy
def test_eventually_nested_with_is_final() -> None:
    formula = LTLEventually(LTLEventually(LTLVariable("a")))
    f = ltl_interpret(formula, lambda: {"a": False}, is_final=True)
    assert f is False