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
c17037bc
Commit
c17037bc
authored
Dec 06, 2009
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
safety fixes for tests under type inference
parent
ff75036d
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
34 additions
and
34 deletions
+34
-34
tests/compile/extcoerce.pyx
tests/compile/extcoerce.pyx
+1
-0
tests/compile/hinsen2.pyx
tests/compile/hinsen2.pyx
+1
-1
tests/run/big_indices.pyx
tests/run/big_indices.pyx
+1
-0
tests/run/buffmt.pyx
tests/run/buffmt.pyx
+3
-3
tests/run/builtinnames.pyx
tests/run/builtinnames.pyx
+10
-0
tests/run/cdef_opt.pyx
tests/run/cdef_opt.pyx
+3
-3
tests/run/cdef_setitem_T284.pyx
tests/run/cdef_setitem_T284.pyx
+2
-2
tests/run/inop.pyx
tests/run/inop.pyx
+6
-8
tests/run/inplace.pyx
tests/run/inplace.pyx
+1
-1
tests/run/isinstance.pyx
tests/run/isinstance.pyx
+1
-7
tests/run/kwargproblems.pyx
tests/run/kwargproblems.pyx
+1
-5
tests/run/longlongindex.pyx
tests/run/longlongindex.pyx
+1
-1
tests/run/pyobjcast_T313.pyx
tests/run/pyobjcast_T313.pyx
+1
-1
tests/run/watts1.pyx
tests/run/watts1.pyx
+2
-2
No files found.
tests/compile/extcoerce.pyx
View file @
c17037bc
...
@@ -9,6 +9,7 @@ cdef class Swallow:
...
@@ -9,6 +9,7 @@ cdef class Swallow:
def
f
(
Grail
g
):
def
f
(
Grail
g
):
cdef
int
i
=
0
cdef
int
i
=
0
cdef
Swallow
s
cdef
Swallow
s
cdef
object
x
g
=
x
g
=
x
x
=
g
x
=
g
g
=
i
g
=
i
...
...
tests/compile/hinsen2.pyx
View file @
c17037bc
cdef
class
vector
:
cdef
class
vector
:
def
__div__
(
vector
self
,
double
factor
):
def
__div__
(
vector
self
,
double
factor
):
result
=
vector
()
cdef
object
result
=
vector
()
return
result
return
result
tests/run/big_indices.pyx
View file @
c17037bc
...
@@ -8,6 +8,7 @@ def test():
...
@@ -8,6 +8,7 @@ def test():
neg
neg
pos
pos
"""
"""
cdef
object
D
cdef
long
neg
=
-
1
cdef
long
neg
=
-
1
cdef
unsigned
long
pos
=
-
2
# will be a large positive number
cdef
unsigned
long
pos
=
-
2
# will be a large positive number
...
...
tests/run/buffmt.pyx
View file @
c17037bc
...
@@ -177,7 +177,7 @@ def char3int(fmt):
...
@@ -177,7 +177,7 @@ def char3int(fmt):
...
...
ValueError: Buffer dtype mismatch, expected 'int' but got end in 'Char3Int.d'
ValueError: Buffer dtype mismatch, expected 'int' but got end in 'Char3Int.d'
"""
"""
obj
=
MockBuffer
(
fmt
,
sizeof
(
Char3Int
))
cdef
object
obj
=
MockBuffer
(
fmt
,
sizeof
(
Char3Int
))
cdef
object
[
Char3Int
,
ndim
=
1
]
buf
=
obj
cdef
object
[
Char3Int
,
ndim
=
1
]
buf
=
obj
@
testcase
@
testcase
...
@@ -195,7 +195,7 @@ def unpacked_struct(fmt):
...
@@ -195,7 +195,7 @@ def unpacked_struct(fmt):
assert
(
sizeof
(
UnpackedStruct1
)
==
sizeof
(
UnpackedStruct2
)
assert
(
sizeof
(
UnpackedStruct1
)
==
sizeof
(
UnpackedStruct2
)
==
sizeof
(
UnpackedStruct3
)
==
sizeof
(
UnpackedStruct4
))
==
sizeof
(
UnpackedStruct3
)
==
sizeof
(
UnpackedStruct4
))
obj
=
MockBuffer
(
fmt
,
sizeof
(
UnpackedStruct1
))
cdef
object
obj
=
MockBuffer
(
fmt
,
sizeof
(
UnpackedStruct1
))
cdef
object
[
UnpackedStruct1
,
ndim
=
1
]
buf1
=
obj
cdef
object
[
UnpackedStruct1
,
ndim
=
1
]
buf1
=
obj
cdef
object
[
UnpackedStruct2
,
ndim
=
1
]
buf2
=
obj
cdef
object
[
UnpackedStruct2
,
ndim
=
1
]
buf2
=
obj
cdef
object
[
UnpackedStruct3
,
ndim
=
1
]
buf3
=
obj
cdef
object
[
UnpackedStruct3
,
ndim
=
1
]
buf3
=
obj
...
@@ -218,7 +218,7 @@ def complex_test(fmt):
...
@@ -218,7 +218,7 @@ def complex_test(fmt):
ValueError: Buffer dtype mismatch, expected 'float' but got 'complex float' in 'ComplexFloat.imag'
ValueError: Buffer dtype mismatch, expected 'float' but got 'complex float' in 'ComplexFloat.imag'
"""
"""
obj
=
MockBuffer
(
fmt
,
sizeof
(
ComplexTest
))
cdef
object
obj
=
MockBuffer
(
fmt
,
sizeof
(
ComplexTest
))
cdef
object
[
ComplexTest
]
buf1
=
obj
cdef
object
[
ComplexTest
]
buf1
=
obj
...
...
tests/run/builtinnames.pyx
View file @
c17037bc
...
@@ -46,3 +46,13 @@ def test_c(arg):
...
@@ -46,3 +46,13 @@ def test_c(arg):
print
test_file_c
(
arg
)
print
test_file_c
(
arg
)
print
len
(
arg
)
print
len
(
arg
)
print
type
(
arg
)
print
type
(
arg
)
def
test_for_in_range
(
arg
):
"""
>>> print(str(test_for_in_range('abc')).replace("u'", "'"))
['r', 'a', 'n', 'g', 'e', 'a', 'b', 'c']
"""
l
=
[]
for
c
in
range
(
arg
):
l
.
append
(
c
)
return
l
tests/run/cdef_opt.pyx
View file @
c17037bc
...
@@ -23,7 +23,7 @@ def call0():
...
@@ -23,7 +23,7 @@ def call0():
>>> call0()
>>> call0()
(True, u'yo')
(True, u'yo')
"""
"""
a
=
A
()
cdef
A
a
=
A
()
return
a
.
foo
()
return
a
.
foo
()
def
call1
():
def
call1
():
...
@@ -31,7 +31,7 @@ def call1():
...
@@ -31,7 +31,7 @@ def call1():
>>> call1()
>>> call1()
(False, u'yo')
(False, u'yo')
"""
"""
a
=
A
()
cdef
A
a
=
A
()
return
a
.
foo
(
False
)
return
a
.
foo
(
False
)
def
call2
():
def
call2
():
...
@@ -39,5 +39,5 @@ def call2():
...
@@ -39,5 +39,5 @@ def call2():
>>> call2()
>>> call2()
(False, u'go')
(False, u'go')
"""
"""
a
=
A
()
cdef
A
a
=
A
()
return
a
.
foo
(
False
,
u"go"
)
return
a
.
foo
(
False
,
u"go"
)
tests/run/cdef_setitem_T284.pyx
View file @
c17037bc
...
@@ -2,10 +2,10 @@ def no_cdef():
...
@@ -2,10 +2,10 @@ def no_cdef():
"""
"""
>>> no_cdef()
>>> no_cdef()
"""
"""
lst
=
list
(
range
(
11
))
cdef
object
lst
=
list
(
range
(
11
))
ob
=
10L
ob
=
10L
lst
[
ob
]
=
-
10
lst
[
ob
]
=
-
10
dd
=
{}
cdef
object
dd
=
{}
dd
[
ob
]
=
-
10
dd
[
ob
]
=
-
10
def
with_cdef
():
def
with_cdef
():
...
...
tests/run/inop.pyx
View file @
c17037bc
...
@@ -7,7 +7,7 @@ def f(a,b):
...
@@ -7,7 +7,7 @@ def f(a,b):
>>> f(2,(1,2,3))
>>> f(2,(1,2,3))
True
True
"""
"""
result
=
a
in
b
cdef
object
result
=
a
in
b
return
result
return
result
def
g
(
a
,
b
):
def
g
(
a
,
b
):
...
@@ -19,8 +19,7 @@ def g(a,b):
...
@@ -19,8 +19,7 @@ def g(a,b):
>>> g(2,(1,2,3))
>>> g(2,(1,2,3))
1
1
"""
"""
cdef
int
result
cdef
int
result
=
a
in
b
result
=
a
in
b
return
result
return
result
def
h
(
b
):
def
h
(
b
):
...
@@ -30,7 +29,7 @@ def h(b):
...
@@ -30,7 +29,7 @@ def h(b):
>>> h([1,3,4])
>>> h([1,3,4])
False
False
"""
"""
result
=
2
in
b
cdef
object
result
=
2
in
b
return
result
return
result
def
j
(
b
):
def
j
(
b
):
...
@@ -40,8 +39,7 @@ def j(b):
...
@@ -40,8 +39,7 @@ def j(b):
>>> j([1,3,4])
>>> j([1,3,4])
0
0
"""
"""
cdef
int
result
cdef
int
result
=
2
in
b
result
=
2
in
b
return
result
return
result
def
k
(
a
):
def
k
(
a
):
...
@@ -104,8 +102,8 @@ def r(a):
...
@@ -104,8 +102,8 @@ def r(a):
>>> r(2)
>>> r(2)
1
1
"""
"""
l
=
[
1
,
2
,
3
,
4
]
cdef
object
l
=
[
1
,
2
,
3
,
4
]
l2
=
[
l
[
1
:],
l
[:
-
1
],
l
]
cdef
object
l2
=
[
l
[
1
:],
l
[:
-
1
],
l
]
cdef
int
result
=
a
in
l
in
l2
cdef
int
result
=
a
in
l
in
l2
return
result
return
result
...
...
tests/run/inplace.pyx
View file @
c17037bc
...
@@ -107,7 +107,7 @@ def test_side_effects():
...
@@ -107,7 +107,7 @@ def test_side_effects():
c side effect 4
c side effect 4
([0, 11, 102, 3, 4], [0, 1, 2, 13, 104])
([0, 11, 102, 3, 4], [0, 1, 2, 13, 104])
"""
"""
a
=
list
(
range
(
5
))
cdef
object
a
=
list
(
range
(
5
))
a
[
side_effect
(
1
)]
+=
10
a
[
side_effect
(
1
)]
+=
10
a
[
c_side_effect
(
2
)]
+=
100
a
[
c_side_effect
(
2
)]
+=
100
cdef
int
i
cdef
int
i
...
...
tests/run/isinstance.pyx
View file @
c17037bc
cdef
class
A
:
cdef
class
A
:
pass
pass
import
sys
IS_PY3
=
sys
.
version_info
[
0
]
>=
3
def
test_all
():
def
test_all
():
"""
"""
>>> test_all()
>>> test_all()
True
True
"""
"""
if
IS_PY3
:
new_type
=
type
(
'a'
,(),{})
new_type
=
type
(
u'a'
,(),{})
else
:
new_type
=
type
(
'a'
,(),{})
# Optimized tests.
# Optimized tests.
assert
isinstance
(
new_type
,
type
)
assert
isinstance
(
new_type
,
type
)
...
...
tests/run/kwargproblems.pyx
View file @
c17037bc
import
sys
def
test
(
**
kw
):
def
test
(
**
kw
):
"""
"""
...
@@ -19,8 +18,5 @@ def test(**kw):
...
@@ -19,8 +18,5 @@ def test(**kw):
>>> d
>>> d
{'arg': 2}
{'arg': 2}
"""
"""
if
sys
.
version_info
[
0
]
>=
3
:
kw
[
'arg'
]
=
3
kw
[
u'arg'
]
=
3
else
:
kw
[
'arg'
]
=
3
return
kw
return
kw
tests/run/longlongindex.pyx
View file @
c17037bc
...
@@ -11,7 +11,7 @@ __doc__ = u"""
...
@@ -11,7 +11,7 @@ __doc__ = u"""
ctypedef
long
long
foo
ctypedef
long
long
foo
def
set_longlong
(
long
long
ob
,
foo
x
,
long
y
,
val
):
def
set_longlong
(
long
long
ob
,
foo
x
,
long
y
,
val
):
tank
=
{}
cdef
object
tank
=
{}
tank
[
ob
]
=
val
tank
[
ob
]
=
val
tank
[
x
]
=
val
tank
[
x
]
=
val
tank
[
y
]
=
val
tank
[
y
]
=
val
...
...
tests/run/pyobjcast_T313.pyx
View file @
c17037bc
...
@@ -14,7 +14,7 @@ cdef extern from *:
...
@@ -14,7 +14,7 @@ cdef extern from *:
def
f
():
def
f
():
cdef
void
*
p1
cdef
void
*
p1
cdef
PyObject
*
p2
cdef
PyObject
*
p2
a
=
u"teststring"
cdef
object
a
=
u"teststring"
p1
=
<
void
*>
a
p1
=
<
void
*>
a
p2
=
<
PyObject
*>
a
p2
=
<
PyObject
*>
a
return
(
<
object
>
p1
,
<
object
>
p2
)
return
(
<
object
>
p1
,
<
object
>
p2
)
tests/run/watts1.pyx
View file @
c17037bc
...
@@ -4,6 +4,6 @@ def test():
...
@@ -4,6 +4,6 @@ def test():
True
True
"""
"""
cdef
int
a
,
b
cdef
int
a
,
b
foo
=
(
55
,
66
)
cdef
object
foo
=
(
55
,
66
)
a
,
b
=
foo
a
,
b
=
foo
return
a
+
b
return
a
+
b
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