示例#1
0
def test_recursive_rowfunc():
    f = rrowfunc(t['name'], t)
    assert [f(row) for row in data] == [row[0] for row in data]

    expr = optimize(t['amount'] + t['id'], [])
    f = rrowfunc(expr, t)
    assert [f(row) for row in data] == [row[1] + row[2] for row in data]

    assert raises(Exception, lambda: rrowfunc(t[t['amount'] < 0]['name'], t))
示例#2
0
def test_recursive_rowfunc():
    f = rrowfunc(t['name'], t)
    assert [f(row) for row in data] == [row[0] for row in data]

    expr = optimize(t['amount'] + t['id'], [])
    f = rrowfunc(expr, t)
    assert [f(row) for row in data] == [row[1] + row[2] for row in data]

    assert raises(Exception, lambda: rrowfunc(t[t['amount'] < 0]['name'], t))
示例#3
0
def test_neg():
    expr = optimize(-t.amount, [])
    assert list(compute(expr, data)) == [-x[1] for x in data]
示例#4
0
def test_dispatched_rowfunc():
    cw = optimize(t['amount'] + 100, [])
    assert rowfunc(t)(t) == t
    assert rowfunc(cw)(('Alice', 100, 1)) == 200
示例#5
0
def test_neg():
    expr = optimize(-t.amount, [])
    assert list(compute(expr, data)) == [-x[1] for x in data]
示例#6
0
def test_dispatched_rowfunc():
    cw = optimize(t['amount'] + 100, [])
    assert rowfunc(t)(t) == t
    assert rowfunc(cw)(('Alice', 100, 1)) == 200