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
749415a1
Commit
749415a1
authored
Dec 29, 2014
by
root
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated test cases for reversed iteration.
parent
cab1d35c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
157 additions
and
6 deletions
+157
-6
tests/errors/reversed_literal_pyobjs.pyx
tests/errors/reversed_literal_pyobjs.pyx
+31
-0
tests/run/reversed_iteration.pyx
tests/run/reversed_iteration.pyx
+126
-6
No files found.
tests/errors/reversed_literal_pyobjs.pyx
0 → 100644
View file @
749415a1
# mode: error
# tag: reversed
cdef
int
i
,
j
for
i
in
reversed
(
range
([],
j
,
2
)):
pass
for
i
in
reversed
(
range
([],
j
,
-
2
)):
pass
for
i
in
reversed
(
range
(
j
,
[],
2
)):
pass
for
i
in
reversed
(
range
(
j
,
[],
-
2
)):
pass
for
i
in
reversed
(
range
({},
j
,
2
)):
pass
for
i
in
reversed
(
range
({},
j
,
-
2
)):
pass
for
i
in
reversed
(
range
(
j
,
{},
2
)):
pass
for
i
in
reversed
(
range
(
j
,
{},
-
2
)):
pass
_ERRORS
=
"""
5:24: Cannot coerce list to type 'long'
7:24: Cannot coerce list to type 'long'
9:27: Cannot coerce list to type 'long'
11:27: Cannot coerce list to type 'long'
13:24: Cannot interpret dict as type 'long'
15:24: Cannot interpret dict as type 'long'
17:27: Cannot interpret dict as type 'long'
19:27: Cannot interpret dict as type 'long'
"""
tests/run/reversed_iteration.pyx
View file @
749415a1
...
...
@@ -133,7 +133,6 @@ def reversed_range_step_neg(int a, int b):
result
.
append
(
i
)
return
result
,
i
@
cython
.
test_assert_path_exists
(
'//ForFromStatNode'
)
@
cython
.
test_fail_if_path_exists
(
'//ForInStatNode'
)
def
reversed_range_step3
(
int
a
,
int
b
):
...
...
@@ -152,6 +151,11 @@ def reversed_range_step3(int a, int b):
[]
>>> reversed_range_step3(5, 0)
([], 99)
>>> [ i for i in _reversed(range(1, 1, 3)) ]
[]
>>> reversed_range_step3(1, 1)
([], 99)
"""
cdef
int
i
=
99
result
=
[]
...
...
@@ -159,7 +163,6 @@ def reversed_range_step3(int a, int b):
result
.
append
(
i
)
return
result
,
i
@
cython
.
test_assert_path_exists
(
'//ForFromStatNode'
)
@
cython
.
test_fail_if_path_exists
(
'//ForInStatNode'
)
def
reversed_range_step3_neg
(
int
a
,
int
b
):
...
...
@@ -178,6 +181,11 @@ def reversed_range_step3_neg(int a, int b):
[]
>>> reversed_range_step3_neg(0, 5)
([], 99)
>>> [ i for i in _reversed(range(1, 1, -3)) ]
[]
>>> reversed_range_step3_neg(1, 1)
([], 99)
"""
cdef
int
i
=
99
result
=
[]
...
...
@@ -185,8 +193,122 @@ def reversed_range_step3_neg(int a, int b):
result
.
append
(
i
)
return
result
,
i
def
reversed_range_step3_py_args
(
a
,
b
):
"""
>>> [ i for i in _reversed(range(-5, 0, 3)) ]
[-2, -5]
>>> reversed_range_step3_py_args(-5, 0)
([-2, -5], -5)
>>> [ i for i in _reversed(range(0, 5, 3)) ]
[3, 0]
>>> reversed_range_step3_py_args(0, 5)
([3, 0], 0)
>>> [ i for i in _reversed(range(5, 0, 3)) ]
[]
>>> reversed_range_step3_py_args(5, 0)
([], 99)
>>> [ i for i in _reversed(range(1, 1, 3)) ]
[]
>>> reversed_range_step3_py_args(1, 1)
([], 99)
>>> reversed_range_step3_py_args(set(), 1)
Traceback (most recent call last):
TypeError: range() integer start argument expected, got set.
>>> reversed_range_step3_py_args(1, set())
Traceback (most recent call last):
TypeError: range() integer end argument expected, got set.
"""
i
=
99
result
=
[]
for
i
in
reversed
(
range
(
a
,
b
,
3
)):
result
.
append
(
i
)
return
result
,
i
def
reversed_range_step3_neg_py_args
(
a
,
b
):
"""
>>> [ i for i in _reversed(range(0, -5, -3)) ]
[-3, 0]
>>> reversed_range_step3_neg_py_args(0, -5)
([-3, 0], 0)
>>> [ i for i in _reversed(range(5, 0, -3)) ]
[2, 5]
>>> reversed_range_step3_neg_py_args(5, 0)
([2, 5], 5)
>>> [ i for i in _reversed(range(0, 5, -3)) ]
[]
>>> reversed_range_step3_neg_py_args(0, 5)
([], 99)
>>> [ i for i in _reversed(range(1, 1, -3)) ]
[]
>>> reversed_range_step3_neg_py_args(1, 1)
([], 99)
>>> reversed_range_step3_neg_py_args(set(), 1)
Traceback (most recent call last):
TypeError: range() integer start argument expected, got set.
>>> reversed_range_step3_neg_py_args(1, set())
Traceback (most recent call last):
TypeError: range() integer end argument expected, got set.
"""
i
=
99
result
=
[]
for
i
in
reversed
(
range
(
a
,
b
,
-
3
)):
result
.
append
(
i
)
return
result
,
i
def
reversed_range_step3_py_obj_left
(
a
,
int
b
):
"""
>>> reversed_range_step3_py_obj_left(set(), 0)
Traceback (most recent call last):
TypeError: an integer is required
"""
cdef
int
i
result
=
[]
for
i
in
reversed
(
range
(
a
,
b
,
3
)):
result
.
append
(
i
)
def
reversed_range_step3_py_obj_right
(
int
a
,
b
):
"""
>>> reversed_range_step3_py_obj_right(0, set())
Traceback (most recent call last):
TypeError: an integer is required
"""
cdef
int
i
result
=
[]
for
i
in
reversed
(
range
(
a
,
b
,
3
)):
result
.
append
(
i
)
def
reversed_range_step3_neg_py_obj_left
(
a
,
int
b
):
"""
>>> reversed_range_step3_neg_py_obj_left(set(), 0)
Traceback (most recent call last):
TypeError: an integer is required
"""
cdef
int
i
result
=
[]
for
i
in
reversed
(
range
(
a
,
b
,
-
3
)):
result
.
append
(
i
)
def
reversed_range_step3_neg_py_obj_right
(
int
a
,
b
):
"""
>>> reversed_range_step3_py_obj_right(0, set())
Traceback (most recent call last):
TypeError: an integer is required
"""
cdef
int
i
result
=
[]
for
i
in
reversed
(
range
(
a
,
b
,
-
3
)):
result
.
append
(
i
)
@
cython
.
test_assert_path_exists
(
'//ForFromStatNode'
)
@
cython
.
test_fail_if_path_exists
(
'//ForInStatNode'
)
def
reversed_range_constant
():
"""
...
...
@@ -202,7 +324,6 @@ def reversed_range_constant():
assert
result
==
list
(
reversed
(
range
(
1
,
1
,
4
))),
result
assert
i
==
99
result
=
[]
for
i
in
reversed
(
range
(
1
,
1
,
1
)):
result
.
append
(
i
)
assert
result
==
list
(
reversed
(
range
(
1
,
1
,
1
))),
result
...
...
@@ -272,13 +393,13 @@ def reversed_range_constant():
result
.
append
(
i
)
assert
result
==
list
(
reversed
(
range
(
0
,
12
,
4
))),
result
i
=
99
result
=
[]
for
i
in
reversed
(
range
(
-
12
,
-
2
,
4
)):
result
.
append
(
i
)
assert
result
==
list
(
reversed
(
range
(
-
12
,
-
2
,
4
))),
result
return
result
,
i
@
cython
.
test_assert_path_exists
(
'//ForFromStatNode'
)
@
cython
.
test_fail_if_path_exists
(
'//ForInStatNode'
)
def
reversed_range_constant_neg
():
...
...
@@ -414,7 +535,6 @@ def reversed_range_constant_neg():
result
.
append
(
i
)
assert
result
==
list
(
reversed
(
range
(
-
2
,
-
12
,
-
1
))),
result
unicode_string
=
u"abcDEF"
@
cython
.
test_assert_path_exists
(
'//ForFromStatNode'
)
...
...
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