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
ec09b000
Commit
ec09b000
authored
Nov 13, 2008
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test case for array slice assignments
parent
17b5c93e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
98 additions
and
0 deletions
+98
-0
tests/run/arrayassign.pyx
tests/run/arrayassign.pyx
+98
-0
No files found.
tests/run/arrayassign.pyx
0 → 100644
View file @
ec09b000
__doc__
=
u"""
>>> test_literal_list_slice_all()
(1, 2, 3, 4, 5)
>>> test_literal_list_slice_start()
(1, 2, 3, 4, 5)
>>> test_literal_list_slice_end()
(1, 2, 3, 4, 5)
>>> test_literal_list_slice_start_end()
(1, 2, 3, 4, 5)
>>> test_literal_list_slice_start_param(2)
(1, 2, 3, 4, 5)
>>> test_literal_list_slice_end_param(4)
(1, 2, 3, 4, 5)
>>> test_literal_list_slice_start_end_param(2,7)
(1, 2, 3, 4, 5)
>>> test_ptr_literal_list_slice_all()
(1, 2, 3, 4, 5)
>>> test_ptr_literal_list_slice_start()
(1, 2, 3, 4, 5)
>>> test_ptr_literal_list_slice_end()
(1, 2, 3, 4, 5)
"""
# this doesn't work - it would reassign the array address!
#
#def test_literal_list():
# cdef int a[5]
# a = [1,2,3,4,5]
# return (a[0], a[1], a[2], a[3], a[4])
def
test_literal_list_slice_all
():
cdef
int
a
[
5
]
# = [5,4,3,2,1]
a
[:]
=
[
1
,
2
,
3
,
4
,
5
]
return
(
a
[
0
],
a
[
1
],
a
[
2
],
a
[
3
],
a
[
4
])
def
test_literal_list_slice_start
():
cdef
int
a
[
7
]
# = [7,6,5,4,3,2,1]
a
[
2
:]
=
[
1
,
2
,
3
,
4
,
5
]
return
(
a
[
2
],
a
[
3
],
a
[
4
],
a
[
5
],
a
[
6
])
def
test_literal_list_slice_end
():
cdef
int
a
[
7
]
# = [7,6,5,4,3,2,1]
a
[:
5
]
=
[
1
,
2
,
3
,
4
,
5
]
return
(
a
[
0
],
a
[
1
],
a
[
2
],
a
[
3
],
a
[
4
])
def
test_literal_list_slice_start_end
():
cdef
int
a
[
9
]
# = [9,8,7,6,5,4,3,2,1]
a
[
2
:
7
]
=
[
1
,
2
,
3
,
4
,
5
]
return
(
a
[
2
],
a
[
3
],
a
[
4
],
a
[
5
],
a
[
6
])
def
test_literal_list_slice_start_param
(
s
):
cdef
int
a
[
9
]
# = [9,8,7,6,5,4,3,2,1]
a
[
s
:]
=
[
1
,
2
,
3
,
4
,
5
]
return
(
a
[
2
],
a
[
3
],
a
[
4
],
a
[
5
],
a
[
6
])
# return a[s:]
def
test_literal_list_slice_end_param
(
e
):
cdef
int
a
[
9
]
# = [9,8,7,6,5,4,3,2,1]
a
[:
e
]
=
[
1
,
2
,
3
,
4
,
5
]
return
(
a
[
0
],
a
[
1
],
a
[
2
],
a
[
3
],
a
[
4
])
# return a[:e]
def
test_literal_list_slice_start_end_param
(
s
,
e
):
cdef
int
a
[
9
]
# = [9,8,7,6,5,4,3,2,1]
a
[
s
:
e
]
=
[
1
,
2
,
3
,
4
,
5
]
return
(
a
[
2
],
a
[
3
],
a
[
4
],
a
[
5
],
a
[
6
])
# return a[s:e]
def
test_ptr_literal_list_slice_all
():
cdef
int
*
a
=
[
6
,
5
,
4
,
3
,
2
]
a
[:]
=
[
1
,
2
,
3
,
4
,
5
]
return
(
a
[
0
],
a
[
1
],
a
[
2
],
a
[
3
],
a
[
4
])
def
test_ptr_literal_list_slice_start
():
cdef
int
*
a
=
[
6
,
5
,
4
,
3
,
2
,
1
]
a
[
1
:]
=
[
1
,
2
,
3
,
4
,
5
]
return
(
a
[
1
],
a
[
2
],
a
[
3
],
a
[
4
],
a
[
5
])
def
test_ptr_literal_list_slice_end
():
cdef
int
*
a
=
[
6
,
5
,
4
,
3
,
2
,
1
]
a
[:
5
]
=
[
1
,
2
,
3
,
4
,
5
]
return
(
a
[
0
],
a
[
1
],
a
[
2
],
a
[
3
],
a
[
4
])
# tuples aren't supported (yet)
#
#def test_literal_tuple():
# cdef int a[5]
# a = (1,2,3,4,5)
# return (a[0], a[1], a[2], a[3], a[4])
# this would be nice to have:
#
#def test_list(list l):
# cdef int a[5]
# a[:] = l
# return (a[0], a[1], a[2], a[3], a[4])
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