summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/fun_callstardblstar.py
diff options
context:
space:
mode:
authorDavid Lechner <david@pybricks.com>2022-03-29 13:15:15 -0500
committerDamien George <damien@micropython.org>2022-03-31 17:01:15 +1100
commit47685180f02254a9d2dfd2eb9dafc24888daeb33 (patch)
tree0d63bb44a9d7ce93cc0fa50a2a8e2c476b58201c /tests/basics/fun_callstardblstar.py
parent9b74d71aa74d368e0679616173edb4be49e03684 (diff)
downloadmicropython-47685180f02254a9d2dfd2eb9dafc24888daeb33.tar.gz
micropython-47685180f02254a9d2dfd2eb9dafc24888daeb33.zip
tests/basics/fun_callstardblstar: Add coverage test.
This fixes code coverage for the case where a *arg without __len__ is unpacked and uses exactly the amount of memory that was allocated for kw args. This triggers the code branch where the memory for the kw args gets reallocated since it was used already by the *arg unpacking. Signed-off-by: David Lechner <david@pybricks.com>
Diffstat (limited to 'tests/basics/fun_callstardblstar.py')
-rw-r--r--tests/basics/fun_callstardblstar.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/basics/fun_callstardblstar.py b/tests/basics/fun_callstardblstar.py
index aceb04a843..7db458b561 100644
--- a/tests/basics/fun_callstardblstar.py
+++ b/tests/basics/fun_callstardblstar.py
@@ -25,3 +25,12 @@ try:
eval("a.f(**{'a': 1}, *(2, 3, 4))")
except SyntaxError:
print("SyntaxError")
+
+
+# coverage test for arg allocation corner case
+
+def f2(*args, **kwargs):
+ print(len(args), len(kwargs))
+
+
+f2(*iter(range(4)), **{'a': 1})