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
13b1a497
Commit
13b1a497
authored
Sep 01, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clarify cypclass builtin dict and list unit tests
parent
8008479c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
209 additions
and
209 deletions
+209
-209
tests/run/cypclass_builtin_dict.pyx
tests/run/cypclass_builtin_dict.pyx
+143
-143
tests/run/cypclass_builtin_list.pyx
tests/run/cypclass_builtin_list.pyx
+66
-66
No files found.
tests/run/cypclass_builtin_dict.pyx
View file @
13b1a497
...
@@ -133,7 +133,7 @@ def test_nogil_setitem_and_items_iteration():
...
@@ -133,7 +133,7 @@ def test_nogil_setitem_and_items_iteration():
def
test_len
():
def
test_len
():
"""
"""
>>> test_len()
>>> test_len()
1
0
"""
"""
d
=
cypdict
[
Index
,
Value
]()
d
=
cypdict
[
Index
,
Value
]()
cdef
long
unsigned
int
nb_elements
=
0
cdef
long
unsigned
int
nb_elements
=
0
...
@@ -142,15 +142,15 @@ def test_len():
...
@@ -142,15 +142,15 @@ def test_len():
for
k
in
d
:
for
k
in
d
:
nb_elements
+=
1
nb_elements
+=
1
if
d
.
__len__
()
!=
nb_elements
:
if
d
.
__len__
()
!=
nb_elements
:
return
0
return
-
1
if
nb_elements
!=
10
:
if
nb_elements
!=
10
:
return
0
return
-
2
return
1
return
0
def
test_clear
():
def
test_clear
():
"""
"""
>>> test_clear()
>>> test_clear()
1
0
"""
"""
d
=
cypdict
[
Index
,
Value
]()
d
=
cypdict
[
Index
,
Value
]()
for
i
in
range
(
10
):
for
i
in
range
(
10
):
...
@@ -159,13 +159,13 @@ def test_clear():
...
@@ -159,13 +159,13 @@ def test_clear():
return
-
1
return
-
1
d
.
clear
()
d
.
clear
()
if
d
.
__len__
()
!=
0
:
if
d
.
__len__
()
!=
0
:
return
0
return
-
2
return
1
return
0
def
test_update
():
def
test_update
():
"""
"""
>>> test_update()
>>> test_update()
1
0
"""
"""
d1
=
cypdict
[
Index
,
Value
]()
d1
=
cypdict
[
Index
,
Value
]()
d2
=
cypdict
[
Index
,
Value
]()
d2
=
cypdict
[
Index
,
Value
]()
...
@@ -175,66 +175,66 @@ def test_update():
...
@@ -175,66 +175,66 @@ def test_update():
d2
[
Index
(
2
)]
=
Value
(
20
)
d2
[
Index
(
2
)]
=
Value
(
20
)
d1
.
update
(
d2
)
d1
.
update
(
d2
)
if
d1
.
__len__
()
!=
4
:
if
d1
.
__len__
()
!=
4
:
return
0
return
-
1
for
key
in
d2
:
for
key
in
d2
:
if
not
key
in
d1
:
if
not
key
in
d1
:
return
0
return
-
2
if
d2
[
key
]
is
not
d1
[
key
]:
if
d2
[
key
]
is
not
d1
[
key
]:
return
0
return
-
3
return
1
return
0
def
test_contains
():
def
test_contains
():
"""
"""
>>> test_contains()
>>> test_contains()
1
0
"""
"""
d
=
cypdict
[
Index
,
double
]()
d
=
cypdict
[
Index
,
double
]()
for
i
in
range
(
10
):
for
i
in
range
(
10
):
index
=
Index
(
i
)
index
=
Index
(
i
)
if
index
in
d
:
if
index
in
d
:
return
0
return
-
1
d
[
index
]
=
<
double
>
i
d
[
index
]
=
<
double
>
i
if
index
not
in
d
:
if
index
not
in
d
:
return
0
return
-
2
return
1
return
0
def
test_nonexistent_getitem_exception
():
def
test_nonexistent_getitem_exception
():
"""
"""
>>> test_nonexistent_getitem_exception()
>>> test_nonexistent_getitem_exception()
'Getting nonexistent item'
'Getting nonexistent item'
1
0
"""
"""
d
=
cypdict
[
Index
,
Value
]()
d
=
cypdict
[
Index
,
Value
]()
try
:
try
:
with
nogil
:
with
nogil
:
v
=
d
[
Index
()]
v
=
d
[
Index
()]
with
gil
:
with
gil
:
return
0
return
-
1
except
KeyError
as
e
:
except
KeyError
as
e
:
print
(
e
)
print
(
e
)
return
1
return
0
def
test_nonexistent_delitem_exception
():
def
test_nonexistent_delitem_exception
():
"""
"""
>>> test_nonexistent_delitem_exception()
>>> test_nonexistent_delitem_exception()
'Deleting nonexistent item'
'Deleting nonexistent item'
1
0
"""
"""
d
=
cypdict
[
Index
,
Value
]()
d
=
cypdict
[
Index
,
Value
]()
try
:
try
:
with
nogil
:
with
nogil
:
del
d
[
Index
()]
del
d
[
Index
()]
with
gil
:
with
gil
:
return
0
return
-
1
except
KeyError
as
e
:
except
KeyError
as
e
:
print
(
e
)
print
(
e
)
return
1
return
0
def
test_setitem_iterator_invalidation
():
def
test_setitem_iterator_invalidation
():
"""
"""
>>> test_setitem_iterator_invalidation()
>>> test_setitem_iterator_invalidation()
Modifying a dictionary with active iterators
Modifying a dictionary with active iterators
1
0
"""
"""
d
=
cypdict
[
Index
,
Value
]()
d
=
cypdict
[
Index
,
Value
]()
iterator
=
d
.
begin
()
iterator
=
d
.
begin
()
...
@@ -242,16 +242,16 @@ def test_setitem_iterator_invalidation():
...
@@ -242,16 +242,16 @@ def test_setitem_iterator_invalidation():
with
nogil
:
with
nogil
:
d
[
Index
()]
=
Value
()
d
[
Index
()]
=
Value
()
with
gil
:
with
gil
:
return
0
return
-
1
except
RuntimeError
as
e
:
except
RuntimeError
as
e
:
print
(
e
)
print
(
e
)
return
1
return
0
def
test_setitem_keys_iterator_invalidation
():
def
test_setitem_keys_iterator_invalidation
():
"""
"""
>>> test_setitem_keys_iterator_invalidation()
>>> test_setitem_keys_iterator_invalidation()
Modifying a dictionary with active iterators
Modifying a dictionary with active iterators
1
0
"""
"""
d
=
cypdict
[
Index
,
Value
]()
d
=
cypdict
[
Index
,
Value
]()
iterator
=
d
.
keys
().
begin
()
iterator
=
d
.
keys
().
begin
()
...
@@ -259,16 +259,16 @@ def test_setitem_keys_iterator_invalidation():
...
@@ -259,16 +259,16 @@ def test_setitem_keys_iterator_invalidation():
with
nogil
:
with
nogil
:
d
[
Index
()]
=
Value
()
d
[
Index
()]
=
Value
()
with
gil
:
with
gil
:
return
0
return
-
1
except
RuntimeError
as
e
:
except
RuntimeError
as
e
:
print
(
e
)
print
(
e
)
return
1
return
0
def
test_setitem_values_iterator_invalidation
():
def
test_setitem_values_iterator_invalidation
():
"""
"""
>>> test_setitem_values_iterator_invalidation()
>>> test_setitem_values_iterator_invalidation()
Modifying a dictionary with active iterators
Modifying a dictionary with active iterators
1
0
"""
"""
d
=
cypdict
[
Index
,
Value
]()
d
=
cypdict
[
Index
,
Value
]()
iterator
=
d
.
values
().
begin
()
iterator
=
d
.
values
().
begin
()
...
@@ -276,16 +276,16 @@ def test_setitem_values_iterator_invalidation():
...
@@ -276,16 +276,16 @@ def test_setitem_values_iterator_invalidation():
with
nogil
:
with
nogil
:
d
[
Index
()]
=
Value
()
d
[
Index
()]
=
Value
()
with
gil
:
with
gil
:
return
0
return
-
1
except
RuntimeError
as
e
:
except
RuntimeError
as
e
:
print
(
e
)
print
(
e
)
return
1
return
0
def
test_setitem_items_iterator_invalidation
():
def
test_setitem_items_iterator_invalidation
():
"""
"""
>>> test_setitem_items_iterator_invalidation()
>>> test_setitem_items_iterator_invalidation()
Modifying a dictionary with active iterators
Modifying a dictionary with active iterators
1
0
"""
"""
d
=
cypdict
[
Index
,
Value
]()
d
=
cypdict
[
Index
,
Value
]()
iterator
=
d
.
items
().
begin
()
iterator
=
d
.
items
().
begin
()
...
@@ -293,16 +293,16 @@ def test_setitem_items_iterator_invalidation():
...
@@ -293,16 +293,16 @@ def test_setitem_items_iterator_invalidation():
with
nogil
:
with
nogil
:
d
[
Index
()]
=
Value
()
d
[
Index
()]
=
Value
()
with
gil
:
with
gil
:
return
0
return
-
1
except
RuntimeError
as
e
:
except
RuntimeError
as
e
:
print
(
e
)
print
(
e
)
return
1
return
0
def
test_delitem_iterator_invalidation
():
def
test_delitem_iterator_invalidation
():
"""
"""
>>> test_delitem_iterator_invalidation()
>>> test_delitem_iterator_invalidation()
Modifying a dictionary with active iterators
Modifying a dictionary with active iterators
1
0
"""
"""
d
=
cypdict
[
Index
,
Value
]()
d
=
cypdict
[
Index
,
Value
]()
index
=
Index
(
0
)
index
=
Index
(
0
)
...
@@ -312,16 +312,16 @@ def test_delitem_iterator_invalidation():
...
@@ -312,16 +312,16 @@ def test_delitem_iterator_invalidation():
with
nogil
:
with
nogil
:
del
d
[
index
]
del
d
[
index
]
with
gil
:
with
gil
:
return
0
return
-
1
except
RuntimeError
as
e
:
except
RuntimeError
as
e
:
print
(
e
)
print
(
e
)
return
1
return
0
def
test_clear_iterator_invalidation
():
def
test_clear_iterator_invalidation
():
"""
"""
>>> test_clear_iterator_invalidation()
>>> test_clear_iterator_invalidation()
Modifying a dictionary with active iterators
Modifying a dictionary with active iterators
1
0
"""
"""
d
=
cypdict
[
Index
,
Value
]()
d
=
cypdict
[
Index
,
Value
]()
iterator
=
d
.
begin
()
iterator
=
d
.
begin
()
...
@@ -329,15 +329,15 @@ def test_clear_iterator_invalidation():
...
@@ -329,15 +329,15 @@ def test_clear_iterator_invalidation():
with
nogil
:
with
nogil
:
d
.
clear
()
d
.
clear
()
with
gil
:
with
gil
:
return
0
return
-
1
except
RuntimeError
as
e
:
except
RuntimeError
as
e
:
print
(
e
)
print
(
e
)
return
1
return
0
def
test_modification_after_dict_iterator
():
def
test_modification_after_dict_iterator
():
"""
"""
>>> test_modification_after_dict_iterator()
>>> test_modification_after_dict_iterator()
1
0
"""
"""
d
=
cypdict
[
Index
,
Value
]()
d
=
cypdict
[
Index
,
Value
]()
for
key
in
d
:
for
key
in
d
:
...
@@ -349,15 +349,15 @@ def test_modification_after_dict_iterator():
...
@@ -349,15 +349,15 @@ def test_modification_after_dict_iterator():
del
d
[
index
]
del
d
[
index
]
d
.
clear
()
d
.
clear
()
with
gil
:
with
gil
:
return
1
return
0
except
RuntimeError
as
e
:
except
RuntimeError
as
e
:
print
(
e
)
print
(
e
)
return
0
return
-
1
def
test_modification_after_dict_keys_iterator
():
def
test_modification_after_dict_keys_iterator
():
"""
"""
>>> test_modification_after_dict_keys_iterator()
>>> test_modification_after_dict_keys_iterator()
1
0
"""
"""
d
=
cypdict
[
Index
,
Value
]()
d
=
cypdict
[
Index
,
Value
]()
for
key
in
d
.
keys
():
for
key
in
d
.
keys
():
...
@@ -369,15 +369,15 @@ def test_modification_after_dict_keys_iterator():
...
@@ -369,15 +369,15 @@ def test_modification_after_dict_keys_iterator():
del
d
[
index
]
del
d
[
index
]
d
.
clear
()
d
.
clear
()
with
gil
:
with
gil
:
return
1
return
0
except
RuntimeError
as
e
:
except
RuntimeError
as
e
:
print
(
e
)
print
(
e
)
return
0
return
-
1
def
test_modification_after_dict_values_iterator
():
def
test_modification_after_dict_values_iterator
():
"""
"""
>>> test_modification_after_dict_values_iterator()
>>> test_modification_after_dict_values_iterator()
1
0
"""
"""
d
=
cypdict
[
Index
,
Value
]()
d
=
cypdict
[
Index
,
Value
]()
for
value
in
d
.
values
():
for
value
in
d
.
values
():
...
@@ -389,15 +389,15 @@ def test_modification_after_dict_values_iterator():
...
@@ -389,15 +389,15 @@ def test_modification_after_dict_values_iterator():
del
d
[
index
]
del
d
[
index
]
d
.
clear
()
d
.
clear
()
with
gil
:
with
gil
:
return
1
return
0
except
RuntimeError
as
e
:
except
RuntimeError
as
e
:
print
(
e
)
print
(
e
)
return
0
return
-
1
def
test_modification_after_dict_items_iterator
():
def
test_modification_after_dict_items_iterator
():
"""
"""
>>> test_modification_after_dict_items_iterator()
>>> test_modification_after_dict_items_iterator()
1
0
"""
"""
d
=
cypdict
[
Index
,
Value
]()
d
=
cypdict
[
Index
,
Value
]()
for
item
in
d
.
items
():
for
item
in
d
.
items
():
...
@@ -409,10 +409,10 @@ def test_modification_after_dict_items_iterator():
...
@@ -409,10 +409,10 @@ def test_modification_after_dict_items_iterator():
del
d
[
index
]
del
d
[
index
]
d
.
clear
()
d
.
clear
()
with
gil
:
with
gil
:
return
1
return
0
except
RuntimeError
as
e
:
except
RuntimeError
as
e
:
print
(
e
)
print
(
e
)
return
0
return
-
1
def
test_scalar_types_dict
():
def
test_scalar_types_dict
():
"""
"""
...
@@ -465,51 +465,51 @@ def test_items_destroyed():
...
@@ -465,51 +465,51 @@ def test_items_destroyed():
def
test_items_refcount
():
def
test_items_refcount
():
"""
"""
>>> test_items_refcount()
>>> test_items_refcount()
1
0
"""
"""
d
=
cypdict
[
Index
,
Value
]()
d
=
cypdict
[
Index
,
Value
]()
index
=
Index
()
index
=
Index
()
value
=
Value
()
value
=
Value
()
if
Cy_GETREF
(
index
)
!=
2
:
if
Cy_GETREF
(
index
)
!=
2
:
return
0
return
-
1
if
Cy_GETREF
(
value
)
!=
2
:
if
Cy_GETREF
(
value
)
!=
2
:
return
0
return
-
2
d
[
index
]
=
value
d
[
index
]
=
value
if
Cy_GETREF
(
index
)
!=
3
:
if
Cy_GETREF
(
index
)
!=
3
:
return
0
return
-
3
if
Cy_GETREF
(
value
)
!=
3
:
if
Cy_GETREF
(
value
)
!=
3
:
return
0
return
-
4
del
d
[
index
]
del
d
[
index
]
if
Cy_GETREF
(
index
)
!=
2
:
if
Cy_GETREF
(
index
)
!=
2
:
return
0
return
-
5
if
Cy_GETREF
(
value
)
!=
2
:
if
Cy_GETREF
(
value
)
!=
2
:
return
0
return
-
6
d
[
index
]
=
value
d
[
index
]
=
value
if
Cy_GETREF
(
index
)
!=
3
:
if
Cy_GETREF
(
index
)
!=
3
:
return
0
return
-
7
if
Cy_GETREF
(
value
)
!=
3
:
if
Cy_GETREF
(
value
)
!=
3
:
return
0
return
-
8
d
.
clear
()
d
.
clear
()
if
Cy_GETREF
(
index
)
!=
2
:
if
Cy_GETREF
(
index
)
!=
2
:
return
0
return
-
9
if
Cy_GETREF
(
value
)
!=
2
:
if
Cy_GETREF
(
value
)
!=
2
:
return
0
return
-
1
0
d
[
index
]
=
value
d
[
index
]
=
value
if
Cy_GETREF
(
index
)
!=
3
:
if
Cy_GETREF
(
index
)
!=
3
:
return
0
return
-
11
if
Cy_GETREF
(
value
)
!=
3
:
if
Cy_GETREF
(
value
)
!=
3
:
return
0
return
-
12
d
=
cypdict
[
Index
,
Value
]()
d
=
cypdict
[
Index
,
Value
]()
if
Cy_GETREF
(
index
)
!=
2
:
if
Cy_GETREF
(
index
)
!=
2
:
return
0
return
-
13
if
Cy_GETREF
(
value
)
!=
2
:
if
Cy_GETREF
(
value
)
!=
2
:
return
0
return
-
14
return
1
return
0
def
test_update_refcount
():
def
test_update_refcount
():
"""
"""
>>> test_update_refcount()
>>> test_update_refcount()
1
0
"""
"""
d1
=
cypdict
[
Index
,
Value
]()
d1
=
cypdict
[
Index
,
Value
]()
d2
=
cypdict
[
Index
,
Value
]()
d2
=
cypdict
[
Index
,
Value
]()
...
@@ -523,181 +523,181 @@ def test_update_refcount():
...
@@ -523,181 +523,181 @@ def test_update_refcount():
d2
[
index2
]
=
value2
d2
[
index2
]
=
value2
d2
[
index3
]
=
value3
d2
[
index3
]
=
value3
if
Cy_GETREF
(
index1
)
!=
3
:
if
Cy_GETREF
(
index1
)
!=
3
:
return
0
return
-
1
if
Cy_GETREF
(
value1
)
!=
3
:
if
Cy_GETREF
(
value1
)
!=
3
:
return
0
return
-
2
if
Cy_GETREF
(
index2
)
!=
3
:
if
Cy_GETREF
(
index2
)
!=
3
:
return
0
return
-
3
if
Cy_GETREF
(
value2
)
!=
3
:
if
Cy_GETREF
(
value2
)
!=
3
:
return
0
return
-
4
if
Cy_GETREF
(
index3
)
!=
3
:
if
Cy_GETREF
(
index3
)
!=
3
:
return
0
return
-
5
if
Cy_GETREF
(
value3
)
!=
3
:
if
Cy_GETREF
(
value3
)
!=
3
:
return
0
return
-
6
d1
.
update
(
d2
)
d1
.
update
(
d2
)
if
Cy_GETREF
(
index1
)
!=
3
:
if
Cy_GETREF
(
index1
)
!=
3
:
return
0
return
-
7
if
Cy_GETREF
(
value1
)
!=
3
:
if
Cy_GETREF
(
value1
)
!=
3
:
return
0
return
-
8
if
Cy_GETREF
(
index2
)
!=
4
:
if
Cy_GETREF
(
index2
)
!=
4
:
return
0
return
-
9
if
Cy_GETREF
(
value2
)
!=
4
:
if
Cy_GETREF
(
value2
)
!=
4
:
return
0
return
-
1
0
if
Cy_GETREF
(
index3
)
!=
4
:
if
Cy_GETREF
(
index3
)
!=
4
:
return
0
return
-
11
if
Cy_GETREF
(
value3
)
!=
4
:
if
Cy_GETREF
(
value3
)
!=
4
:
return
0
return
-
12
del
d2
del
d2
if
Cy_GETREF
(
index1
)
!=
3
:
if
Cy_GETREF
(
index1
)
!=
3
:
return
0
return
-
13
if
Cy_GETREF
(
value1
)
!=
3
:
if
Cy_GETREF
(
value1
)
!=
3
:
return
0
return
-
14
if
Cy_GETREF
(
index2
)
!=
3
:
if
Cy_GETREF
(
index2
)
!=
3
:
return
0
return
-
15
if
Cy_GETREF
(
value2
)
!=
3
:
if
Cy_GETREF
(
value2
)
!=
3
:
return
0
return
-
16
if
Cy_GETREF
(
index3
)
!=
3
:
if
Cy_GETREF
(
index3
)
!=
3
:
return
0
return
-
17
if
Cy_GETREF
(
value3
)
!=
3
:
if
Cy_GETREF
(
value3
)
!=
3
:
return
0
return
-
18
del
d1
del
d1
if
Cy_GETREF
(
index1
)
!=
2
:
if
Cy_GETREF
(
index1
)
!=
2
:
return
0
return
-
19
if
Cy_GETREF
(
value1
)
!=
2
:
if
Cy_GETREF
(
value1
)
!=
2
:
return
0
return
-
2
0
if
Cy_GETREF
(
index2
)
!=
2
:
if
Cy_GETREF
(
index2
)
!=
2
:
return
0
return
-
21
if
Cy_GETREF
(
value2
)
!=
2
:
if
Cy_GETREF
(
value2
)
!=
2
:
return
0
return
-
22
if
Cy_GETREF
(
index3
)
!=
2
:
if
Cy_GETREF
(
index3
)
!=
2
:
return
0
return
-
23
if
Cy_GETREF
(
value3
)
!=
2
:
if
Cy_GETREF
(
value3
)
!=
2
:
return
0
return
-
24
return
1
return
0
def
test_view_dict_refcount
():
def
test_view_dict_refcount
():
"""
"""
>>> test_view_dict_refcount()
>>> test_view_dict_refcount()
1
0
"""
"""
d
=
cypdict
[
Index
,
Value
]()
d
=
cypdict
[
Index
,
Value
]()
if
Cy_GETREF
(
d
)
!=
2
:
if
Cy_GETREF
(
d
)
!=
2
:
return
0
return
-
1
def
keys_view
():
def
keys_view
():
key_view
=
d
.
keys
()
key_view
=
d
.
keys
()
if
Cy_GETREF
(
d
)
!=
3
:
if
Cy_GETREF
(
d
)
!=
3
:
return
0
return
-
1
return
1
if
not
keys_view
():
return
0
return
0
if
keys_view
():
return
-
2
if
Cy_GETREF
(
d
)
!=
2
:
if
Cy_GETREF
(
d
)
!=
2
:
return
0
return
-
3
def
values_view
():
def
values_view
():
values_view
=
d
.
values
()
values_view
=
d
.
values
()
if
Cy_GETREF
(
d
)
!=
3
:
if
Cy_GETREF
(
d
)
!=
3
:
return
0
return
-
1
return
1
if
not
values_view
():
return
0
return
0
if
values_view
():
return
-
4
if
Cy_GETREF
(
d
)
!=
2
:
if
Cy_GETREF
(
d
)
!=
2
:
return
0
return
-
5
def
items_view
():
def
items_view
():
items_view
=
d
.
items
()
items_view
=
d
.
items
()
if
Cy_GETREF
(
d
)
!=
3
:
if
Cy_GETREF
(
d
)
!=
3
:
return
0
return
-
1
return
1
if
not
items_view
():
return
0
return
0
if
items_view
():
return
-
6
if
Cy_GETREF
(
d
)
!=
2
:
if
Cy_GETREF
(
d
)
!=
2
:
return
0
return
-
7
return
1
return
0
def
test_iterator_refcount
():
def
test_iterator_refcount
():
"""
"""
>>> test_iterator_refcount()
>>> test_iterator_refcount()
1
0
"""
"""
d
=
cypdict
[
Index
,
Value
]()
d
=
cypdict
[
Index
,
Value
]()
if
Cy_GETREF
(
d
)
!=
2
:
if
Cy_GETREF
(
d
)
!=
2
:
return
0
return
-
1
def
begin_iterator
():
def
begin_iterator
():
it
=
d
.
begin
()
it
=
d
.
begin
()
if
Cy_GETREF
(
d
)
!=
3
:
if
Cy_GETREF
(
d
)
!=
3
:
return
0
return
-
1
return
1
if
not
begin_iterator
():
return
0
return
0
if
begin_iterator
():
return
-
2
if
Cy_GETREF
(
d
)
!=
2
:
if
Cy_GETREF
(
d
)
!=
2
:
return
0
return
-
3
def
end_iterator
():
def
end_iterator
():
it
=
d
.
end
()
it
=
d
.
end
()
if
Cy_GETREF
(
d
)
!=
2
:
if
Cy_GETREF
(
d
)
!=
2
:
return
0
return
-
1
return
1
if
not
end_iterator
():
return
0
return
0
if
end_iterator
():
return
-
4
if
Cy_GETREF
(
d
)
!=
2
:
if
Cy_GETREF
(
d
)
!=
2
:
return
0
return
-
5
def
keys_begin_iterator
():
def
keys_begin_iterator
():
keys
=
d
.
keys
()
keys
=
d
.
keys
()
if
Cy_GETREF
(
d
)
!=
3
:
if
Cy_GETREF
(
d
)
!=
3
:
return
0
return
-
1
it
=
keys
.
begin
()
it
=
keys
.
begin
()
if
Cy_GETREF
(
d
)
!=
4
:
if
Cy_GETREF
(
d
)
!=
4
:
return
0
return
-
2
return
1
if
not
keys_begin_iterator
():
return
0
return
0
if
keys_begin_iterator
():
return
-
6
if
Cy_GETREF
(
d
)
!=
2
:
if
Cy_GETREF
(
d
)
!=
2
:
return
0
return
-
7
def
values_begin_iterator
():
def
values_begin_iterator
():
values
=
d
.
values
()
values
=
d
.
values
()
if
Cy_GETREF
(
d
)
!=
3
:
if
Cy_GETREF
(
d
)
!=
3
:
return
0
return
-
1
it
=
values
.
begin
()
it
=
values
.
begin
()
if
Cy_GETREF
(
d
)
!=
4
:
if
Cy_GETREF
(
d
)
!=
4
:
return
0
return
-
2
return
1
if
not
values_begin_iterator
():
return
0
return
0
if
values_begin_iterator
():
return
-
8
if
Cy_GETREF
(
d
)
!=
2
:
if
Cy_GETREF
(
d
)
!=
2
:
return
0
return
-
9
def
items_begin_iterator
():
def
items_begin_iterator
():
items
=
d
.
items
()
items
=
d
.
items
()
if
Cy_GETREF
(
d
)
!=
3
:
if
Cy_GETREF
(
d
)
!=
3
:
return
0
return
-
1
it
=
items
.
begin
()
it
=
items
.
begin
()
if
Cy_GETREF
(
d
)
!=
4
:
if
Cy_GETREF
(
d
)
!=
4
:
return
0
return
-
2
return
1
if
not
items_begin_iterator
():
return
0
return
0
if
items_begin_iterator
():
return
-
10
if
Cy_GETREF
(
d
)
!=
2
:
if
Cy_GETREF
(
d
)
!=
2
:
return
0
return
-
11
return
1
return
0
tests/run/cypclass_builtin_list.pyx
View file @
13b1a497
...
@@ -59,7 +59,7 @@ def test_nogil_insert_and_iteration():
...
@@ -59,7 +59,7 @@ def test_nogil_insert_and_iteration():
def
test_len
():
def
test_len
():
"""
"""
>>> test_len()
>>> test_len()
1
0
"""
"""
l
=
cyplist
[
Value
]()
l
=
cyplist
[
Value
]()
cdef
long
unsigned
int
nb_elements
=
0
cdef
long
unsigned
int
nb_elements
=
0
...
@@ -68,15 +68,15 @@ def test_len():
...
@@ -68,15 +68,15 @@ def test_len():
for
v
in
l
:
for
v
in
l
:
nb_elements
+=
1
nb_elements
+=
1
if
l
.
__len__
()
!=
nb_elements
:
if
l
.
__len__
()
!=
nb_elements
:
return
0
return
-
1
if
nb_elements
!=
10
:
if
nb_elements
!=
10
:
return
0
return
-
2
return
1
return
0
def
test_clear
():
def
test_clear
():
"""
"""
>>> test_clear()
>>> test_clear()
1
0
"""
"""
l
=
cyplist
[
Value
]()
l
=
cyplist
[
Value
]()
for
i
in
range
(
10
):
for
i
in
range
(
10
):
...
@@ -85,23 +85,23 @@ def test_clear():
...
@@ -85,23 +85,23 @@ def test_clear():
return
-
1
return
-
1
l
.
clear
()
l
.
clear
()
if
l
.
__len__
()
!=
0
:
if
l
.
__len__
()
!=
0
:
return
0
return
-
2
return
1
return
0
def
test_contains
():
def
test_contains
():
"""
"""
>>> test_clear()
>>> test_clear()
1
0
"""
"""
l
=
cyplist
[
Value
]()
l
=
cyplist
[
Value
]()
for
i
in
range
(
10
):
for
i
in
range
(
10
):
value
=
Value
(
i
)
value
=
Value
(
i
)
if
value
in
l
:
if
value
in
l
:
return
0
return
-
1
l
.
append
(
value
)
l
.
append
(
value
)
if
value
not
in
l
:
if
value
not
in
l
:
return
0
return
-
2
return
1
return
0
def
test_add
():
def
test_add
():
"""
"""
...
@@ -157,55 +157,55 @@ def test_getitem_out_of_range():
...
@@ -157,55 +157,55 @@ def test_getitem_out_of_range():
"""
"""
>>> test_getitem_out_of_range()
>>> test_getitem_out_of_range()
Getting list index out of range
Getting list index out of range
1
0
"""
"""
l
=
cyplist
[
Value
]()
l
=
cyplist
[
Value
]()
try
:
try
:
with
nogil
:
with
nogil
:
v
=
l
[
0
]
v
=
l
[
0
]
with
gil
:
with
gil
:
return
0
return
-
1
except
IndexError
as
e
:
except
IndexError
as
e
:
print
(
e
)
print
(
e
)
return
1
return
0
def
test_setitem_out_of_range
():
def
test_setitem_out_of_range
():
"""
"""
>>> test_setitem_out_of_range()
>>> test_setitem_out_of_range()
Setting list index out of range
Setting list index out of range
1
0
"""
"""
l
=
cyplist
[
Value
]()
l
=
cyplist
[
Value
]()
try
:
try
:
with
nogil
:
with
nogil
:
l
[
0
]
=
Value
(
0
)
l
[
0
]
=
Value
(
0
)
with
gil
:
with
gil
:
return
0
return
-
1
except
IndexError
as
e
:
except
IndexError
as
e
:
print
(
e
)
print
(
e
)
return
1
return
0
def
test_delitem_out_of_range
():
def
test_delitem_out_of_range
():
"""
"""
>>> test_delitem_out_of_range()
>>> test_delitem_out_of_range()
Deleting list index out of range
Deleting list index out of range
1
0
"""
"""
l
=
cyplist
[
Value
]()
l
=
cyplist
[
Value
]()
try
:
try
:
with
nogil
:
with
nogil
:
del
l
[
0
]
del
l
[
0
]
with
gil
:
with
gil
:
return
0
return
-
1
except
IndexError
as
e
:
except
IndexError
as
e
:
print
(
e
)
print
(
e
)
return
1
return
0
def
test_append_iterator_invalidation
():
def
test_append_iterator_invalidation
():
"""
"""
>>> test_append_iterator_invalidation()
>>> test_append_iterator_invalidation()
Modifying a list with active iterators
Modifying a list with active iterators
1
0
"""
"""
l
=
cyplist
[
Value
]()
l
=
cyplist
[
Value
]()
iterator
=
l
.
begin
()
iterator
=
l
.
begin
()
...
@@ -213,16 +213,16 @@ def test_append_iterator_invalidation():
...
@@ -213,16 +213,16 @@ def test_append_iterator_invalidation():
with
nogil
:
with
nogil
:
l
.
append
(
Value
(
1
))
l
.
append
(
Value
(
1
))
with
gil
:
with
gil
:
return
0
return
-
1
except
RuntimeError
as
e
:
except
RuntimeError
as
e
:
print
(
e
)
print
(
e
)
return
1
return
0
def
test_insert_iterator_invalidation
():
def
test_insert_iterator_invalidation
():
"""
"""
>>> test_insert_iterator_invalidation()
>>> test_insert_iterator_invalidation()
Modifying a list with active iterators
Modifying a list with active iterators
1
0
"""
"""
l
=
cyplist
[
Value
]()
l
=
cyplist
[
Value
]()
iterator
=
l
.
begin
()
iterator
=
l
.
begin
()
...
@@ -230,16 +230,16 @@ def test_insert_iterator_invalidation():
...
@@ -230,16 +230,16 @@ def test_insert_iterator_invalidation():
with
nogil
:
with
nogil
:
l
.
insert
(
0
,
Value
(
1
))
l
.
insert
(
0
,
Value
(
1
))
with
gil
:
with
gil
:
return
0
return
-
1
except
RuntimeError
as
e
:
except
RuntimeError
as
e
:
print
(
e
)
print
(
e
)
return
1
return
0
def
test_del_iterator_invalidation
():
def
test_del_iterator_invalidation
():
"""
"""
>>> test_del_iterator_invalidation()
>>> test_del_iterator_invalidation()
Modifying a list with active iterators
Modifying a list with active iterators
1
0
"""
"""
l
=
cyplist
[
Value
]()
l
=
cyplist
[
Value
]()
l
.
append
(
Value
(
0
))
l
.
append
(
Value
(
0
))
...
@@ -248,16 +248,16 @@ def test_del_iterator_invalidation():
...
@@ -248,16 +248,16 @@ def test_del_iterator_invalidation():
with
nogil
:
with
nogil
:
del
l
[
0
]
del
l
[
0
]
with
gil
:
with
gil
:
return
0
return
-
1
except
RuntimeError
as
e
:
except
RuntimeError
as
e
:
print
(
e
)
print
(
e
)
return
1
return
0
def
test_clear_iterator_invalidation
():
def
test_clear_iterator_invalidation
():
"""
"""
>>> test_clear_iterator_invalidation()
>>> test_clear_iterator_invalidation()
Modifying a list with active iterators
Modifying a list with active iterators
1
0
"""
"""
l
=
cyplist
[
Value
]()
l
=
cyplist
[
Value
]()
iterator
=
l
.
begin
()
iterator
=
l
.
begin
()
...
@@ -265,15 +265,15 @@ def test_clear_iterator_invalidation():
...
@@ -265,15 +265,15 @@ def test_clear_iterator_invalidation():
with
nogil
:
with
nogil
:
l
.
clear
()
l
.
clear
()
with
gil
:
with
gil
:
return
0
return
-
1
except
RuntimeError
as
e
:
except
RuntimeError
as
e
:
print
(
e
)
print
(
e
)
return
1
return
0
def
test_modification_after_iteration
():
def
test_modification_after_iteration
():
"""
"""
>>> test_modification_after_iteration()
>>> test_modification_after_iteration()
1
0
"""
"""
l
=
cyplist
[
Value
]()
l
=
cyplist
[
Value
]()
for
value
in
l
:
for
value
in
l
:
...
@@ -285,10 +285,10 @@ def test_modification_after_iteration():
...
@@ -285,10 +285,10 @@ def test_modification_after_iteration():
del
l
[
0
]
del
l
[
0
]
l
.
clear
()
l
.
clear
()
with
gil
:
with
gil
:
return
1
return
0
except
RuntimeError
as
e
:
except
RuntimeError
as
e
:
print
(
e
)
print
(
e
)
return
0
return
-
1
def
test_scalar_types_list
():
def
test_scalar_types_list
():
"""
"""
...
@@ -327,101 +327,101 @@ def test_values_destroyed():
...
@@ -327,101 +327,101 @@ def test_values_destroyed():
def
test_values_refcount
():
def
test_values_refcount
():
"""
"""
>>> test_values_refcount()
>>> test_values_refcount()
1
0
"""
"""
l
=
cyplist
[
Value
]()
l
=
cyplist
[
Value
]()
value
=
Value
()
value
=
Value
()
if
Cy_GETREF
(
value
)
!=
2
:
if
Cy_GETREF
(
value
)
!=
2
:
return
0
return
-
1
l
.
append
(
value
)
l
.
append
(
value
)
if
Cy_GETREF
(
value
)
!=
3
:
if
Cy_GETREF
(
value
)
!=
3
:
return
0
return
-
2
l
.
insert
(
0
,
value
)
l
.
insert
(
0
,
value
)
if
Cy_GETREF
(
value
)
!=
4
:
if
Cy_GETREF
(
value
)
!=
4
:
return
0
return
-
3
del
l
[
0
]
del
l
[
0
]
if
Cy_GETREF
(
value
)
!=
3
:
if
Cy_GETREF
(
value
)
!=
3
:
return
0
return
-
4
l
.
clear
()
l
.
clear
()
if
Cy_GETREF
(
value
)
!=
2
:
if
Cy_GETREF
(
value
)
!=
2
:
return
0
return
-
5
l
.
append
(
value
)
l
.
append
(
value
)
if
Cy_GETREF
(
value
)
!=
3
:
if
Cy_GETREF
(
value
)
!=
3
:
return
0
return
-
6
del
l
del
l
if
Cy_GETREF
(
value
)
!=
2
:
if
Cy_GETREF
(
value
)
!=
2
:
return
0
return
-
7
return
1
return
0
def
test_iterator_refcount
():
def
test_iterator_refcount
():
"""
"""
>>> test_iterator_refcount()
>>> test_iterator_refcount()
1
0
"""
"""
l
=
cyplist
[
Value
]()
l
=
cyplist
[
Value
]()
if
Cy_GETREF
(
l
)
!=
2
:
if
Cy_GETREF
(
l
)
!=
2
:
return
0
return
-
1
def
begin_iterator
():
def
begin_iterator
():
it
=
l
.
begin
()
it
=
l
.
begin
()
if
Cy_GETREF
(
l
)
!=
3
:
if
Cy_GETREF
(
l
)
!=
3
:
return
0
return
-
1
return
1
if
not
begin_iterator
():
return
0
return
0
if
begin_iterator
():
return
-
2
if
Cy_GETREF
(
l
)
!=
2
:
if
Cy_GETREF
(
l
)
!=
2
:
return
0
return
-
3
def
end_iterator
():
def
end_iterator
():
it
=
l
.
end
()
it
=
l
.
end
()
if
Cy_GETREF
(
l
)
!=
2
:
if
Cy_GETREF
(
l
)
!=
2
:
return
0
return
-
1
return
1
if
not
end_iterator
():
return
0
return
0
if
end_iterator
():
return
-
4
if
Cy_GETREF
(
l
)
!=
2
:
if
Cy_GETREF
(
l
)
!=
2
:
return
0
return
-
5
return
1
return
0
def
test_concatenation_refcount
():
def
test_concatenation_refcount
():
"""
"""
>>> test_concatenation_refcount()
>>> test_concatenation_refcount()
1
0
"""
"""
value
=
Value
(
1
)
value
=
Value
(
1
)
l1
=
cyplist
[
Value
]()
l1
=
cyplist
[
Value
]()
if
Cy_GETREF
(
value
)
!=
2
:
if
Cy_GETREF
(
value
)
!=
2
:
return
0
return
-
1
l1
.
append
(
value
)
l1
.
append
(
value
)
if
Cy_GETREF
(
value
)
!=
3
:
if
Cy_GETREF
(
value
)
!=
3
:
return
0
return
-
2
l2
=
cyplist
[
Value
]()
l2
=
cyplist
[
Value
]()
l2
.
append
(
value
)
l2
.
append
(
value
)
if
Cy_GETREF
(
value
)
!=
4
:
if
Cy_GETREF
(
value
)
!=
4
:
return
0
return
-
3
l3
=
l1
+
l2
l3
=
l1
+
l2
if
Cy_GETREF
(
value
)
!=
6
:
if
Cy_GETREF
(
value
)
!=
6
:
return
0
return
-
4
l3
+=
l1
l3
+=
l1
if
Cy_GETREF
(
value
)
!=
7
:
if
Cy_GETREF
(
value
)
!=
7
:
return
0
return
-
5
l4
=
l3
*
3
l4
=
l3
*
3
if
Cy_GETREF
(
value
)
!=
16
:
if
Cy_GETREF
(
value
)
!=
16
:
return
0
return
-
6
l4
*=
2
l4
*=
2
if
Cy_GETREF
(
value
)
!=
25
:
if
Cy_GETREF
(
value
)
!=
25
:
return
0
return
-
7
return
1
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