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
f7c0c87e
Commit
f7c0c87e
authored
May 19, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add unit test against inplace operator with baseclass rhs inferring lhs to baseclass
parent
1ed9056d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
0 deletions
+42
-0
tests/run/cypclass_inplace_operator_inference.pyx
tests/run/cypclass_inplace_operator_inference.pyx
+42
-0
No files found.
tests/run/cypclass_inplace_operator_inference.pyx
0 → 100644
View file @
f7c0c87e
# mode: run
# tag: cpp, cpp11
# cython: experimental_cpp_class_def=True, language_level=2
cdef
cypclass
A
nolock
:
int
val
__init__
(
self
,
int
a
):
self
.
val
=
a
A
__iadd__
(
self
,
A
other
):
self
.
val
+=
(
other
.
val
+
1
)
cdef
cypclass
B
(
A
)
nolock
:
B
__iadd__
(
self
,
A
other
):
self
.
val
+=
(
other
.
val
+
10
)
B
__iadd__
(
self
,
B
other
):
self
.
val
+=
(
other
.
val
+
100
)
def
test_inplace_operator_inference
():
"""
>>> test_inplace_operator_inference()
111
"""
a
=
A
(
0
)
b0
=
B
(
0
)
b1
=
B
(
0
)
# at this point, the types are unambiguous and the following assignments should not cause them to infer as another type.
a
+=
b0
# should add 1
# before it being fixed, 'b0 += a' where 'a' is of type A caused 'b0' to be inferred as type A instead of B.
b0
+=
a
# should add 10
# since all cypclass methods are virtual, 'b0' being erroneously inferred as type A would cause
# 'b0 += b1' to call 'B __iadd__(self, A other)' instead of 'B __iadd__(self, B other)'.
b0
+=
b1
# should add 100
return
b0
.
val
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