Ejemplo n.º 1
0
def test_curry_ignore_kwargs():
    currier = curry(ignore_kwargs=True)
    num, val, kw = run_in_loop(currier(task)(2)(4))
    assert num == 6
    assert val is None
    assert kw == {}

    currier = curry(ignore_kwargs=True)
    num, val, kw = run_in_loop(currier(task)(2)(4, baz='foo', tee=True))
    assert num == 6
    assert val is 'foo'
    assert kw == {'tee': True}
Ejemplo n.º 2
0
def test_curry_extra_arguments():
    currier = curry(4)
    num, val, kw = run_in_loop(currier(task)(2)(4)(baz='foo')(tee=True))
    assert num == 6
    assert val == 'foo'
    assert kw == {'tee': True}

    currier = curry(4)
    num, val, kw = run_in_loop(currier(task)(2)(4)(baz='foo')(tee=True))
    assert num == 6
    assert val == 'foo'
    assert kw == {'tee': True}
Ejemplo n.º 3
0
def test_curry_evaluator_function():
    def evaluator(acc, fn):
        return len(acc[0]) < 3

    def task(x, y):
        return x * y

    currier = curry(evaluator=evaluator)
    assert run_in_loop(currier(task)(4, 4)) == 16
Ejemplo n.º 4
0
def test_curry_function_arity():
    num, val, kw = run_in_loop(curry(task)(2)(4)(baz='foo'))
    assert num == 6
    assert val == 'foo'
    assert kw == {}

    num, val, kw = run_in_loop(curry(task)(2, 4)(baz='foo'))
    assert num == 6
    assert val == 'foo'
    assert kw == {}

    num, val, kw = run_in_loop(curry(task)(2, 4, baz='foo'))
    assert num == 6
    assert val == 'foo'
    assert kw == {}

    num, val, kw = run_in_loop(curry(task)(2, 4, baz='foo', fee=True))
    assert num == 6
    assert val == 'foo'
    assert kw == {'fee': True}
Ejemplo n.º 5
0
def test_curry_custom_arity():
    currier = curry(4)
    num, val, kw = run_in_loop(currier(task)(2)(4)(baz='foo')(tee=True))
    assert num == 6
    assert val == 'foo'
    assert kw == {'tee': True}
Ejemplo n.º 6
0
def test_curry_zero_arity():
    assert run_in_loop(curry(lambda: True))
Ejemplo n.º 7
0
def test_curry_single_arity():
    assert run_in_loop(curry(lambda x: x)(True))
Ejemplo n.º 8
0
def test_curry_coroutine():
    num, val, kw = run_in_loop(curry(coro)(2)(4)(baz='foo', tee=True))
    assert num == 6
    assert val == 'foo'
    assert kw == {'tee': True}