update parser test for new api
This commit is contained in:
parent
72f7dd2386
commit
fb617482bf
1 changed files with 34 additions and 0 deletions
34
test_parser.py
Normal file
34
test_parser.py
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import stl
|
||||||
|
from blustl.game import from_yaml
|
||||||
|
from nose2.tools import params
|
||||||
|
import unittest
|
||||||
|
from sympy import Symbol
|
||||||
|
|
||||||
|
from glob import glob
|
||||||
|
|
||||||
|
def main():
|
||||||
|
with open('examples/example1.stl', 'r') as f:
|
||||||
|
print(from_yaml(f))
|
||||||
|
|
||||||
|
ex1 = ('x1 > 2', stl.LinEq(
|
||||||
|
(stl.Var(1, Symbol("x1"), stl.ast.t_sym),),
|
||||||
|
">",
|
||||||
|
2.0
|
||||||
|
))
|
||||||
|
i1 = stl.Interval(0., 1.)
|
||||||
|
i2 = stl.Interval(2., 3.)
|
||||||
|
ex2 = ('◇[0,1](x1 > 2)', stl.F(i1, ex1[1]))
|
||||||
|
ex3 = ('□[2,3]◇[0,1](x1 > 2)', stl.G(i2, ex2[1]))
|
||||||
|
ex4 = ('(x1 > 2) or ((x1 > 2) or (x1 > 2))',
|
||||||
|
stl.Or((ex1[1], ex1[1], ex1[1])))
|
||||||
|
|
||||||
|
example_ymls = glob('examples/*')
|
||||||
|
|
||||||
|
class TestSTLParser(unittest.TestCase):
|
||||||
|
@params(ex1, ex2, ex3, ex4)
|
||||||
|
def test_stl(self, phi_str, phi):
|
||||||
|
self.assertEqual(stl.parse(phi_str), phi)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue