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
e56bc6a1
Commit
e56bc6a1
authored
Sep 07, 2018
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tighten the new 2-item slicing tests by asserting a specific tree structure.
parent
c6177dfd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
tests/run/typed_slice.pyx
tests/run/typed_slice.pyx
+26
-0
No files found.
tests/run/typed_slice.pyx
View file @
e56bc6a1
# mode: run
# tag: list, tuple, slice, slicing
cimport
cython
@
cython
.
test_fail_if_path_exists
(
"//CondExprNode"
)
def
slice_list
(
list
l
,
int
start
,
int
stop
):
"""
>>> slice_list([1,2,3,4], 1, 3)
...
...
@@ -22,6 +26,7 @@ def slice_list(list l, int start, int stop):
"""
return
l
[
start
:
stop
]
@
cython
.
test_fail_if_path_exists
(
"//CondExprNode"
)
def
slice_list_start
(
list
l
,
int
start
):
"""
>>> slice_list_start([1,2,3,4], 1)
...
...
@@ -44,6 +49,7 @@ def slice_list_start(list l, int start):
return
l
[
start
:]
@
cython
.
test_fail_if_path_exists
(
"//CondExprNode"
)
def
slice_list_stop
(
list
l
,
int
stop
):
"""
>>> slice_list_stop([1,2,3,4], 3)
...
...
@@ -68,6 +74,7 @@ def slice_list_stop(list l, int stop):
return
l
[:
stop
]
@
cython
.
test_fail_if_path_exists
(
"//CondExprNode"
)
def
slice_list_copy
(
list
l
):
"""
>>> slice_list_copy([])
...
...
@@ -78,6 +85,7 @@ def slice_list_copy(list l):
return
l
[:]
@
cython
.
test_fail_if_path_exists
(
"//CondExprNode"
)
def
slice_tuple_copy
(
tuple
l
):
"""
>>> slice_tuple_copy(())
...
...
@@ -88,6 +96,7 @@ def slice_tuple_copy(tuple l):
return
l
[:]
@
cython
.
test_fail_if_path_exists
(
"//CondExprNode"
)
def
slice_tuple
(
tuple
t
,
int
start
,
int
stop
):
"""
>>> slice_tuple((1,2,3,4), 1, 3)
...
...
@@ -110,6 +119,7 @@ def slice_tuple(tuple t, int start, int stop):
return
t
[
start
:
stop
]
@
cython
.
test_fail_if_path_exists
(
"//CondExprNode"
)
def
slice_tuple_start
(
tuple
t
,
int
start
):
"""
>>> slice_tuple_start((1,2,3,4), 1)
...
...
@@ -129,6 +139,8 @@ def slice_tuple_start(tuple t, int start):
"""
return
t
[
start
:]
@
cython
.
test_fail_if_path_exists
(
"//CondExprNode"
)
def
slice_tuple_stop
(
tuple
t
,
int
stop
):
"""
>>> slice_tuple_stop((1,2,3,4), 3)
...
...
@@ -147,6 +159,7 @@ def slice_tuple_stop(tuple t, int stop):
return
t
[:
stop
]
@
cython
.
test_fail_if_path_exists
(
"//CondExprNode"
)
def
slice_list_assign_list
(
list
l
):
"""
>>> l = [1,2,3,4]
...
...
@@ -158,6 +171,7 @@ def slice_list_assign_list(list l):
return
l
@
cython
.
test_fail_if_path_exists
(
"//CondExprNode"
)
def
slice_list_assign_tuple
(
list
l
):
"""
>>> l = [1,2,3,4]
...
...
@@ -169,6 +183,7 @@ def slice_list_assign_tuple(list l):
return
l
@
cython
.
test_fail_if_path_exists
(
"//CondExprNode"
)
def
slice_list_assign
(
list
l
,
value
):
"""
>>> l = [1,2,3,4]
...
...
@@ -204,6 +219,7 @@ def slice_charp_repeat(py_string_arg):
s
=
slice_val
return
s
[
1
:
3
].
decode
(
u'ASCII'
)
# Readers will find the common boilerplate in the tests below:
# >>> l = [1,2,3,4,5]
# >>> t = tuple(l)
...
...
@@ -227,6 +243,8 @@ ctypedef fused slicable:
bytes
unicode
@
cython
.
test_assert_path_exists
(
"//SliceIndexNode//CondExprNode"
)
def
slice_fused_type_start
(
slicable
seq
,
start
):
"""
>>> l = [1,2,3,4,5]
...
...
@@ -269,6 +287,8 @@ def slice_fused_type_start(slicable seq, start):
obj
=
seq
[
start
:]
return
obj
@
cython
.
test_assert_path_exists
(
"//SliceIndexNode//CondExprNode"
)
def
slice_fused_type_stop
(
slicable
seq
,
stop
):
"""
>>> l = [1,2,3,4,5]
...
...
@@ -311,6 +331,8 @@ def slice_fused_type_stop(slicable seq, stop):
obj
=
seq
[:
stop
]
return
obj
@
cython
.
test_assert_path_exists
(
"//SliceIndexNode//CondExprNode"
)
def
slice_fused_type_start_and_stop
(
slicable
seq
,
start
,
stop
):
"""
>>> l = [1,2,3,4,5]
...
...
@@ -354,6 +376,7 @@ def slice_fused_type_start_and_stop(slicable seq, start, stop):
obj
=
seq
[
start
:
stop
]
return
obj
def
slice_fused_type_step
(
slicable
seq
,
step
):
"""
>>> l = [1,2,3,4,5]
...
...
@@ -405,6 +428,7 @@ def slice_fused_type_step(slicable seq, step):
obj
=
seq
[::
step
]
return
obj
def
slice_fused_type_start_and_step
(
slicable
seq
,
start
,
step
):
"""
>>> l = [1,2,3,4,5]
...
...
@@ -468,6 +492,7 @@ def slice_fused_type_start_and_step(slicable seq, start, step):
obj
=
seq
[
start
::
step
]
return
obj
def
slice_fused_type_stop_and_step
(
slicable
seq
,
stop
,
step
):
"""
>>> l = [1,2,3,4,5]
...
...
@@ -521,6 +546,7 @@ def slice_fused_type_stop_and_step(slicable seq, stop, step):
obj
=
seq
[:
stop
:
step
]
return
obj
def
slice_fused_type_all
(
slicable
seq
,
start
,
stop
,
step
):
"""
>>> l = [1,2,3,4,5]
...
...
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