Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b7a3c7e

Browse files
committed
Add object overload test
1 parent 909b7c0 commit b7a3c7e

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

src/testing/methodtest.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,21 @@ public static int[] TestOverloadedParams(int v, int[] args)
116116
return args;
117117
}
118118

119+
public static string TestOverloadedNoObject(int i)
120+
{
121+
return "Got int";
122+
}
123+
124+
public static string TestOverloadedObject(int i)
125+
{
126+
return "Got int";
127+
}
128+
129+
public static string TestOverloadedObject(object o)
130+
{
131+
return "Got object";
132+
}
133+
119134
public static bool TestStringOutParams(string s, out string s1)
120135
{
121136
s1 = "output string";

src/tests/test_method.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,3 +769,25 @@ def test_wrong_overload():
769769
res = System.Math.Max(System.Double(50.5), 50.1)
770770
assert res == 50.5
771771
assert type(res) == float
772+
773+
774+
def test_no_object_in_param():
775+
"""Test that fix for #203 doesn't break behavior w/ no object overload"""
776+
777+
res = MethodTest.TestOverloadedNoObject(5)
778+
assert res == "Got int"
779+
780+
with pytest.raises(TypeError):
781+
MethodTest.TestOverloadedNoObject("test")
782+
783+
784+
@pytest.mark.xfail(reason="Needs fixing. #203")
785+
def test_object_in_param():
786+
"""Test regression introduced by #151 in which Object method overloads
787+
aren't being used. See #203 for issue."""
788+
789+
res = MethodTest.TestOverloadedObject(5)
790+
assert res == "Got int"
791+
792+
res = MethodTest.TestOverloadedObject("test")
793+
assert res == "Got object"

0 commit comments

Comments
 (0)