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
3fbd62b7
Commit
3fbd62b7
authored
Jan 30, 2010
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tests for ticket #445.
parent
9d1317a6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
+47
-0
tests/run/complex_cast_T445.pyx
tests/run/complex_cast_T445.pyx
+47
-0
No files found.
tests/run/complex_cast_T445.pyx
0 → 100644
View file @
3fbd62b7
def
complex_double_cast
(
double
x
,
double
complex
z
):
"""
>>> complex_double_cast(1, 4-3j)
((1+0j), (4-3j))
"""
cdef
double
complex
xx
=
<
double
complex
>
x
cdef
double
complex
zz
=
<
double
complex
>
z
xx
=
x
return
xx
,
zz
def
complex_double_int_cast
(
int
x
,
int
complex
z
):
"""
>>> complex_double_int_cast(2, 2 + 3j)
((2+0j), (3+3j))
"""
cdef
double
complex
xx
=
<
double
complex
>
x
cdef
double
complex
zz
=
<
double
complex
>
(
z
+
1
)
return
xx
,
zz
def
complex_int_double_cast
(
double
x
,
double
complex
z
):
"""
>>> complex_int_double_cast(2.5, 2.5 + 3.5j)
((2+0j), (2+3j))
"""
cdef
int
complex
xx
=
<
int
complex
>
x
cdef
int
complex
zz
=
<
int
complex
>
z
return
xx
,
zz
cdef
int
side_effect_counter
=
0
cdef
double
complex
side_effect
(
double
complex
z
):
global
side_effect_counter
side_effect_counter
+=
1
print
"side effect"
,
side_effect_counter
,
z
return
z
def
test_side_effect
(
int
complex
z
):
"""
>>> test_side_effect(5)
side effect 1 (5+0j)
(5+0j)
>>> test_side_effect(3-4j)
side effect 2 (3-4j)
(3-4j)
"""
cdef
int
complex
zz
=
<
int
complex
>
side_effect
(
z
)
return
zz
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