Пример #1
0
def test_ComparisonProcess_07():
    src = """
        dflt is ...
    """
    nodes = parseSource(src)
    cvtr = ComparisonConverter()
    matches = cvtr.gather(nodes)
    cvtr.processAll(matches)
    assert nodesToString(nodes) == """!_pyjs.isDef( dflt )"""
Пример #2
0
def test_ComparisonProcess_06():
    src = """
        x is not y
    """
    nodes = parseSource(src)
    cvtr = ComparisonConverter()
    matches = cvtr.gather(nodes)
    cvtr.processAll(matches)
    assert nodesToString(nodes) == """!Object.is( x, y )"""
Пример #3
0
def test_ComparisonProcess_04():
    src = """
        x is not None
    """
    nodes = parseSource(src)
    cvtr = ComparisonConverter()
    matches = cvtr.gather(nodes)
    cvtr.processAll(matches)
    assert nodesToString(nodes) == """x !== null"""
Пример #4
0
def test_ComparisonProcess_01():
    src = """
        x == y
    """
    nodes = parseSource(src)
    cvtr = ComparisonConverter()
    matches = cvtr.gather(nodes)
    cvtr.processAll(matches)
    assert nodesToString(nodes) == """x === y"""
Пример #5
0
def test_ComparisonGather_01():
    src = """
        x == y; x < y; x > y; x >= y; x <= y; x <> y; x != y; x in y; x is y
    """
    # dumpTree( parseSource( src ) )
    matches = ComparisonConverter().gather(parseSource(src))
    match = matches[0]
    assert nodesToString(match.left) == 'x'
    assert nodesToString(match.comp_op) == '=='
    assert nodesToString(match.right) == 'y'
    assert nodesToString(matches[3].comp_op) == '>='
    assert nodesToString(matches[7].comp_op) == 'in'
Пример #6
0
def test_ComparisonGather_02():
    src = """
        x is not y; x not in y
    """
    # dumpTree( parseSource( src ) )

    matches = ComparisonConverter().gather(parseSource(src))
    match = matches[0]
    assert nodesToString(match.left) == 'x'
    assert nodesToString(match.comp_op) == 'is not'
    assert nodesToString(match.right) == 'y'
    assert nodesToString(matches[1].comp_op) == 'not in'