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
Kirill Smelkov
cython
Commits
f2a2f905
Commit
f2a2f905
authored
Oct 21, 2009
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extended test case
parent
9f118eb6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
17 deletions
+57
-17
tests/run/parallel_swap_assign_T425.pyx
tests/run/parallel_swap_assign_T425.pyx
+57
-17
No files found.
tests/run/parallel_swap_assign_T425.pyx
View file @
f2a2f905
__doc__
=
u"""
>>> swap(1,2)
(2, 1)
>>> l = [1,2,3,4]
>>> swap_list_items(l, 1, 2)
>>> l
[1, 3, 2, 4]
>>> swap_list_items(l, 3, 0)
>>> l
[4, 3, 2, 1]
>>> swap_list_items(l, 0, 5)
Traceback (most recent call last):
IndexError: list index out of range
>>> l
[4, 3, 2, 1]
"""
cimport
cython
...
...
@@ -28,10 +11,53 @@ cimport cython
"//ParallelAssignmentNode/SingleAssignmentNode//CoerceToTempNode[@use_managed_ref=True]"
,
)
def
swap
(
a
,
b
):
"""
>>> swap(1,2)
(2, 1)
"""
a
,
b
=
b
,
a
return
a
,
b
@
cython
.
test_assert_path_exists
(
"//ParallelAssignmentNode"
,
"//ParallelAssignmentNode/SingleAssignmentNode"
,
"//ParallelAssignmentNode/SingleAssignmentNode//CoerceToTempNode/NameNode"
,
"//ParallelAssignmentNode/SingleAssignmentNode//CoerceToTempNode[@use_managed_ref=False]/NameNode"
,
)
@
cython
.
test_fail_if_path_exists
(
"//ParallelAssignmentNode/SingleAssignmentNode//CoerceToTempNode[@use_managed_ref=True]"
,
)
def
swap5
(
a
,
b
,
c
,
d
,
e
):
"""
>>> swap5(1,2,3,4,5)
(5, 4, 3, 2, 1)
"""
a
,
b
,
c
,
d
,
e
=
e
,
d
,
c
,
b
,
a
return
a
,
b
,
c
,
d
,
e
@
cython
.
test_assert_path_exists
(
"//ParallelAssignmentNode"
,
"//ParallelAssignmentNode/SingleAssignmentNode"
,
"//ParallelAssignmentNode/SingleAssignmentNode//CoerceToTempNode/NameNode"
,
"//ParallelAssignmentNode/SingleAssignmentNode//CoerceToTempNode[@use_managed_ref=False]/NameNode"
,
)
@
cython
.
test_fail_if_path_exists
(
"//ParallelAssignmentNode/SingleAssignmentNode//CoerceToTempNode[@use_managed_ref=True]"
,
)
cdef
bint
c_swap_cmp5
(
a
,
b
,
c
,
d
,
e
):
a
,
b
,
c
,
d
,
e
=
e
,
d
,
c
,
b
,
a
return
a
>
b
>
c
>
d
>
e
def
swap_cmp5
(
a
,
b
,
c
,
d
,
e
):
"""
>>> swap_cmp5(1,2,3,4,5)
True
"""
return
c_swap_cmp5
(
a
,
b
,
c
,
d
,
e
)
@
cython
.
test_assert_path_exists
(
"//ParallelAssignmentNode"
,
"//ParallelAssignmentNode/SingleAssignmentNode"
,
...
...
@@ -56,6 +82,20 @@ def swap_py(a,b):
# "//ParallelAssignmentNode/SingleAssignmentNode//IndexNode[@use_managed_ref=True]",
)
def
swap_list_items
(
list
a
,
int
i
,
int
j
):
"""
>>> l = [1,2,3,4]
>>> swap_list_items(l, 1, 2)
>>> l
[1, 3, 2, 4]
>>> swap_list_items(l, 3, 0)
>>> l
[4, 3, 2, 1]
>>> swap_list_items(l, 0, 5)
Traceback (most recent call last):
IndexError: list index out of range
>>> l
[4, 3, 2, 1]
"""
a
[
i
],
a
[
j
]
=
a
[
j
],
a
[
i
]
...
...
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