Exemple #1
0
def check(fn, args, expected_result, remaining_raise=False):
    signature = [int] * len(args)  # for now
    graph, t = get_graph(fn, signature)
    remove_asserts(t, [graph])
    assert contains_raise(graph) == remaining_raise
    check_graph(graph, args, expected_result, t)
    return t, graph
Exemple #2
0
def check(fn, args, expected_result, remaining_raise=False):
    signature = [int] * len(args)   # for now
    graph, t = get_graph(fn, signature)
    remove_asserts(t, [graph])
    assert contains_raise(graph) == remaining_raise
    check_graph(graph, args, expected_result, t)
    return t, graph
def test_simple_melting_away():
    def fn(n):
        assert n >= 1
        return n-1
    graph, t = get_graph(fn, [int])
    assert summary(graph) == {'int_ge': 1, 'int_sub': 1}
    remove_asserts(t, [graph])
    assert summary(graph) == {'int_ge': 1, 'debug_assert': 1, 'int_sub': 1}
    check_graph(graph, [1], 0, t)
Exemple #4
0
def test_simple_melting_away():
    def fn(n):
        assert n >= 1
        return n - 1

    graph, t = get_graph(fn, [int])
    assert summary(graph) == {'int_ge': 1, 'int_sub': 1}
    remove_asserts(t, [graph])
    assert summary(graph) == {'int_ge': 1, 'debug_assert': 1, 'int_sub': 1}
    check_graph(graph, [1], 0, t)
Exemple #5
0
def test_simple_melting_away():
    def fn(n):
        assert n >= 1
        return n-1
    graph, t = get_graph(fn, [int])
    assert summary(graph) == {'int_ge': 1, 'int_sub': 1}
    remove_asserts(t, [graph])
    assert summary(graph) == {'int_ge': 1, 'debug_assert': 1, 'int_sub': 1}
    check_graph(graph, [1], 0, t)
    from pypy.translator.backendopt.removenoops import remove_debug_assert
    remove_debug_assert(graph)
    assert summary(graph) == {'int_ge': 1, 'int_sub': 1}
    from pypy.translator.simplify import transform_dead_op_vars
    transform_dead_op_vars(graph)
    assert summary(graph) == {'int_sub': 1}
Exemple #6
0
def test_simple_melting_away():
    def fn(n):
        assert n >= 1
        return n - 1

    graph, t = get_graph(fn, [int])
    assert summary(graph) == {'int_ge': 1, 'int_sub': 1}
    remove_asserts(t, [graph])
    assert summary(graph) == {'int_ge': 1, 'debug_assert': 1, 'int_sub': 1}
    check_graph(graph, [1], 0, t)
    from pypy.translator.backendopt.removenoops import remove_debug_assert
    remove_debug_assert(graph)
    assert summary(graph) == {'int_ge': 1, 'int_sub': 1}
    from pypy.translator.simplify import transform_dead_op_vars
    transform_dead_op_vars(graph)
    assert summary(graph) == {'int_sub': 1}