acd: fix typeness checks, and add options for those
* spot/twaalgos/zlktree.cc, spot/twaalgos/zlktree.hh: Here. * tests/python/zlktree.ipynb, tests/python/zlktree.py: Add tests and examples.
This commit is contained in:
parent
406bc8ed17
commit
043a1dc394
4 changed files with 365 additions and 87 deletions
|
|
@ -27,3 +27,93 @@ trans-acc --BODY-- State: 0 [!0&!1] 3 [!0&!1] 4 State: 1 [!0&!1] 4 {3}
|
|||
b = spot.zielonka_tree_transform(a)
|
||||
assert spot.are_equivalent(a, b)
|
||||
assert b.acc().is_buchi()
|
||||
|
||||
def report_missing_exception():
|
||||
raise RuntimeError("missing exception")
|
||||
|
||||
a = spot.automaton("""
|
||||
HOA: v1 States: 10 Start: 0 AP: 2 "p0" "p1" acc-name: Rabin 3
|
||||
Acceptance: 6 (Fin(0) & Inf(1)) | (Fin(2) & Inf(3)) | (Fin(4) &
|
||||
Inf(5)) properties: trans-labels explicit-labels trans-acc --BODY--
|
||||
State: 0 [0&!1] 0 {1 2 3} [!0&!1] 8 [0&1] 4 State: 1 [0&1] 1 {2}
|
||||
State: 2 [0&1] 8 {3} [0&1] 2 {1} [!0&1] 4 {3 4} [!0&!1] 3 {2 5} State:
|
||||
3 [!0&!1] 5 [0&1] 8 {1 2} [!0&!1] 9 {1} State: 4 [0&!1] 3 {0 2} [!0&1]
|
||||
5 {1} State: 5 [!0&!1] 6 [!0&!1] 7 {2} [0&!1] 3 {1} [!0&1] 5 State: 6
|
||||
[!0&!1] 1 [!0&!1] 2 {4} [0&!1] 0 {1 3 4} [0&1] 5 [!0&!1] 3 State: 7
|
||||
[0&1] 4 {0} [0&1] 5 [0&1] 0 {3} [0&1] 1 {2 4} State: 8 [0&!1] 6 {0 4
|
||||
5} [!0&!1] 7 {4} [0&!1] 2 {1 3} [0&1] 0 {0 1 4} State: 9 [!0&1] 6 {4}
|
||||
[!0&!1] 2 {5} [!0&!1] 0 {3} [!0&!1] 5 --END--""")
|
||||
aa = spot.acd(a)
|
||||
try:
|
||||
assert aa.has_rabin_shape()
|
||||
except RuntimeError as e:
|
||||
assert 'CHECK_RABIN' in str(e)
|
||||
else:
|
||||
report_missing_exception()
|
||||
|
||||
try:
|
||||
assert not aa.has_streett_shape()
|
||||
except RuntimeError as e:
|
||||
assert 'CHECK_STREETT' in str(e)
|
||||
else:
|
||||
report_missing_exception()
|
||||
|
||||
try:
|
||||
assert not aa.has_parity_shape()
|
||||
except RuntimeError as e:
|
||||
assert 'CHECK_PARITY' in str(e)
|
||||
else:
|
||||
report_missing_exception()
|
||||
|
||||
|
||||
aa = spot.acd(a, spot.acd_options_CHECK_RABIN)
|
||||
assert aa.has_rabin_shape()
|
||||
assert aa.node_count() == 13
|
||||
|
||||
try:
|
||||
assert not aa.has_streett_shape()
|
||||
except RuntimeError as e:
|
||||
assert 'CHECK_STREETT' in str(e)
|
||||
else:
|
||||
report_missing_exception()
|
||||
|
||||
try:
|
||||
assert aa.has_parity_shape()
|
||||
except RuntimeError as e:
|
||||
assert 'CHECK_PARITY' in str(e)
|
||||
else:
|
||||
report_missing_exception()
|
||||
|
||||
aa = spot.acd(a, (spot.acd_options_CHECK_PARITY |
|
||||
spot.acd_options_ABORT_WRONG_SHAPE))
|
||||
assert aa.has_rabin_shape()
|
||||
assert not aa.has_streett_shape()
|
||||
assert not aa.has_parity_shape()
|
||||
assert aa.node_count() == 0
|
||||
try:
|
||||
aa.first_branch(0)
|
||||
except RuntimeError as e:
|
||||
assert 'ABORT_WRONG_SHAPE' in str(e)
|
||||
else:
|
||||
report_missing_exception()
|
||||
|
||||
try:
|
||||
aa.step(0, 0)
|
||||
except RuntimeError as e:
|
||||
assert 'incorrect branch number' in str(e)
|
||||
else:
|
||||
report_missing_exception()
|
||||
|
||||
try:
|
||||
aa.node_acceptance(0)
|
||||
except RuntimeError as e:
|
||||
assert 'unknown node' in str(e)
|
||||
else:
|
||||
report_missing_exception()
|
||||
|
||||
try:
|
||||
aa.edges_of_node(0)
|
||||
except RuntimeError as e:
|
||||
assert 'unknown node' in str(e)
|
||||
else:
|
||||
report_missing_exception()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue