Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
32206bb4
Commit
32206bb4
authored
Aug 17, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add unit test for cypclass method resolution order
parent
ba35886d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
151 additions
and
0 deletions
+151
-0
tests/run/cypclass_mro.pyx
tests/run/cypclass_mro.pyx
+151
-0
No files found.
tests/run/cypclass_mro.pyx
0 → 100644
View file @
32206bb4
# mode: run
# tag: cpp, cpp11, pthread
# cython: experimental_cpp_class_def=True, language_level=2
cdef
cypclass
LeftAdd
:
int
__add__
(
self
,
int
other
):
return
1
cdef
cypclass
RightAdd
:
int
__add__
(
self
,
int
other
):
return
0
cdef
cypclass
DerivedAdd
(
LeftAdd
,
RightAdd
):
pass
def
test_binop_mro
():
"""
>>> test_binop_mro()
(1, 1, 1)
"""
d
=
DerivedAdd
()
cdef
int
r1
=
d
+
1
cdef
RightAdd
r
=
DerivedAdd
()
cdef
int
r2
=
r
+
1
cdef
LeftAdd
l
=
DerivedAdd
()
cdef
int
r3
=
l
+
1
return
(
r1
,
r2
,
r3
)
cdef
cypclass
BaseFoo
:
int
foo
(
self
):
return
0
cdef
cypclass
InheritFoo
(
BaseFoo
):
pass
cdef
cypclass
OverrideFoo
(
BaseFoo
):
int
foo
(
self
):
return
1
cdef
cypclass
MixinFoo
(
InheritFoo
,
OverrideFoo
):
pass
def
test_mixin_mro
():
"""
>>> test_mixin_mro()
(1, 1)
"""
m
=
MixinFoo
()
cdef
int
r1
=
m
.
foo
()
cdef
InheritFoo
i
=
MixinFoo
()
cdef
int
r2
=
i
.
foo
()
return
r1
,
r2
cdef
cypclass
LeftBar
:
int
bar
(
self
):
return
1
cdef
cypclass
RightBar
:
int
bar
(
self
):
return
0
cdef
cypclass
InheritBarTwice
(
LeftBar
,
RightBar
):
pass
def
test_unrelated_mro
():
"""
>>> test_unrelated_mro()
(1, 1, 1)
"""
d
=
InheritBarTwice
()
cdef
int
r1
=
d
.
bar
()
cdef
RightBar
r
=
InheritBarTwice
()
cdef
int
r2
=
r
.
bar
()
cdef
LeftBar
l
=
InheritBarTwice
()
cdef
int
r3
=
l
.
bar
()
return
r1
,
r2
,
r3
cdef
cypclass
BaseStaticBaz
:
@
staticmethod
int
baz
():
return
0
cdef
cypclass
InheritStaticBaz
(
BaseStaticBaz
):
pass
cdef
cypclass
OverloadStaticBaz
(
BaseStaticBaz
):
@
staticmethod
int
baz
():
return
1
cdef
cypclass
MixinStaticBaz
(
InheritStaticBaz
,
OverloadStaticBaz
):
pass
def
test_mixin_static_mro
():
"""
>>> test_mixin_static_mro()
(1, 1)
"""
m
=
MixinStaticBaz
()
cdef
int
r1
=
m
.
baz
()
cdef
InheritStaticBaz
i
=
MixinStaticBaz
()
cdef
int
r2
=
i
.
baz
()
return
r1
,
r2
cdef
cypclass
LeftStaticFoobar
:
@
staticmethod
int
foobar
():
return
1
cdef
cypclass
RightStaticFoobar
:
@
staticmethod
int
foobar
():
return
0
cdef
cypclass
InheritStaticFoobarTwice
(
LeftStaticFoobar
,
RightStaticFoobar
):
pass
def
test_unrelated_static_mro
():
"""
>>> test_unrelated_static_mro()
(1, 1, 1)
"""
d
=
InheritStaticFoobarTwice
()
cdef
int
r1
=
d
.
foobar
()
cdef
RightStaticFoobar
r
=
InheritStaticFoobarTwice
()
cdef
int
r2
=
r
.
foobar
()
cdef
LeftStaticFoobar
l
=
InheritStaticFoobarTwice
()
cdef
int
r3
=
l
.
foobar
()
return
r1
,
r2
,
r3
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment