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

Commit461c9c7

Browse files
committed
Add tests for deriving a Python subclass from a generic interface
1 parentfb17907 commit461c9c7

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

‎src/testing/interfacetest.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ private interface IPrivate
7979
{
8080
}
8181
}
82-
82+
8383
publicinterfaceIOutArg
8484
{
8585
stringMyMethod_Out(stringname,outintindex);
@@ -93,4 +93,25 @@ public static int CallMyMethod_Out(IOutArg myInterface)
9393
returnindex;
9494
}
9595
}
96+
97+
publicinterfaceIGenericInterface<T>
98+
{
99+
publicTGet(Tx);
100+
}
101+
102+
publicclassSpecificInterfaceUser
103+
{
104+
publicSpecificInterfaceUser(IGenericInterface<int>some,intx)
105+
{
106+
some.Get(x);
107+
}
108+
}
109+
110+
publicclassGenericInterfaceUser<T>
111+
{
112+
publicGenericInterfaceUser(IGenericInterface<T>some,Tx)
113+
{
114+
some.Get(x);
115+
}
116+
}
96117
}

‎tests/test_subclass.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
importSystem
1010
importpytest
1111
fromPython.Testimport (IInterfaceTest,SubClassTest,EventArgsTest,
12-
FunctionsTest)
12+
FunctionsTest,IGenericInterface)
1313
fromSystem.Collections.GenericimportList
1414

1515

@@ -29,6 +29,17 @@ def bar(self, x, i):
2929
returnInterfaceTestClass
3030

3131

32+
definterface_generic_class_fixture(subnamespace):
33+
34+
classGenericInterfaceImpl(IGenericInterface[int]):
35+
__namespace__="Python.Test."+subnamespace
36+
37+
defGet(self,x):
38+
returnx
39+
40+
returnGenericInterfaceImpl
41+
42+
3243
defderived_class_fixture(subnamespace):
3344
"""Delay creation of class until test starts."""
3445

@@ -306,3 +317,13 @@ class Derived(BaseClass):
306317

307318
importgc
308319
gc.collect()
320+
321+
deftest_generic_interface():
322+
fromSystemimportInt32
323+
fromPython.TestimportGenericInterfaceUser,SpecificInterfaceUser
324+
325+
GenericInterfaceImpl=interface_generic_class_fixture(test_generic_interface.__name__)
326+
327+
obj=GenericInterfaceImpl()
328+
SpecificInterfaceUser(obj,Int32(0))
329+
GenericInterfaceUser[Int32](obj,Int32(0))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp