def mixed_arbitary_arguments(self): func = curried(lambda a, b, c, *args, **kwargs: (a, b, c, args, kwargs)) Assert(func(1, 2, 3)) == (1, 2, 3, (), {}) Assert(func(1, 2, 3, 4, 5)) == (1, 2, 3, (4, 5), {}) Assert(func(1, 2, 3, foo=4)) == (1, 2, 3, (), dict(foo=4)) Assert(func(1, 2, 3, 4, foo=5)) == (1, 2, 3, (4, ), dict(foo=5))
def arbitary_keyword_arguments(self): func = curried(lambda a, b, c, **kwargs: (a, b, c, kwargs)) Assert(func(1, 2, 3)) == (1, 2, 3, {}) with Assert.raises(TypeError): func(1, 2)(3, c=4) Assert(func(1, 2, 3, foo=4)) == (1, 2, 3, dict(foo=4)) Assert(func(1)(2, 3, foo=4)) == (1, 2, 3, dict(foo=4)) Assert(func(1, 2)(3, foo=4)) == (1, 2, 3, dict(foo=4))
def keyword_arguments(self): func = curried(lambda a=1, b=2, c=3: (a, b, c)) Assert(func()) == (1, 2, 3) Assert(func(c=4)) == (1, 2, 4) Assert(func(4)) == (4, 2, 3) with Assert.raises(TypeError) as exc: func(d=4) Assert(exc.args[0]) == 'd is an unexpected keyword argument: 4'
def arbitary_positionals(self): func = curried(lambda a, b, c, *args: (a, b, c, args)) Assert(func(1, 2, 3)) == (1, 2, 3, ()) Assert(func(1, 2, 3, 4, 5)) == (1, 2, 3, (4, 5)) Assert(func(1)(2, 3, 4, 5)) == (1, 2, 3, (4, 5)) Assert(func(1, 2)(3, 4, 5)) == (1, 2, 3, (4, 5)) Assert(func(1)(2, 3, 4, 5)) == (1, 2, 3, (4, 5)) Assert(func(1)(b=2)(3, 4, 5)) == (1, 2, 3, (4, 5)) Assert(func(a=1)(b=2)(3, 4, 5)) == (1, 2, 3, (4, 5)) Assert(func(a=1, b=2)(3, 4, 5)) == (1, 2, 3, (4, 5))
def positional(self): func = curried(lambda a, b, c: (a, b, c)) Assert(func(1, 2, 3)) == (1, 2, 3) Assert(func(1, 2)(3)) == (1, 2, 3) Assert(func(1)(2, 3)) == (1, 2, 3) Assert(func(1)(2)(3)) == (1, 2, 3) Assert(func(c=3, b=2, a=1)) == (1, 2, 3) Assert(func(c=3)(a=1)(2)) == (1, 2, 3) with Assert.raises(TypeError) as exc: func(1, 2, 3, 4) Assert(exc.args[0]) == 'unexpected positional argument: 4'
def mixed_positional_keyword_arguments(self): func = curried(lambda a, b, c=3: (a, b, c)) Assert(func(1, 2)) == (1, 2, 3) Assert(func(1, 2, 4)) == (1, 2, 4)