added test coverage for f_neg_canonical_form
This commit is contained in:
parent
7aed260d5d
commit
fd555661a0
3 changed files with 16 additions and 8 deletions
12
stl/ast.py
12
stl/ast.py
|
|
@ -89,6 +89,10 @@ class AST(object):
|
||||||
# TODO: this is hack to flatten the AST. Fix!
|
# TODO: this is hack to flatten the AST. Fix!
|
||||||
return phi
|
return phi
|
||||||
|
|
||||||
|
def __hash__(self):
|
||||||
|
# TODO: compute hash based on contents
|
||||||
|
return hash(repr(self))
|
||||||
|
|
||||||
|
|
||||||
class _Top(AST):
|
class _Top(AST):
|
||||||
__slots__ = ()
|
__slots__ = ()
|
||||||
|
|
@ -96,10 +100,6 @@ class _Top(AST):
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "⊤"
|
return "⊤"
|
||||||
|
|
||||||
def __hash__(self):
|
|
||||||
# TODO: compute hash based on contents
|
|
||||||
return hash(repr(self))
|
|
||||||
|
|
||||||
def __invert__(self):
|
def __invert__(self):
|
||||||
return BOT
|
return BOT
|
||||||
|
|
||||||
|
|
@ -110,10 +110,6 @@ class _Bot(AST):
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "⊥"
|
return "⊥"
|
||||||
|
|
||||||
def __hash__(self):
|
|
||||||
# TODO: compute hash based on contents
|
|
||||||
return hash(repr(self))
|
|
||||||
|
|
||||||
def __invert__(self):
|
def __invert__(self):
|
||||||
return TOP
|
return TOP
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import stl
|
import stl
|
||||||
|
from stl.hypothesis import SignalTemporalLogicStrategy
|
||||||
|
|
||||||
import hypothesis.strategies as st
|
import hypothesis.strategies as st
|
||||||
from hypothesis import given
|
from hypothesis import given
|
||||||
|
|
@ -12,3 +13,8 @@ def test_params1(a, b, c):
|
||||||
phi2 = phi.set_params({'a?': a, 'b?': b, 'c?': c})
|
phi2 = phi.set_params({'a?': a, 'b?': b, 'c?': c})
|
||||||
assert phi2.params == set()
|
assert phi2.params == set()
|
||||||
assert phi2 == stl.parse(f'G[{a}, {b}](x > {c})')
|
assert phi2 == stl.parse(f'G[{a}, {b}](x > {c})')
|
||||||
|
|
||||||
|
|
||||||
|
@given(SignalTemporalLogicStrategy)
|
||||||
|
def test_hash_stable(phi):
|
||||||
|
assert hash(phi) == hash(stl.parse(str(phi)))
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import stl
|
||||||
from stl.hypothesis import SignalTemporalLogicStrategy
|
from stl.hypothesis import SignalTemporalLogicStrategy
|
||||||
|
|
||||||
from hypothesis import given
|
from hypothesis import given
|
||||||
|
from pytest import raises
|
||||||
|
|
||||||
|
|
||||||
CONTEXT = {
|
CONTEXT = {
|
||||||
|
|
@ -23,6 +24,11 @@ def test_f_neg_or_canonical_form(phi):
|
||||||
isinstance(x, (stl.ast.G, stl.ast.And)) for x in phi2.walk())
|
isinstance(x, (stl.ast.G, stl.ast.And)) for x in phi2.walk())
|
||||||
|
|
||||||
|
|
||||||
|
def test_f_neg_or_canonical_form_not_implemented():
|
||||||
|
with raises(NotImplementedError):
|
||||||
|
stl.utils.f_neg_or_canonical_form(stl.ast.AST())
|
||||||
|
|
||||||
|
|
||||||
def test_inline_context_rigid():
|
def test_inline_context_rigid():
|
||||||
phi = stl.parse('G(AP1)')
|
phi = stl.parse('G(AP1)')
|
||||||
phi2 = phi.inline_context(CONTEXT)
|
phi2 = phi.inline_context(CONTEXT)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue