Skip to content

Commit

Permalink
Adds stargs and kwargs support to methodcaller partial
Browse files Browse the repository at this point in the history
Refs #228.
  • Loading branch information
evhub committed Mar 21, 2017
1 parent 5fc67b3 commit 236ac4e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion coconut/compiler/grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ class Grammar(object):
questionmark | dubstar + test | star + test | name + default | test
), comma))
methodcaller_args = (
itemlist(condense(name + default | test), comma)
itemlist(condense(dubstar + test | star + test | name + default | test), comma)
| op_item
)

Expand Down
3 changes: 2 additions & 1 deletion tests/src/cocotest/agnostic/suite.coco
Original file line number Diff line number Diff line change
Expand Up @@ -288,5 +288,6 @@ def suite_test():
assert Tuple(1, 2, 3) != Tuple(1, 2)
assert map(plus1, (1, 2, 3)) |> fmap$(times2) |> repr == map(times2..plus1, (1, 2, 3)) |> repr
assert reversed((1, 2, 3)) |> fmap$(plus1) |> repr == map(plus1, (1, 2, 3)) |> reversed |> repr
assert identity_getitem()[1:2, 2:3] == (slice(1, 2), slice(2, 3)) == identity_getitem() |> .[1:2, 2:3]
assert ident[1:2, 2:3] == (slice(1, 2), slice(2, 3)) == ident |> .[1:2, 2:3]
assert ident.method(*(1,), **{"a": 2}) == ((1,), {"a": 1}) == ident |> .method(*(1,), **{"a": 2})
return True
4 changes: 3 additions & 1 deletion tests/src/cocotest/agnostic/util.coco
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,10 @@ def ret_none(n):

def ret_args_kwargs(*args, **kwargs) = (args, kwargs)

class identity_getitem:
class identity_operations:
def __getitem__(self, *args) = args
def method(self, *args, **kwargs) = (args, kwargs)
ident = identity_operations()

# Typing

Expand Down

0 comments on commit 236ac4e

Please sign in to comment.