mtl-aas/stl/test_parser.py
2017-09-27 21:43:23 -07:00

21 lines
561 B
Python

# -*- coding: utf-8 -*-
import stl
from hypothesis import given, note
from hypothesis_cfg import ContextFreeGrammarStrategy
GRAMMAR = {
'phi': (('Unary', '(', 'phi', ')'),
('(', 'phi', ')', 'Binary', '(', 'phi', ')'),
('AP',)),
'Unary': (('~',), ('G',), ('F',), ('X',)),
'Binary': ((' | ',), (' & ',), (' U ',)),
}
@given(ContextFreeGrammarStrategy(GRAMMAR, length=15, start='phi'))
def test_invertable_repr(foo):
note(''.join(foo))
phi = stl.parse(''.join(foo))
assert str(phi) == str(stl.parse(str(phi)))