Skip to content

Method overload object type #377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 22, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add more object overload method tests
  • Loading branch information
vmuriart committed Feb 22, 2017
commit 4071aa3c37ac45bb6fe40d23558f68922f9b7f3e
50 changes: 50 additions & 0 deletions src/testing/methodtest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,56 @@ public static string TestOverloadedObject(object o)
return "Got object";
}

public static string TestOverloadedObjectTwo(int a, int b)
{
return "Got int-int";
}

public static string TestOverloadedObjectTwo(string a, string b)
{
return "Got string-string";
}

public static string TestOverloadedObjectTwo(string a, int b)
{
return "Got string-int";
}

public static string TestOverloadedObjectTwo(string a, object b)
{
return "Got string-object";
}

public static string TestOverloadedObjectTwo(int a, object b)
{
return "Got int-object";
}

public static string TestOverloadedObjectTwo(object a, int b)
{
return "Got object-int";
}

public static string TestOverloadedObjectTwo(object a, object b)
Copy link
Contributor

@den-run-ai den-run-ai Feb 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't test this method in python

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because you changed the test for it above. I re-added a test for it.

{
return "Got object-object";
}

public static string TestOverloadedObjectTwo(int a, string b)
{
return "Got int-string";
}

public static string TestOverloadedObjectThree(object a, int b)
{
return "Got object-int";
}

public static string TestOverloadedObjectThree(int a, object b)
{
return "Got int-object";
}

public static bool TestStringOutParams(string s, out string s1)
{
s1 = "output string";
Expand Down
29 changes: 29 additions & 0 deletions src/tests/test_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,3 +790,32 @@ def test_object_in_param():

res = MethodTest.TestOverloadedObject("test")
assert res == "Got object"


def test_object_in_multiparam():
"""Test method with object multiparams behaves"""

res = MethodTest.TestOverloadedObjectTwo(5, 5)
assert res == "Got int-int"

res = MethodTest.TestOverloadedObjectTwo(5, "foo")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this break if you add:

public static string TestOverloadedObjectTwo(int a, string b)
        {
            return "Got int-string";
        }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now its there.

assert res == "Got int-string"

res = MethodTest.TestOverloadedObjectTwo("foo", 7.24)
assert res == "Got string-object"

res = MethodTest.TestOverloadedObjectTwo("foo", "bar")
assert res == "Got string-string"

res = MethodTest.TestOverloadedObjectTwo("foo", 5)
assert res == "Got string-int"

res = MethodTest.TestOverloadedObjectTwo(7.24, 7.24)
assert res == "Got object-object"


def test_object_in_multiparam_exception():
"""Test method with object multiparams behaves"""

with pytest.raises(TypeError):
MethodTest.TestOverloadedObjectThree("foo", "bar")