

def test_equality_rewrite_non_static(self):
    'Test an equality rewrite with non-static values'
    l = ast.Literal('foo')
    v = ast.Literal('bar')
    cmp1 = ast.CompareOperator('=', l, v)
    cmp2 = ast.CompareOperator('!=', l, v)
    or1 = ast.LogicalOperator('or', cmp1, cmp2)
    name = merge.node_name(cmp1, True)
    r = compare.equality_rewrite(ast.dup(or1), name, cmp1, True)
    assert isinstance(r.left, ast.Constant)
    assert (r.left.value == True)
    assert isinstance(r.right, ast.Constant)
    assert (r.right.value == False)
    name = merge.node_name(cmp1, True)
    r = compare.equality_rewrite(ast.dup(or1), name, cmp1, False)
    assert isinstance(r.left, ast.Constant)
    assert (r.left.value == False)
    assert isinstance(or1.right, ast.Constant)
    assert (r.right.value == True)
    name = merge.node_name(cmp2, True)
    r = compare.equality_rewrite(ast.dup(or1), name, cmp2, True)
    assert isinstance(r.left, ast.Constant)
    assert (r.left.value == False)
    assert isinstance(r.right, ast.Constant)
    assert (r.right.value == True)
    name = merge.node_name(cmp2, True)
    r = compare.equality_rewrite(ast.dup(or1), name, cmp2, False)
    assert isinstance(r.left, ast.Constant)
    assert (r.left.value == True)
    assert isinstance(r.right, ast.Constant)
    assert (r.right.value == False)

dataset/ETHPy150Open armon/pypred/tests/unit/test_compare.py TestCompare.test_equality_rewrite_non_static/VarMisuse@203/256 `r`->`or1`