コード例 #1
0
 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))
コード例 #2
0
ファイル: __init__.py プロジェクト: DocHoncho/brownie
 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))
コード例 #3
0
 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))
コード例 #4
0
ファイル: __init__.py プロジェクト: DocHoncho/brownie
    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'
コード例 #5
0
    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'
コード例 #6
0
ファイル: __init__.py プロジェクト: DocHoncho/brownie
    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))
コード例 #7
0
    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))
コード例 #8
0
ファイル: __init__.py プロジェクト: DocHoncho/brownie
    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'
コード例 #9
0
    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'
コード例 #10
0
ファイル: __init__.py プロジェクト: DocHoncho/brownie
 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))
コード例 #11
0
ファイル: __init__.py プロジェクト: DocHoncho/brownie
 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)
コード例 #12
0
 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)