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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Xavier Thompson
cython
Commits
585aae4a
Commit
585aae4a
authored
Jun 11, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update unit test for method call resolution according to MRO
parent
1c7b2328
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
101 additions
and
54 deletions
+101
-54
tests/errors/cypclass_hidden_overridden_methods.pyx
tests/errors/cypclass_hidden_overridden_methods.pyx
+0
-21
tests/run/cypclass_hide_override.pyx
tests/run/cypclass_hide_override.pyx
+0
-33
tests/run/cypclass_resolve_method_calls.pyx
tests/run/cypclass_resolve_method_calls.pyx
+101
-0
No files found.
tests/errors/cypclass_hidden_overridden_methods.pyx
deleted
100644 → 0
View file @
1c7b2328
# mode: error
# tag: cpp, cpp11, pthread
# cython: experimental_cpp_class_def=True, language_level=2
cdef
cypclass
A
:
void
foo
(
self
,
int
a
):
pass
cdef
cypclass
B
(
A
):
void
foo
(
self
,
int
a
,
int
b
):
pass
def
test_hidden_overridden_methods
():
cdef
B
b
=
B
()
# A.foo is hidden by B.foo, regardless of signature
b
.
foo
(
1
)
_ERRORS
=
u"""
17:9: Call with wrong number of arguments (expected 2, got 1)
"""
\ No newline at end of file
tests/run/cypclass_hide_override.pyx
deleted
100644 → 0
View file @
1c7b2328
# mode: run
# tag: cpp, cpp11, pthread
# cython: experimental_cpp_class_def=True, language_level=2
cdef
cypclass
A
nolock
:
int
a
__init__
(
self
,
int
a
):
self
.
a
=
a
A
foo
(
self
,
int
other
):
return
A
(
a
+
other
)
cdef
cypclass
B
(
A
)
nolock
:
int
b
__init__
(
self
,
int
b
):
self
.
b
=
10
+
b
B
foo
(
self
,
int
other
):
return
B
(
b
+
other
)
def
test_hide_override
():
"""
>>> test_hide_override()
21
"""
cdef
B
b1
=
B
(
0
)
# This should not result in a 'ambiguous overloaded method' compilation error
cdef
B
b2
=
b1
.
foo
(
1
)
return
b2
.
b
\ No newline at end of file
tests/run/cypclass_resolve_method_calls.pyx
0 → 100644
View file @
585aae4a
# mode: run
# tag: cpp, cpp11, pthread
# cython: experimental_cpp_class_def=True, language_level=2
cdef
cypclass
A
:
int
foo
(
self
,
int
a
):
return
a
+
42
cdef
cypclass
B
(
A
):
int
foo
(
self
,
int
a
,
int
b
):
return
a
+
b
def
test_resolve_unhidden_method
():
"""
>>> test_resolve_unhidden_method()
43
"""
cdef
B
b
=
B
()
# should resolve to A.foo
return
b
.
foo
(
1
)
cdef
cypclass
C
:
int
a
__init__
(
self
,
int
a
):
self
.
a
=
a
C
foo
(
self
,
int
other
):
return
C
(
a
+
other
)
cdef
cypclass
D
(
C
):
int
b
__init__
(
self
,
int
b
):
self
.
b
=
10
+
b
D
foo
(
self
,
int
other
):
return
D
(
b
+
other
)
def
test_resolve_overriden_method
():
"""
>>> test_resolve_overriden_method()
21
"""
cdef
D
d1
=
D
(
0
)
# should not resolve to D.foo
cdef
D
d2
=
d1
.
foo
(
1
)
return
d2
.
b
cdef
cypclass
Left
:
int
foo
(
self
):
return
1
cdef
cypclass
Right
:
int
foo
(
self
):
return
2
cdef
cypclass
Derived
(
Left
,
Right
):
pass
def
test_resolve_multiple_inherited_methods
():
"""
>>> test_resolve_multiple_inherited_methods()
1
"""
cdef
Derived
d
=
Derived
()
# should resolve to Left.foo
cdef
int
r
=
d
.
foo
()
return
r
cdef
cypclass
Top
:
int
foo
(
self
,
int
a
,
int
b
):
return
1
cdef
cypclass
Middle
(
Top
):
int
foo
(
self
):
return
2
cdef
cypclass
Bottom
(
Middle
):
int
foo
(
self
,
int
a
):
return
a
+
10
def
test_inherited_overloaded_method
():
"""
>>> test_inherited_overloaded_method()
2
"""
cdef
Bottom
b
=
Bottom
()
# should resolve to Middle.foo
cdef
int
r
=
b
.
foo
()
return
r
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