Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add more more tests for in, out and ref parameters#1349

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall commits
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
204 changes: 204 additions & 0 deletionssrc/domain_tests/TestRunner.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -843,6 +843,210 @@ raise AssertionError('failed to raise')
assert foo is not bar
",
},

new TestCase
{
Name = "ref_to_out_param",
DotNetBefore = @"
namespace TestNamespace
{

[System.Serializable]
public class Data
{
public int num = -1;
}

[System.Serializable]
public class Cls
{
public static void MyFn (ref Data a)
{
a.num = 7;
}
}
}",
DotNetAfter = @"
namespace TestNamespace
{

[System.Serializable]
public class Data
{
public int num = -1;
}

[System.Serializable]
public class Cls
{
public static void MyFn (out Data a)
{
a = new Data();
a.num = 9001;
}
}
}",
PythonCode = @"
import clr
import sys
clr.AddReference('DomainTests')
import TestNamespace
import System

def before_reload():

foo = TestNamespace.Data()
bar = TestNamespace.Cls.MyFn(foo)
# foo should have changed
assert foo.num == 7
assert bar.num == 7


def after_reload():

foo = TestNamespace.Data()
bar = TestNamespace.Cls.MyFn(foo)
assert bar.num == 9001
# foo shouldn't have changed.
assert foo.num == -1
# this should work too
baz = TestNamespace.Cls.MyFn(None)
assert baz.num == 9001
",
},
new TestCase
{
Name = "ref_to_in_param",
DotNetBefore = @"
namespace TestNamespace
{

[System.Serializable]
public class Data
{
public int num = -1;
}

[System.Serializable]
public class Cls
{
public static void MyFn (ref Data a)
{
a.num = 7;
System.Console.Write(""Method with ref parameter: "");
System.Console.WriteLine(a.num);
}
}
}",
DotNetAfter = @"
namespace TestNamespace
{
[System.Serializable]
public class Data
{
public int num = -1;
}

[System.Serializable]
public class Cls
{
public static void MyFn (Data a)
{
System.Console.Write(""Method with in parameter: "");
System.Console.WriteLine(a.num);
}
}
}",
PythonCode = @"
import clr
import sys
clr.AddReference('DomainTests')
import TestNamespace
import System

def before_reload():

foo = TestNamespace.Data()
bar = TestNamespace.Cls.MyFn(foo)
# foo should have changed
assert foo.num == 7
assert bar.num == 7

def after_reload():

foo = TestNamespace.Data()
TestNamespace.Cls.MyFn(foo)
# foo should not have changed
assert foo.num == TestNamespace.Data().num

",
},
new TestCase
{
Name = "in_to_ref_param",
DotNetBefore = @"
namespace TestNamespace
{
[System.Serializable]
public class Data
{
public int num = -1;
}

[System.Serializable]
public class Cls
{
public static void MyFn (Data a)
{
System.Console.Write(""Method with in parameter: "");
System.Console.WriteLine(a.num);
}
}
}",
DotNetAfter = @"
namespace TestNamespace
{

[System.Serializable]
public class Data
{
public int num = -1;
}

[System.Serializable]
public class Cls
{
public static void MyFn (ref Data a)
{
a.num = 7;
System.Console.Write(""Method with ref parameter: "");
System.Console.WriteLine(a.num);
}
}
}",
PythonCode = @"
import clr
import sys
clr.AddReference('DomainTests')
import TestNamespace
import System

def before_reload():

foo = TestNamespace.Data()
TestNamespace.Cls.MyFn(foo)
# foo should not have changed
assert foo.num == TestNamespace.Data().num

def after_reload():

foo = TestNamespace.Data()
bar = TestNamespace.Cls.MyFn(foo)
# foo should have changed
assert foo.num == 7
assert bar.num == 7
",
},
new TestCase
{
Name = "nested_type",
Expand Down
12 changes: 12 additions & 0 deletionssrc/domain_tests/test_domain_reload.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -83,6 +83,18 @@ def test_construct_removed_class():
def test_out_to_ref_param():
_run_test("out_to_ref_param")

@pytest.mark.skipif(platform.system() == 'Darwin', reason='FIXME: macos can\'t find the python library')
def test_ref_to_out_param():
_run_test("ref_to_out_param")

@pytest.mark.skipif(platform.system() == 'Darwin', reason='FIXME: macos can\'t find the python library')
def test_ref_to_in_param():
_run_test("ref_to_in_param")

@pytest.mark.skipif(platform.system() == 'Darwin', reason='FIXME: macos can\'t find the python library')
def test_in_to_ref_param():
_run_test("in_to_ref_param")

@pytest.mark.skipif(platform.system() == 'Darwin', reason='FIXME: macos can\'t find the python library')
def test_nested_type():
_run_test("nested_type")
4 changes: 2 additions & 2 deletionssrc/runtime/StateSerialization/MaybeMethodBase.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,11 +35,11 @@ public ParameterHelper(ParameterInfo tp)
Name = tp.ParameterType.AssemblyQualifiedName;
Modifier = TypeModifier.None;

if (tp.IsIn)
if (tp.IsIn && tp.ParameterType.IsByRef)
{
Modifier = TypeModifier.In;
}
else if (tp.IsOut)
else if (tp.IsOut && tp.ParameterType.IsByRef)
{
Modifier = TypeModifier.Out;
}
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp