python: fix return of is_rabin_like() and is_streett_like()

* python/spot/impl.i: Fix instantiation of vector_rs_pairs.
* tests/python/setacc.py: Add test cases.
* NEWS: Mention the bugs.
This commit is contained in:
Alexandre Duret-Lutz 2018-10-31 19:43:26 +01:00
parent 266581b272
commit 5bb9c87d4c
3 changed files with 25 additions and 2 deletions

4
NEWS
View file

@ -78,7 +78,9 @@ New in spot 2.6.3.dev (not yet released)
Bugs fixed: Bugs fixed:
- The pair of acc_cond::mark_t returned by - The pair of acc_cond::mark_t returned by
acc_code::used_inf_fin_sets() was not usable in Python. acc_code::used_inf_fin_sets(), and the pair (bool,
vector_rs_pairs) by acc_cond::is_rabin_like() and
acc_cond::is_streett_like() were not usable in Python.
New in spot 2.6.3 (2018-10-17) New in spot 2.6.3 (2018-10-17)

View file

@ -475,7 +475,9 @@ namespace std {
%feature("flatnested") spot::acc_cond::acc_code; %feature("flatnested") spot::acc_cond::acc_code;
%feature("flatnested") spot::acc_cond::rs_pair; %feature("flatnested") spot::acc_cond::rs_pair;
%apply bool* OUTPUT {bool& max, bool& odd}; %apply bool* OUTPUT {bool& max, bool& odd};
%template(vector_rs_pair) std::vector<spot::acc_cond::rs_pair>; namespace std {
%template(vector_rs_pair) vector<spot::acc_cond::rs_pair>;
}
%apply std::vector<spot::acc_cond::rs_pair> &OUTPUT {std::vector<spot::acc_cond::rs_pair>& pairs} %apply std::vector<spot::acc_cond::rs_pair> &OUTPUT {std::vector<spot::acc_cond::rs_pair>& pairs}
%include <spot/twa/acc.hh> %include <spot/twa/acc.hh>
%template(pair_bool_mark) std::pair<bool, spot::acc_cond::mark_t>; %template(pair_bool_mark) std::pair<bool, spot::acc_cond::mark_t>;

View file

@ -36,3 +36,22 @@ assert fin == [0]
(inf, fin) = spot.acc_code("(Fin(0)|Inf(1))&Fin(2)&Inf(0)").used_inf_fin_sets() (inf, fin) = spot.acc_code("(Fin(0)|Inf(1))&Fin(2)&Inf(0)").used_inf_fin_sets()
assert inf == [0,1] assert inf == [0,1]
assert fin == [0,2] assert fin == [0,2]
# is_rabin_like() returns (bool, [(inf, fin), ...])
(b, v) = spot.acc_cond("(Fin(0)&Inf(1))|(Fin(2)&Inf(0))").is_rabin_like()
assert b == True
assert len(v) == 2
assert v[0].fin == [0]
assert v[0].inf == [1]
assert v[1].fin == [2]
assert v[1].inf == [0]
(b, v) = spot.acc_cond("(Fin(0)|Inf(1))&(Fin(2)|Inf(0))").is_rabin_like()
assert b == False
assert len(v) == 0
(b, v) = spot.acc_cond("(Fin(0)|Inf(1))&(Fin(2)|Inf(0))").is_streett_like()
assert b == True
assert len(v) == 2
assert v[0].fin == [0]
assert v[0].inf == [1]
assert v[1].fin == [2]
assert v[1].inf == [0]