Ejemplo n.º 1
0
def test_complex_1():
    expecteds = (
        ('a', 'b', 'd'),
        ('a', 'b', 'e'),
        ('a', 'c', 'o', 'd'),
        ('a', 'c', 'o', 'e'),
    )
    assert tuple(gbr.compile_input('a&(b|(c&o))&(d|e)')) == expecteds
Ejemplo n.º 2
0
def test_complex_2():
    expecteds = (
        ('a', 'jp', 'bc'),
        ('a', 'jp', 'cp'),
        ('b', 'jp', 'bc'),
        ('b', 'jp', 'cp'),
    )
    assert tuple(gbr.compile_input('(a|b)&jp&(bc|cp)')) == expecteds
Ejemplo n.º 3
0
def test_special_id():
    expr = '(049&(02.50|02:50))'
    expected = (('049', '02.50'), ('049', '02:50'))
    assert tuple(gbr.compile_input(expr)) == expected
Ejemplo n.º 4
0
def test_basics():
    assert tuple(gbr.compile_input('aa&bb|cc')) == (('aa', 'bb'), ('aa', 'cc'))
Ejemplo n.º 5
0
def test_multiple_roots():
    assert tuple(gbr.compile_input('a|b')) == (('a', ), ('b', ))
Ejemplo n.º 6
0
def test_combine_or():
    assert tuple(gbr.compile_input('(a|b)',
                                   combine_or=True)) == (('a', 'b'), ('a', ),
                                                         ('b', ))
Ejemplo n.º 7
0
def test_parenthesis():
    assert tuple(gbr.compile_input('(a|b)')) == (('a', ), ('b', ))
    assert tuple(gbr.compile_input('(a&b&c)|(a&d&c)')) == (('a', 'b', 'c'),
                                                           ('a', 'd', 'c'))
Ejemplo n.º 8
0
import csv
import gbr


def problems(fname: str = 'data_gbr.tsv'):
    """Read problems from given file, yield complex name and problem definition"""
    with open(fname) as fd:
        for complex, expr in csv.reader(fd, delimiter='\t'):
            yield complex, expr


if __name__ == "__main__":
    for complex, expr in problems():
        print('—' * 80)
        print('Complex:', complex)
        for solution in gbr.compile_input('{}'.format(expr)):
            print('\t' + ' & '.join(solution))