Skip to content

Commit b9538b9

Browse files
committed
Add tests for method matching in presence of param arrays
1 parent 001aeec commit b9538b9

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

src/testing/methodtest.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,16 @@ public static string DefaultParamsWithOverloading(int a = 5, int b = 6, int c =
703703
{
704704
return $"{a}{b}{c}{d}XXX";
705705
}
706+
707+
public static string ParamsArrayOverloaded(int i = 1)
708+
{
709+
return "without params-array";
710+
}
711+
712+
public static string ParamsArrayOverloaded(int i, params int[] paramsArray)
713+
{
714+
return "with params-array";
715+
}
706716
}
707717

708718

src/tests/test_method.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,3 +1188,37 @@ def test_keyword_arg_method_resolution():
11881188
ob = MethodArityTest()
11891189
assert ob.Foo(1, b=2) == "Arity 2"
11901190

1191+
def test_params_array_overload():
1192+
res = MethodTest.ParamsArrayOverloaded()
1193+
assert res == "without params-array"
1194+
1195+
res = MethodTest.ParamsArrayOverloaded(1)
1196+
assert res == "without params-array"
1197+
1198+
res = MethodTest.ParamsArrayOverloaded(i=1)
1199+
assert res == "without params-array"
1200+
1201+
res = MethodTest.ParamsArrayOverloaded(1, 2)
1202+
assert res == "with params-array"
1203+
1204+
res = MethodTest.ParamsArrayOverloaded(1, 2, 3)
1205+
assert res == "with params-array"
1206+
1207+
res = MethodTest.ParamsArrayOverloaded(1, 2, 3, i=1)
1208+
assert res == "with params-array"
1209+
1210+
# res = MethodTest.ParamsArrayOverloaded(paramsArray=[], i=1)
1211+
# assert res == "with params-array"
1212+
1213+
res = MethodTest.ParamsArrayOverloaded(1, paramsArray=[])
1214+
assert res == "with params-array"
1215+
1216+
res = MethodTest.ParamsArrayOverloaded(1, i=1)
1217+
assert res == "with params-array"
1218+
1219+
# res = MethodTest.ParamsArrayOverloaded(1, 2, i=1)
1220+
# assert res == "with params-array"
1221+
1222+
# res = MethodTest.ParamsArrayOverloaded(1, 2, 3, i=1)
1223+
# assert res == "with params-array"
1224+

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy