implement varargs (#83)

* implement varargs

* clean up varargs
This commit is contained in:
Philipp Moritz
2016-06-04 16:22:10 -07:00
parent 2b52b91acb
commit f9aeb5d018
6 changed files with 74 additions and 24 deletions
+26
View File
@@ -52,3 +52,29 @@ def keyword_fct2(a="hello", b="world"):
@halo.remote([int, int, str, str], [str])
def keyword_fct3(a, b, c="hello", d="world"):
return "{} {} {} {}".format(a, b, c, d)
# Test variable numbers of arguments
@halo.remote([int], [str])
def varargs_fct1(*a):
return " ".join(map(str, a))
@halo.remote([int, int], [str])
def varargs_fct2(a, *b):
return " ".join(map(str, b))
try:
@halo.remote([int], [])
def kwargs_throw_exception(**c):
return ()
kwargs_exception_thrown = False
except:
kwargs_exception_thrown = True
try:
@halo.remote([int, str, int], [str])
def varargs_and_kwargs_throw_exception(a, b="hi", *c):
return "{} {} {}".format(a, b, c)
varargs_and_kwargs_exception_thrown = False
except:
varargs_and_kwargs_exception_thrown = True