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
Boxiang Sun
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
Hide 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
# mode: run
# tag: list, tuple, slice, slicing
# tag: list, tuple, slice, slicing
cimport
cython
@
cython
.
test_fail_if_path_exists
(
"//CondExprNode"
)
def
slice_list
(
list
l
,
int
start
,
int
stop
):
def
slice_list
(
list
l
,
int
start
,
int
stop
):
"""
"""
>>> slice_list([1,2,3,4], 1, 3)
>>> slice_list([1,2,3,4], 1, 3)
...
@@ -22,6 +26,7 @@ def slice_list(list l, int start, int stop):
...
@@ -22,6 +26,7 @@ def slice_list(list l, int start, int stop):
"""
"""
return
l
[
start
:
stop
]
return
l
[
start
:
stop
]
@
cython
.
test_fail_if_path_exists
(
"//CondExprNode"
)
def
slice_list_start
(
list
l
,
int
start
):
def
slice_list_start
(
list
l
,
int
start
):
"""
"""
>>> slice_list_start([1,2,3,4], 1)
>>> slice_list_start([1,2,3,4], 1)
...
@@ -44,6 +49,7 @@ def slice_list_start(list l, int start):
...
@@ -44,6 +49,7 @@ def slice_list_start(list l, int start):
return
l
[
start
:]
return
l
[
start
:]
@
cython
.
test_fail_if_path_exists
(
"//CondExprNode"
)
def
slice_list_stop
(
list
l
,
int
stop
):
def
slice_list_stop
(
list
l
,
int
stop
):
"""
"""
>>> slice_list_stop([1,2,3,4], 3)
>>> slice_list_stop([1,2,3,4], 3)
...
@@ -68,6 +74,7 @@ def slice_list_stop(list l, int stop):
...
@@ -68,6 +74,7 @@ def slice_list_stop(list l, int stop):
return
l
[:
stop
]
return
l
[:
stop
]
@
cython
.
test_fail_if_path_exists
(
"//CondExprNode"
)
def
slice_list_copy
(
list
l
):
def
slice_list_copy
(
list
l
):
"""
"""
>>> slice_list_copy([])
>>> slice_list_copy([])
...
@@ -78,6 +85,7 @@ def slice_list_copy(list l):
...
@@ -78,6 +85,7 @@ def slice_list_copy(list l):
return
l
[:]
return
l
[:]
@
cython
.
test_fail_if_path_exists
(
"//CondExprNode"
)
def
slice_tuple_copy
(
tuple
l
):
def
slice_tuple_copy
(
tuple
l
):
"""
"""
>>> slice_tuple_copy(())
>>> slice_tuple_copy(())
...
@@ -88,6 +96,7 @@ def slice_tuple_copy(tuple l):
...
@@ -88,6 +96,7 @@ def slice_tuple_copy(tuple l):
return
l
[:]
return
l
[:]
@
cython
.
test_fail_if_path_exists
(
"//CondExprNode"
)
def
slice_tuple
(
tuple
t
,
int
start
,
int
stop
):
def
slice_tuple
(
tuple
t
,
int
start
,
int
stop
):
"""
"""
>>> slice_tuple((1,2,3,4), 1, 3)
>>> slice_tuple((1,2,3,4), 1, 3)
...
@@ -110,6 +119,7 @@ def slice_tuple(tuple t, int start, int stop):
...
@@ -110,6 +119,7 @@ def slice_tuple(tuple t, int start, int stop):
return
t
[
start
:
stop
]
return
t
[
start
:
stop
]
@
cython
.
test_fail_if_path_exists
(
"//CondExprNode"
)
def
slice_tuple_start
(
tuple
t
,
int
start
):
def
slice_tuple_start
(
tuple
t
,
int
start
):
"""
"""
>>> slice_tuple_start((1,2,3,4), 1)
>>> slice_tuple_start((1,2,3,4), 1)
...
@@ -129,6 +139,8 @@ def slice_tuple_start(tuple t, int start):
...
@@ -129,6 +139,8 @@ def slice_tuple_start(tuple t, int start):
"""
"""
return
t
[
start
:]
return
t
[
start
:]
@
cython
.
test_fail_if_path_exists
(
"//CondExprNode"
)
def
slice_tuple_stop
(
tuple
t
,
int
stop
):
def
slice_tuple_stop
(
tuple
t
,
int
stop
):
"""
"""
>>> slice_tuple_stop((1,2,3,4), 3)
>>> slice_tuple_stop((1,2,3,4), 3)
...
@@ -147,6 +159,7 @@ def slice_tuple_stop(tuple t, int stop):
...
@@ -147,6 +159,7 @@ def slice_tuple_stop(tuple t, int stop):
return
t
[:
stop
]
return
t
[:
stop
]
@
cython
.
test_fail_if_path_exists
(
"//CondExprNode"
)
def
slice_list_assign_list
(
list
l
):
def
slice_list_assign_list
(
list
l
):
"""
"""
>>> l = [1,2,3,4]
>>> l = [1,2,3,4]
...
@@ -158,6 +171,7 @@ def slice_list_assign_list(list l):
...
@@ -158,6 +171,7 @@ def slice_list_assign_list(list l):
return
l
return
l
@
cython
.
test_fail_if_path_exists
(
"//CondExprNode"
)
def
slice_list_assign_tuple
(
list
l
):
def
slice_list_assign_tuple
(
list
l
):
"""
"""
>>> l = [1,2,3,4]
>>> l = [1,2,3,4]
...
@@ -169,6 +183,7 @@ def slice_list_assign_tuple(list l):
...
@@ -169,6 +183,7 @@ def slice_list_assign_tuple(list l):
return
l
return
l
@
cython
.
test_fail_if_path_exists
(
"//CondExprNode"
)
def
slice_list_assign
(
list
l
,
value
):
def
slice_list_assign
(
list
l
,
value
):
"""
"""
>>> l = [1,2,3,4]
>>> l = [1,2,3,4]
...
@@ -204,6 +219,7 @@ def slice_charp_repeat(py_string_arg):
...
@@ -204,6 +219,7 @@ def slice_charp_repeat(py_string_arg):
s
=
slice_val
s
=
slice_val
return
s
[
1
:
3
].
decode
(
u'ASCII'
)
return
s
[
1
:
3
].
decode
(
u'ASCII'
)
# Readers will find the common boilerplate in the tests below:
# Readers will find the common boilerplate in the tests below:
# >>> l = [1,2,3,4,5]
# >>> l = [1,2,3,4,5]
# >>> t = tuple(l)
# >>> t = tuple(l)
...
@@ -227,6 +243,8 @@ ctypedef fused slicable:
...
@@ -227,6 +243,8 @@ ctypedef fused slicable:
bytes
bytes
unicode
unicode
@
cython
.
test_assert_path_exists
(
"//SliceIndexNode//CondExprNode"
)
def
slice_fused_type_start
(
slicable
seq
,
start
):
def
slice_fused_type_start
(
slicable
seq
,
start
):
"""
"""
>>> l = [1,2,3,4,5]
>>> l = [1,2,3,4,5]
...
@@ -269,6 +287,8 @@ def slice_fused_type_start(slicable seq, start):
...
@@ -269,6 +287,8 @@ def slice_fused_type_start(slicable seq, start):
obj
=
seq
[
start
:]
obj
=
seq
[
start
:]
return
obj
return
obj
@
cython
.
test_assert_path_exists
(
"//SliceIndexNode//CondExprNode"
)
def
slice_fused_type_stop
(
slicable
seq
,
stop
):
def
slice_fused_type_stop
(
slicable
seq
,
stop
):
"""
"""
>>> l = [1,2,3,4,5]
>>> l = [1,2,3,4,5]
...
@@ -311,6 +331,8 @@ def slice_fused_type_stop(slicable seq, stop):
...
@@ -311,6 +331,8 @@ def slice_fused_type_stop(slicable seq, stop):
obj
=
seq
[:
stop
]
obj
=
seq
[:
stop
]
return
obj
return
obj
@
cython
.
test_assert_path_exists
(
"//SliceIndexNode//CondExprNode"
)
def
slice_fused_type_start_and_stop
(
slicable
seq
,
start
,
stop
):
def
slice_fused_type_start_and_stop
(
slicable
seq
,
start
,
stop
):
"""
"""
>>> l = [1,2,3,4,5]
>>> l = [1,2,3,4,5]
...
@@ -354,6 +376,7 @@ def slice_fused_type_start_and_stop(slicable seq, start, stop):
...
@@ -354,6 +376,7 @@ def slice_fused_type_start_and_stop(slicable seq, start, stop):
obj
=
seq
[
start
:
stop
]
obj
=
seq
[
start
:
stop
]
return
obj
return
obj
def
slice_fused_type_step
(
slicable
seq
,
step
):
def
slice_fused_type_step
(
slicable
seq
,
step
):
"""
"""
>>> l = [1,2,3,4,5]
>>> l = [1,2,3,4,5]
...
@@ -405,6 +428,7 @@ def slice_fused_type_step(slicable seq, step):
...
@@ -405,6 +428,7 @@ def slice_fused_type_step(slicable seq, step):
obj
=
seq
[::
step
]
obj
=
seq
[::
step
]
return
obj
return
obj
def
slice_fused_type_start_and_step
(
slicable
seq
,
start
,
step
):
def
slice_fused_type_start_and_step
(
slicable
seq
,
start
,
step
):
"""
"""
>>> l = [1,2,3,4,5]
>>> l = [1,2,3,4,5]
...
@@ -468,6 +492,7 @@ def slice_fused_type_start_and_step(slicable seq, start, step):
...
@@ -468,6 +492,7 @@ def slice_fused_type_start_and_step(slicable seq, start, step):
obj
=
seq
[
start
::
step
]
obj
=
seq
[
start
::
step
]
return
obj
return
obj
def
slice_fused_type_stop_and_step
(
slicable
seq
,
stop
,
step
):
def
slice_fused_type_stop_and_step
(
slicable
seq
,
stop
,
step
):
"""
"""
>>> l = [1,2,3,4,5]
>>> l = [1,2,3,4,5]
...
@@ -521,6 +546,7 @@ def slice_fused_type_stop_and_step(slicable seq, stop, step):
...
@@ -521,6 +546,7 @@ def slice_fused_type_stop_and_step(slicable seq, stop, step):
obj
=
seq
[:
stop
:
step
]
obj
=
seq
[:
stop
:
step
]
return
obj
return
obj
def
slice_fused_type_all
(
slicable
seq
,
start
,
stop
,
step
):
def
slice_fused_type_all
(
slicable
seq
,
start
,
stop
,
step
):
"""
"""
>>> l = [1,2,3,4,5]
>>> 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