FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pythonnet/src/embed_tests/TestInstanceWrapping.cs at drop-python2 · filmor/pythonnet · GitHub
filmor
/
pythonnet
Public
forked from
pythonnet/pythonnet
Notifications
You must be signed in to change notification settings
Fork
1
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
pythonnet
/
src
/
embed_tests
/
TestInstanceWrapping.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
58 lines (50 loc) · 1.73 KB
Breadcrumbs
pythonnet
/
src
/
embed_tests
/
TestInstanceWrapping.cs
Copy path
File metadata and controls
58 lines (50 loc) · 1.73 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using
System
;
using
System
.
Globalization
;
using
NUnit
.
Framework
;
using
Python
.
Runtime
;
namespace
Python
.
EmbeddingTest
{
public
class
TestInstanceWrapping
{
[
OneTimeSetUp
]
public
void
SetUp
(
)
{
PythonEngine
.
Initialize
(
)
;
}
[
OneTimeTearDown
]
public
void
Dispose
(
)
{
PythonEngine
.
Shutdown
(
)
;
}
// regression test for https://github.com/pythonnet/pythonnet/issues/811
[
Test
]
public
void
OverloadResolution_UnknownToObject
(
)
{
var
overloaded
=
new
Overloaded
(
)
;
using
(
Py
.
GIL
(
)
)
{
var
o
=
overloaded
.
ToPython
(
)
;
dynamic
callWithSelf
=
PythonEngine
.
Eval
(
"lambda o: o.ObjOrClass(object())"
)
;
callWithSelf
(
o
)
;
Assert
.
AreEqual
(
Overloaded
.
Object
,
overloaded
.
Value
)
;
}
}
class
Base
{
}
class
Derived
:
Base
{
}
class
Overloaded
:
Derived
{
public
int
Value
{
get
;
set
;
}
public
void
IntOrStr
(
int
arg
)
=>
this
.
Value
=
arg
;
public
void
IntOrStr
(
string
arg
)
=>
this
.
Value
=
int
.
Parse
(
arg
,
NumberStyles
.
Integer
,
CultureInfo
.
InvariantCulture
)
;
public
const
int
Object
=
1
;
public
const
int
ConcreteClass
=
2
;
public
void
ObjOrClass
(
object
_
)
=>
this
.
Value
=
Object
;
public
void
ObjOrClass
(
Overloaded
_
)
=>
this
.
Value
=
ConcreteClass
;
public
const
int
Base
=
ConcreteClass
+
1
;
public
const
int
Derived
=
Base
+
1
;
public
void
BaseOrDerived
(
Base
_
)
=>
this
.
Value
=
Base
;
public
void
BaseOrDerived
(
Derived
_
)
=>
this
.
Value
=
Derived
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL