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
c3fc785a
Commit
c3fc785a
authored
May 16, 2009
by
Lisandro Dalcin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix some tests for Python 3
parent
a8a6cd02
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
42 additions
and
37 deletions
+42
-37
tests/run/cdef_setitem_T284.pyx
tests/run/cdef_setitem_T284.pyx
+5
-5
tests/run/char_constants_T99.pyx
tests/run/char_constants_T99.pyx
+2
-2
tests/run/for_from_float_T254.pyx
tests/run/for_from_float_T254.pyx
+5
-5
tests/run/pyobjcast_T313.pyx
tests/run/pyobjcast_T313.pyx
+6
-3
tests/run/range_optimisation_T203.pyx
tests/run/range_optimisation_T203.pyx
+14
-14
tests/run/typed_slice.pyx
tests/run/typed_slice.pyx
+10
-8
No files found.
tests/run/cdef_setitem_T284.pyx
View file @
c3fc785a
__doc__
=
u'''
>>> no_cdef()
>>> with_cdef()
>>> test_list(
range(11
), -2, None)
>>> test_list(
list(range(11)
), -2, None)
[0, 1, 2, 3, 4, 5, 6, 7, 8, None, 10]
>>> test_list(
range(11), "invalid index", None)
>>> test_list(
list(range(11)), "invalid index", None) #doctest: +ELLIPSIS
Traceback (most recent call last):
...
TypeError: list indices must be integers
TypeError: list indices must be integers
...
'''
def
no_cdef
():
lst
=
range
(
11
)
lst
=
list
(
range
(
11
)
)
ob
=
10L
lst
[
ob
]
=
-
10
dd
=
{}
dd
[
ob
]
=
-
10
def
with_cdef
():
cdef
list
lst
=
range
(
11
)
cdef
list
lst
=
list
(
range
(
11
)
)
ob
=
10L
lst
[
ob
]
=
-
10
cdef
dict
dd
=
{}
...
...
tests/run/char_constants_T99.pyx
View file @
c3fc785a
...
...
@@ -14,11 +14,11 @@ cdef char* s = 'abcdef'
def
global_c_and_s
():
pys
=
s
print
c
print
pys
.
decode
(
'ASCII'
)
print
(
pys
.
decode
(
u'ASCII'
)
)
def
local_c_and_s
():
cdef
char
c
=
'b'
cdef
char
*
s
=
'bcdefg'
pys
=
s
print
c
print
pys
.
decode
(
'ASCII'
)
print
(
pys
.
decode
(
u'ASCII'
)
)
tests/run/for_from_float_T254.pyx
View file @
c3fc785a
...
...
@@ -32,29 +32,29 @@ __doc__ = u"""
def
double_target
(
a
,
b
):
cdef
double
x
for
x
from
a
<=
x
<
b
:
print
"at"
,
x
print
u
"at"
,
x
return
x
def
double_step
(
a
,
b
,
dx
):
cdef
double
x
for
x
from
a
<=
x
<
b
by
dx
:
print
"at"
,
x
print
u
"at"
,
x
return
x
def
double_step_typed
(
a
,
b
,
double
dx
):
cdef
double
x
for
x
from
a
<=
x
<
b
by
dx
:
print
"at"
,
x
print
u
"at"
,
x
return
x
def
double_step_py_target
(
a
,
b
,
double
dx
):
cdef
object
x
for
x
from
a
<=
x
<
b
by
dx
:
print
"at"
,
x
print
u
"at"
,
x
return
x
def
int_step_py_target
(
a
,
b
,
int
dx
):
cdef
object
x
for
x
from
a
<=
x
<
b
by
dx
:
print
"at"
,
x
print
u
"at"
,
x
return
x
tests/run/pyobjcast_T313.pyx
View file @
c3fc785a
# Ensure casting still works to void*
"""
>>> f()
('teststring', 'teststring')
>>> o = f()
>>> print(o[0])
teststring
>>> print(o[1])
teststring
"""
cdef
extern
from
*
:
...
...
@@ -11,7 +14,7 @@ cdef extern from *:
def
f
():
cdef
void
*
p1
cdef
PyObject
*
p2
a
=
"teststring"
a
=
u
"teststring"
p1
=
<
void
*>
a
p2
=
<
PyObject
*>
a
return
(
<
object
>
p1
,
<
object
>
p2
)
...
...
tests/run/range_optimisation_T203.pyx
View file @
c3fc785a
...
...
@@ -74,66 +74,66 @@ at 4
5
"""
cdef
int
get_bound
(
int
m
):
print
"get_bound(%s)"
%
m
print
u
"get_bound(%s)"
%
m
return
m
def
for_from_range
(
a
,
b
):
cdef
int
i
=
100
print
"range(%s)"
%
a
print
u
"range(%s)"
%
a
for
i
in
range
(
a
):
print
"at"
,
i
print
"range(%s, %s)"
%
(
a
,
b
)
print
u
"at"
,
i
print
u
"range(%s, %s)"
%
(
a
,
b
)
for
i
in
range
(
a
,
b
):
print
"at"
,
i
print
"range(%s, %s, %s)"
%
(
a
,
b
,
2
)
print
u
"at"
,
i
print
u
"range(%s, %s, %s)"
%
(
a
,
b
,
2
)
for
i
in
range
(
a
,
b
,
2
):
print
"at"
,
i
print
u
"at"
,
i
return
i
def
for_from_bound_reassignment
(
int
bound
,
int
fake_bound
):
cdef
int
i
=
100
for
i
from
0
<=
i
<
bound
:
print
"at"
,
i
print
u
"at"
,
i
bound
=
fake_bound
return
i
def
for_from_step_reassignment
(
int
bound
,
int
step
,
int
fake_step
):
cdef
int
i
=
100
for
i
from
0
<=
i
<
bound
by
step
:
print
"at"
,
i
print
u
"at"
,
i
step
=
fake_step
return
i
def
for_from_target_reassignment
(
int
bound
,
int
factor
):
cdef
int
i
=
100
for
i
from
0
<=
i
<
bound
:
print
"at"
,
i
print
u
"at"
,
i
i
*=
factor
return
i
def
for_from_py_target_reassignment
(
int
bound
,
int
factor
):
cdef
object
i
for
i
from
0
<=
i
<
bound
:
print
"at"
,
i
print
u
"at"
,
i
i
*=
factor
return
i
def
for_from_py_global_target_reassignment
(
int
bound
,
int
factor
):
global
g_var
for
g_var
from
0
<=
g_var
<
bound
:
print
"at"
,
g_var
print
u
"at"
,
g_var
g_var
*=
factor
return
g_var
def
for_in_target_reassignment
(
int
bound
,
int
factor
):
cdef
int
i
=
100
for
i
in
range
(
bound
):
print
"at"
,
i
print
u
"at"
,
i
i
*=
factor
return
i
def
test_func
(
int
n
):
cdef
int
i
=
100
for
i
from
0
<=
i
<
get_bound
(
n
):
print
"at"
,
i
print
u
"at"
,
i
return
i
tests/run/typed_slice.pyx
View file @
c3fc785a
...
...
@@ -22,10 +22,10 @@ __doc__ = u"""
>>> slice_list_assign(l2, dict(zip(l,l)))
[1, 1, 2, 3, 4, 4]
>>>
slice_charp('abcdefg'
)
'bc'
>>>
slice_charp_repeat('abcdefg'
)
'cd'
>>>
print("%s" % slice_charp('abcdefg')
)
bc
>>>
print("%s" % slice_charp_repeat('abcdefg')
)
cd
"""
def
slice_list
(
list
l
):
...
...
@@ -51,12 +51,14 @@ def slice_list_assign(list l, value):
return
l
def
slice_charp
(
str
py_string
):
def
slice_charp
(
py_string_arg
):
cdef
str
py_string
=
py_string_arg
.
encode
(
u'ASCII'
)
cdef
char
*
s
=
py_string
return
s
[
1
:
3
]
return
s
[
1
:
3
]
.
decode
(
u'ASCII'
)
def
slice_charp_repeat
(
str
py_string
):
def
slice_charp_repeat
(
py_string_arg
):
cdef
str
py_string
=
py_string_arg
.
encode
(
u'ASCII'
)
cdef
char
*
s
=
py_string
cdef
str
slice_val
=
s
[
1
:
6
]
s
=
slice_val
return
s
[
1
:
3
]
return
s
[
1
:
3
]
.
decode
(
u'ASCII'
)
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