import pytest @pytest.mark.parametrize(['text', 'oracles'], [ ('hello world', ['VAR[hello]', 'VAR[world]']), ('HELLO WORLD', ['CONST[HELLO]', 'CONST[WORLD]']), ('\\exists \\forall', ['EXISTS', 'FORALL']), ('\\existsX', [None]), ('\\exists X', ['EXISTS', 'CONST[X]']), (' A->B ', ['CONST[A]', 'IMP', 'CONST[B]']), (' x&y ', ['VAR[x]', 'AND', 'VAR[y]']), (' a|b ', ['VAR[a]', 'OR', 'VAR[b]']), (' ~s ', ['NOT', 'VAR[s]']), (' (k) ', ['OPAR', 'VAR[k]', 'CPAR']), (' a,b ', ['VAR[a]', 'COMMA', 'VAR[b]']), (' Pr(x) ', ['PRED[Pr]', 'OPAR', 'VAR[x]', 'CPAR']), ]) def test_token(lexer, text, oracles): lexer.scan(text) for oracle in oracles: tok = lexer.next() if tok is None: assert oracle is None else: assert str(tok) == oracle