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
7677b120
Commit
7677b120
authored
Dec 29, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add unit tests for 'consume' operations
parent
30f17717
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
663 additions
and
0 deletions
+663
-0
tests/run/cypclass_consume.pyx
tests/run/cypclass_consume.pyx
+517
-0
tests/run/cypclass_consume_refcount.pyx
tests/run/cypclass_consume_refcount.pyx
+146
-0
No files found.
tests/run/cypclass_consume.pyx
0 → 100644
View file @
7677b120
This diff is collapsed.
Click to expand it.
tests/run/cypclass_consume_refcount.pyx
0 → 100644
View file @
7677b120
# mode: run
# tag: cpp, cpp11, pthread
# cython: experimental_cpp_class_def=True, language_level=2
cdef
cypclass
Refcounted
:
__dealloc__
(
self
)
with
gil
:
print
(
"Refcounted destroyed"
)
def
test_consume_name
():
"""
>>> test_consume_name()
Refcounted destroyed
0
"""
r0
=
Refcounted
()
if
Cy_GETREF
(
r0
)
!=
2
:
return
-
1
cdef
Refcounted
r1
=
consume
r0
if
r0
is
not
NULL
:
return
-
2
if
Cy_GETREF
(
r1
)
!=
2
:
return
-
3
return
0
def
test_consume_iso_name
():
"""
>>> test_consume_iso_name()
Refcounted destroyed
0
"""
cdef
iso
Refcounted
r0
=
consume
Refcounted
()
cdef
Refcounted
r1
=
consume
r0
if
r0
is
not
NULL
:
return
-
2
if
Cy_GETREF
(
r1
)
!=
2
:
return
-
3
return
0
def
test_consume_and_drop_name
():
"""
>>> test_consume_and_drop_name()
Refcounted destroyed
consumed
0
"""
r
=
Refcounted
()
if
Cy_GETREF
(
r
)
!=
2
:
return
-
1
consume
r
print
(
"consumed"
)
if
r
is
not
NULL
:
return
-
2
return
0
def
test_consume_constructed
():
"""
>>> test_consume_constructed()
Refcounted destroyed
0
"""
cdef
Refcounted
r
=
consume
Refcounted
()
if
Cy_GETREF
(
r
)
!=
2
:
return
-
1
return
0
def
test_consume_iso_constructed
():
"""
>>> test_consume_iso_constructed()
Refcounted destroyed
0
"""
cdef
Refcounted
r
=
consume
new
Refcounted
()
if
Cy_GETREF
(
r
)
!=
2
:
return
-
1
return
0
def
test_consume_and_drop_constructed
():
"""
>>> test_consume_and_drop_constructed()
Refcounted destroyed
consumed
0
"""
consume
Refcounted
()
print
(
"consumed"
)
return
0
cdef
cypclass
Origin
:
Refcounted
field
__init__
(
self
):
self
.
field
=
Refcounted
()
cdef
cypclass
OriginIso
:
iso
Refcounted
field
__init__
(
self
):
self
.
field
=
consume
Refcounted
()
def
test_consume_field
():
"""
>>> test_consume_field()
Refcounted destroyed
0
"""
cdef
Refcounted
r
=
consume
Origin
().
field
if
Cy_GETREF
(
r
)
!=
2
:
return
-
1
return
0
def
test_consume_iso_field
():
"""
>>> test_consume_iso_field()
Refcounted destroyed
0
"""
cdef
Refcounted
r
=
consume
OriginIso
().
field
if
Cy_GETREF
(
r
)
!=
2
:
return
-
1
return
0
def
test_consume_and_drop_field
():
"""
>>> test_consume_and_drop_field()
Refcounted destroyed
consumed
0
"""
consume
Origin
().
field
print
(
"consumed"
)
return
0
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