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
Gwenaël Samain
cython
Commits
d127f1eb
Commit
d127f1eb
authored
Mar 04, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extended test case
parent
f7d30514
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
0 deletions
+54
-0
tests/run/parallel_swap_assign_T425.pyx
tests/run/parallel_swap_assign_T425.pyx
+54
-0
No files found.
tests/run/parallel_swap_assign_T425.pyx
View file @
d127f1eb
...
@@ -107,6 +107,60 @@ def swap_attr_values(A a, A b):
...
@@ -107,6 +107,60 @@ def swap_attr_values(A a, A b):
a
.
x
,
a
.
y
,
b
.
x
,
b
.
y
=
b
.
y
,
b
.
x
,
a
.
y
,
a
.
x
# reverse
a
.
x
,
a
.
y
,
b
.
x
,
b
.
y
=
b
.
y
,
b
.
x
,
a
.
y
,
a
.
x
# reverse
cdef
class
B
:
cdef
readonly
A
a1
cdef
readonly
A
a2
def
__init__
(
self
,
x1
,
y1
,
x2
,
y2
):
self
.
a1
,
self
.
a2
=
A
(
x1
,
y1
),
A
(
x2
,
y2
)
@
cython
.
test_assert_path_exists
(
"//ParallelAssignmentNode"
,
"//ParallelAssignmentNode/SingleAssignmentNode"
,
"//ParallelAssignmentNode/SingleAssignmentNode/CoerceToTempNode"
,
"//ParallelAssignmentNode/SingleAssignmentNode/CoerceToTempNode[@use_managed_ref=False]"
,
"//ParallelAssignmentNode/SingleAssignmentNode//AttributeNode/NameNode"
,
"//ParallelAssignmentNode/SingleAssignmentNode//AttributeNode[@use_managed_ref=False]/NameNode"
,
)
@
cython
.
test_fail_if_path_exists
(
"//ParallelAssignmentNode/SingleAssignmentNode/CoerceToTempNode[@use_managed_ref=True]"
,
"//ParallelAssignmentNode/SingleAssignmentNode/AttributeNode[@use_managed_ref=True]"
,
)
def
swap_recursive_attr_values
(
B
a
,
B
b
):
"""
>>> a, b = B(1,2,3,4), B(5,6,7,8)
>>> a.a1.x, a.a1.y, a.a2.x, a.a2.y
(1, 2, 3, 4)
>>> b.a1.x, b.a1.y, b.a2.x, b.a2.y
(5, 6, 7, 8)
>>> swap_recursive_attr_values(a,b)
>>> a.a1.x, a.a1.y, a.a2.x, a.a2.y
(2, 1, 4, 4)
>>> b.a1.x, b.a1.y, b.a2.x, b.a2.y
(6, 5, 8, 8)
# compatibility test
>>> class A:
... def __init__(self, x, y):
... self.x, self.y = x, y
>>> class B:
... def __init__(self, x1, y1, x2, y2):
... self.a1, self.a2 = A(x1, y1), A(x2, y2)
>>> a, b = B(1,2,3,4), B(5,6,7,8)
>>> a.a1, a.a2 = a.a2, a.a1
>>> b.a1, b.a2 = b.a2, b.a1
>>> a.a1, a.a1.x, a.a2.y, a.a2, a.a1.y, a.a2.x = a.a2, a.a2.y, a.a1.x, a.a1, a.a2.x, a.a1.y
>>> b.a1, b.a1.x, b.a2.y, b.a2, b.a1.y, b.a2.x = b.a2, b.a2.y, b.a1.x, b.a1, b.a2.x, b.a1.y
>>> a.a1.x, a.a1.y, a.a2.x, a.a2.y
(2, 1, 4, 4)
>>> b.a1.x, b.a1.y, b.a2.x, b.a2.y
(6, 5, 8, 8)
"""
a
.
a1
,
a
.
a2
=
a
.
a2
,
a
.
a1
b
.
a1
,
b
.
a2
=
b
.
a2
,
b
.
a1
a
.
a1
,
a
.
a1
.
x
,
a
.
a2
.
y
,
a
.
a2
,
a
.
a1
.
y
,
a
.
a2
.
x
=
a
.
a2
,
a
.
a2
.
y
,
a
.
a1
.
x
,
a
.
a1
,
a
.
a2
.
x
,
a
.
a1
.
y
b
.
a1
,
b
.
a1
.
x
,
b
.
a2
.
y
,
b
.
a2
,
b
.
a1
.
y
,
b
.
a2
.
x
=
b
.
a2
,
b
.
a2
.
y
,
b
.
a1
.
x
,
b
.
a1
,
b
.
a2
.
x
,
b
.
a1
.
y
@
cython
.
test_assert_path_exists
(
@
cython
.
test_assert_path_exists
(
# "//ParallelAssignmentNode",
# "//ParallelAssignmentNode",
# "//ParallelAssignmentNode/SingleAssignmentNode",
# "//ParallelAssignmentNode/SingleAssignmentNode",
...
...
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