diff --git a/wrap/python/spot_impl.i b/wrap/python/spot_impl.i index 6fc2926ac84694c676081e2675be47459bf3bafd..3ca14772089cd59734333f0b68b03d5bdac0aee2 100644 --- a/wrap/python/spot_impl.i +++ b/wrap/python/spot_impl.i @@ -178,6 +178,13 @@ using namespace spot; }; %apply char** OUTPUT { char** err }; +%typemap(out) spot::formula { + if (!$1) + $result = SWIG_Py_Void(); + else + $result = SWIG_NewPointerObj(new spot::formula($1), $descriptor(spot::formula*), SWIG_POINTER_OWN); +} + %exception { try { $action diff --git a/wrap/python/tests/Makefile.am b/wrap/python/tests/Makefile.am index 667f768b4e579e93195abd22d7211e26433adb25..3f5c6442a556253e2808f7c48dca9a6c194c7cd4 100644 --- a/wrap/python/tests/Makefile.am +++ b/wrap/python/tests/Makefile.am @@ -48,6 +48,7 @@ TESTS = \ parsetgba.py \ piperead.ipynb \ randaut.ipynb \ + randgen.py \ randltl.ipynb \ relabel.py \ setxor.py \ diff --git a/wrap/python/tests/randgen.py b/wrap/python/tests/randgen.py new file mode 100755 index 0000000000000000000000000000000000000000..f5cfe7b93b0873d61a88a9640a8186c5e7c91ae1 --- /dev/null +++ b/wrap/python/tests/randgen.py @@ -0,0 +1,29 @@ +# -*- mode: python; coding: utf-8 -*- +# Copyright (C) 2015 Laboratoire de Recherche et Développement de +# l'Epita (LRDE). +# +# This file is part of Spot, a model checking library. +# +# Spot is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Spot is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +# License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This is a python translation of the ltl2tgba C++ test program. +# Compare with src/tgbatest/ltl2tgba.cc. + +import spot + +o = spot.option_map() +g = spot.randltlgenerator(0, o) +assert str(g.next()) == '1' +assert str(g.next()) == '0' +assert str(g.next()) == 'None'