Skip to content

Commit 97d47b7

Browse files
committed
Add more unit tests
1 parent a1a7e72 commit 97d47b7

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/embed_tests/TestMethodBinder.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,20 @@ public void PyObjectArgsHavePrecedenceOverOtherTypes()
967967
pyInstance.InvokeMethod("Method", pyArg);
968968
});
969969

970+
// With the first named argument
971+
Assert.DoesNotThrow(() =>
972+
{
973+
using var kwargs = Py.kw("decimalArgument", 1.234m);
974+
pyInstance.InvokeMethod("Method", new[] { pyArg }, kwargs);
975+
});
976+
977+
// Snake case version
978+
Assert.DoesNotThrow(() =>
979+
{
980+
using var kwargs = Py.kw("decimal_argument", 1.234m);
981+
pyInstance.InvokeMethod("method", new[] { pyArg }, kwargs);
982+
});
983+
970984
Assert.AreEqual("Overload 4", instance.CalledMethodMessage);
971985

972986
Assert.IsFalse(Exceptions.ErrorOccurred());

src/runtime/MethodBinder.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ private static int GetMatchedArgumentsPrecedence(MethodInformation method, int m
362362
var val = 0;
363363
for (var i = 0; i < pi.Length; i++)
364364
{
365-
if (i < matchedPositionalArgsCount || matchedKwargsNames.Contains(pi[i].Name))
365+
if (i < matchedPositionalArgsCount || matchedKwargsNames.Contains(method.ParameterNames[i]))
366366
{
367367
val += ArgPrecedence(pi[i].ParameterType, isOperatorMethod);
368368
}
@@ -480,11 +480,6 @@ internal Binding Bind(BorrowedReference inst, BorrowedReference args, BorrowedRe
480480
var methods = info == null ? GetMethods()
481481
: new List<MethodInformation>(1) { new MethodInformation(info, true) };
482482

483-
if (methods.Any(m => m.MethodBase.Name.StartsWith("History")))
484-
{
485-
486-
}
487-
488483
int pyArgCount = (int)Runtime.PyTuple_Size(args);
489484
var matches = new List<MatchedMethod>(methods.Count);
490485
List<MatchedMethod> matchesUsingImplicitConversion = null;

0 commit comments

Comments
 (0)