Esempio n. 1
0
def test_first_maybe():
    eq_(first(maybe(a('x'))), ['x', _EPSYLON])
    eq_(first(maybe(a('x')) + a('y')), ['x', 'y'])
    eq_(first(maybe(a('x')) + maybe(a('y'))), ['x', 'y', _EPSYLON])

    eq_(first(maybe(a('x')) | a('y')), ['x', _EPSYLON, 'y'])
    eq_(first(a('x') | maybe(a('y'))), ['x', 'y', _EPSYLON])
    eq_(first(maybe(a('x')) | maybe(a('y'))), ['x', _EPSYLON, 'y', _EPSYLON])
Esempio n. 2
0
def test_first_maybe():
    eq_(first(maybe(a('x'))), ['x', _EPSYLON])
    eq_(first(maybe(a('x')) + a('y')), ['x', 'y'])
    eq_(first(maybe(a('x')) + maybe(a('y'))), ['x', 'y', _EPSYLON])

    eq_(first(maybe(a('x')) | a('y')), ['x', _EPSYLON, 'y'])
    eq_(first(a('x') | maybe(a('y'))), ['x', 'y', _EPSYLON])
    eq_(first(maybe(a('x')) | maybe(a('y'))), ['x', _EPSYLON, 'y', _EPSYLON])
Esempio n. 3
0
def test_first_non_pure():
    eq_(first(a('x')), ['x'])
    eq_(first(a('x') + a('y')), ['x'])
    eq_(first(a('x') | a('y')), ['x', 'y'])
Esempio n. 4
0
def test_first_many():
    eq_(first(many(a('x'))), ['x', _EPSYLON])
    eq_(first(many(a('x')) + a('y')), ['x', 'y'])
    eq_(first(a('x') + many(a('y'))), ['x'])
Esempio n. 5
0
def test_first_non_pure():
    eq_(first(a('x')), ['x'])
    eq_(first(a('x') + a('y')), ['x'])
    eq_(first(a('x') | a('y')), ['x', 'y'])
Esempio n. 6
0
def test_first_many():
    eq_(first(many(a('x'))), ['x', _EPSYLON])
    eq_(first(many(a('x')) + a('y')), ['x', 'y'])
    eq_(first(a('x') + many(a('y'))), ['x'])