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
78df7dc4
Commit
78df7dc4
authored
Jan 01, 2008
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
loads of doctests
parent
b488c7c5
Changes
37
Hide whitespace changes
Inline
Side-by-side
Showing
37 changed files
with
491 additions
and
34 deletions
+491
-34
tests/compile/classmethargdefault.pyx
tests/compile/classmethargdefault.pyx
+17
-2
tests/compile/pinard4.pyx
tests/compile/pinard4.pyx
+6
-0
tests/run/addop.pyx
tests/run/addop.pyx
+7
-1
tests/run/ass2local.pyx
tests/run/ass2local.pyx
+6
-0
tests/run/bishop1.pyx
tests/run/bishop1.pyx
+13
-0
tests/run/boolop.pyx
tests/run/boolop.pyx
+12
-1
tests/run/classpass.pyx
tests/run/classpass.pyx
+11
-0
tests/run/concatcstrings.pyx
tests/run/concatcstrings.pyx
+5
-0
tests/run/cstringmul.pyx
tests/run/cstringmul.pyx
+9
-2
tests/run/cvardef.pyx
tests/run/cvardef.pyx
+4
-0
tests/run/exarkun.pyx
tests/run/exarkun.pyx
+16
-2
tests/run/extclasspass.pyx
tests/run/extclasspass.pyx
+6
-1
tests/run/extinstantiate.pyx
tests/run/extinstantiate.pyx
+6
-0
tests/run/if.pyx
tests/run/if.pyx
+33
-4
tests/run/ishimoto3.pyx
tests/run/ishimoto3.pyx
+10
-0
tests/run/kostyrka.pyx
tests/run/kostyrka.pyx
+6
-0
tests/run/kostyrka2.pyx
tests/run/kostyrka2.pyx
+6
-0
tests/run/lepage_1.pyx
tests/run/lepage_1.pyx
+18
-0
tests/run/list.pyx
tests/run/list.pyx
+26
-1
tests/run/literals.pyx
tests/run/literals.pyx
+4
-0
tests/run/multass.pyx
tests/run/multass.pyx
+31
-3
tests/run/pass.pyx
tests/run/pass.pyx
+4
-0
tests/run/pinard6.pyx
tests/run/pinard6.pyx
+5
-0
tests/run/pinard8.pyx
tests/run/pinard8.pyx
+21
-0
tests/run/print.pyx
tests/run/print.pyx
+9
-1
tests/run/pyintop.pyx
tests/run/pyintop.pyx
+32
-5
tests/run/r_jiba1.pyx
tests/run/r_jiba1.pyx
+13
-5
tests/run/r_mcintyre1.pyx
tests/run/r_mcintyre1.pyx
+8
-0
tests/run/r_mitch_chapman_2.pyx
tests/run/r_mitch_chapman_2.pyx
+5
-0
tests/run/r_vree_1.pyx
tests/run/r_vree_1.pyx
+13
-0
tests/run/rodriguez_1.pyx
tests/run/rodriguez_1.pyx
+6
-0
tests/run/simpcall.pyx
tests/run/simpcall.pyx
+23
-3
tests/run/slice2.pyx
tests/run/slice2.pyx
+30
-0
tests/run/strconstinclass.pyx
tests/run/strconstinclass.pyx
+6
-0
tests/run/tuple.pyx
tests/run/tuple.pyx
+46
-0
tests/run/unop.pyx
tests/run/unop.pyx
+11
-1
tests/run/unpack.pyx
tests/run/unpack.pyx
+7
-2
No files found.
tests/compile/classmethargdefault.pyx
View file @
78df7dc4
__doc__
=
"""
>>> s = Swallow()
>>> s.spam(1)
1 42 'grail' True
>>> s.spam(1, 2)
1 2 'grail' True
>>> s.spam(1, z = 2)
1 42 'grail' 2
>>> s.spam(1, y = 2)
1 42 2 True
>>> s.spam(1, x = 2, y = 'test')
1 2 'test' True
"""
swallow
=
True
class
Swallow
:
class
Swallow
:
def
spam
(
w
,
int
x
=
42
,
y
=
"grail"
,
z
=
swallow
):
def
spam
(
w
,
int
x
=
42
,
y
=
"grail"
,
z
=
swallow
):
pass
print
w
,
x
,
y
,
z
tests/compile/pinard4.pyx
View file @
78df7dc4
__doc__
=
"""
>>> fiches_CP
[]
"""
fiches_CP
=
[
1
,
2
,
3
]
fiches_CP
[:]
=
[]
fiches_CP
[:]
=
[]
tests/run/addop.pyx
View file @
78df7dc4
__doc__
=
"""
>>>
"""
def
f
():
def
f
():
cdef
int
int1
,
int2
,
int3
cdef
int
int1
,
int2
,
int3
cdef
char
*
ptr1
,
*
ptr2
,
*
ptr3
cdef
char
*
ptr1
,
*
ptr2
,
*
ptr3
int2
=
10
int3
=
20
obj1
=
1
obj1
=
1
obj2
=
2
obj2
=
2
obj3
=
3
obj3
=
3
...
@@ -8,4 +14,4 @@ def f():
...
@@ -8,4 +14,4 @@ def f():
ptr1
=
ptr2
+
int3
ptr1
=
ptr2
+
int3
ptr1
=
int2
+
ptr3
ptr1
=
int2
+
ptr3
obj1
=
obj2
+
int3
obj1
=
obj2
+
int3
return
int1
,
obj1
\ No newline at end of file
tests/run/ass2local.pyx
View file @
78df7dc4
__doc__
=
"""
>>> f()
42
"""
def
f
():
def
f
():
a
=
42
a
=
42
return
a
tests/run/bishop1.pyx
View file @
78df7dc4
__doc__
=
"""
>>> m = fmatrix()
>>> m[1] = True
>>> m.getfoo()
1
>>> m[0] = True
>>> m.getfoo()
0
"""
cdef
class
fmatrix
:
cdef
class
fmatrix
:
cdef
int
foo
cdef
int
foo
...
@@ -6,3 +16,6 @@ cdef class fmatrix:
...
@@ -6,3 +16,6 @@ cdef class fmatrix:
self
.
foo
=
value
self
.
foo
=
value
return
return
self
.
foo
=
not
value
self
.
foo
=
not
value
def
getfoo
(
self
):
return
self
.
foo
tests/run/boolop.pyx
View file @
78df7dc4
cdef
void
foo
(
obj1
,
obj2
,
obj3
,
obj4
,
obj5
):
__doc__
=
"""
>>> foo(True, False, 23, 'test', 1)
(0, 1, False, False)
"""
def
foo
(
obj1
,
obj2
,
obj3
,
obj4
,
obj5
):
cdef
int
bool1
,
bool2
,
bool3
,
bool4
cdef
int
bool1
,
bool2
,
bool3
,
bool4
cdef
char
*
ptr
cdef
char
*
ptr
cdef
float
f
cdef
float
f
bool1
=
1
bool2
=
0
ptr
=
NULL
f
=
0.0
bool3
=
bool1
and
bool2
bool3
=
bool1
and
bool2
bool3
=
bool1
or
bool2
bool3
=
bool1
or
bool2
bool3
=
obj1
and
obj2
bool3
=
obj1
and
obj2
...
@@ -11,3 +21,4 @@ cdef void foo(obj1, obj2, obj3, obj4, obj5):
...
@@ -11,3 +21,4 @@ cdef void foo(obj1, obj2, obj3, obj4, obj5):
bool4
=
bool1
or
bool2
and
bool3
bool4
=
bool1
or
bool2
and
bool3
obj4
=
obj1
and
obj2
and
obj3
obj4
=
obj1
and
obj2
and
obj3
obj5
=
(
obj1
+
obj2
+
obj3
)
and
obj4
obj5
=
(
obj1
+
obj2
+
obj3
)
and
obj4
return
bool3
,
bool4
,
obj4
,
obj5
tests/run/classpass.pyx
View file @
78df7dc4
__doc__
=
"""
>>> s = Spam()
>>> print s.__class__.__name__
Spam
>>> s = SpamT()
>>> print type(s).__name__
SpamT
"""
class
Spam
:
pass
class
Spam
:
pass
class
SpamT
(
object
):
pass
tests/run/concatcstrings.pyx
View file @
78df7dc4
__doc__
=
"""
>>> spam == "C string 1" + "C string 2"
True
"""
spam
=
"C string 1"
+
"C string 2"
spam
=
"C string 1"
+
"C string 2"
tests/run/cstringmul.pyx
View file @
78df7dc4
spam
=
"eggs"
*
42
__doc__
=
"""
grail
=
17
*
"tomato"
>>> print spam
eggseggseggseggs
>>> print grail
tomatotomatotomatotomatotomatotomatotomato
"""
spam
=
"eggs"
*
4
grail
=
7
*
"tomato"
tests/run/cvardef.pyx
View file @
78df7dc4
__doc__
=
"""
>>> f()
"""
def
f
():
def
f
():
cdef
char
a_char
cdef
char
a_char
cdef
short
a_short
cdef
short
a_short
...
...
tests/run/exarkun.pyx
View file @
78df7dc4
__doc__
=
"""
>>> p = Point(1,2,3)
>>> p.gettuple()
(1.0, 2.0, 3.0)
>>> q = p + Point(2,3,4)
>>> q.gettuple()
(3.0, 5.0, 7.0)
>>> p.gettuple()
(1.0, 2.0, 3.0)
"""
cdef
class
Point
:
cdef
class
Point
:
cdef
double
x
,
y
,
z
cdef
double
x
,
y
,
z
def
__init__
(
self
,
double
x
,
double
y
,
double
z
):
def
__init__
(
self
,
double
x
,
double
y
,
double
z
):
...
@@ -5,6 +16,9 @@ cdef class Point:
...
@@ -5,6 +16,9 @@ cdef class Point:
self
.
y
=
y
self
.
y
=
y
self
.
z
=
z
self
.
z
=
z
# XXX
# XXX
: originally, this said "def __add__(self, other)"
def
__add__
(
self
,
other
):
def
__add__
(
Point
self
,
Point
other
):
return
Point
(
self
.
x
+
other
.
x
,
self
.
y
+
other
.
y
,
self
.
z
+
other
.
z
)
return
Point
(
self
.
x
+
other
.
x
,
self
.
y
+
other
.
y
,
self
.
z
+
other
.
z
)
def
gettuple
(
self
):
return
(
self
.
x
,
self
.
y
,
self
.
z
)
tests/run/extclasspass.pyx
View file @
78df7dc4
cdef
class
Eggs
:
pass
__doc__
=
"""
>>> e = Eggs()
>>> print type(e).__name__
Eggs
"""
cdef
class
Eggs
:
pass
tests/run/extinstantiate.pyx
View file @
78df7dc4
__doc__
=
"""
>>> print type(f()).__name__
Spam
"""
cdef
class
Spam
:
cdef
class
Spam
:
pass
pass
def
f
():
def
f
():
s
=
Spam
()
s
=
Spam
()
return
s
tests/run/if.pyx
View file @
78df7dc4
__doc__
=
"""
>>> f(0,0)
0
>>> f(1,2)
2
>>> f(1,-1)
1
>>> g(1,2)
1
>>> g(0,2)
2
>>> g(0,0)
0
>>> h(1,2)
1
>>> h(0,2)
2
>>> h(0,0)
3
"""
def
f
(
a
,
b
):
def
f
(
a
,
b
):
x
=
0
if
a
:
if
a
:
x
=
1
x
=
1
if
a
+
b
:
if
a
+
b
:
x
=
1
x
=
2
return
x
def
g
(
a
,
b
):
x
=
0
if
a
:
if
a
:
x
=
1
x
=
1
elif
b
:
elif
b
:
x
=
2
x
=
2
return
x
def
h
(
a
,
b
):
x
=
0
if
a
:
if
a
:
x
=
1
x
=
1
elif
b
:
elif
b
:
x
=
2
x
=
2
else
:
else
:
x
=
3
x
=
3
return
x
\ No newline at end of file
tests/run/ishimoto3.pyx
View file @
78df7dc4
__doc__
=
"""
>>> c1 = C1()
>>> c2 = C2(c1)
>>> c1 is c2.getc1()
True
"""
cdef
class
C1
:
cdef
class
C1
:
pass
pass
...
@@ -6,3 +13,6 @@ cdef class C2:
...
@@ -6,3 +13,6 @@ cdef class C2:
def
__init__
(
self
,
arg
):
def
__init__
(
self
,
arg
):
self
.
c1
=
arg
self
.
c1
=
arg
def
getc1
(
self
):
return
self
.
c1
tests/run/kostyrka.pyx
View file @
78df7dc4
__doc__
=
"""
>>> t = TEST()
>>> 1 in t
True
"""
cdef
class
TEST
:
cdef
class
TEST
:
def
__contains__
(
self
,
x
):
def
__contains__
(
self
,
x
):
return
42
return
42
tests/run/kostyrka2.pyx
View file @
78df7dc4
__doc__
=
"""
>>> x = X()
>>> x.slots
['']
"""
class
X
:
class
X
:
slots
=
[
""
,
]
slots
=
[
""
,
]
tests/run/lepage_1.pyx
View file @
78df7dc4
__doc__
=
"""
>>> a = A(1,2,3)
>>> a[0]
1.0
>>> a[1]
2.0
>>> a[2]
3.0
"""
cdef
class
A
:
cdef
class
A
:
cdef
double
x
[
3
]
cdef
double
x
[
3
]
def
__init__
(
self
,
*
args
):
cdef
int
i
,
max
max
=
len
(
args
)
if
max
>
3
:
max
=
3
for
i
from
0
<=
i
<
max
:
self
.
x
[
i
]
=
args
[
i
]
def
__getitem__
(
self
,
i
):
def
__getitem__
(
self
,
i
):
return
self
.
x
[
i
]
return
self
.
x
[
i
]
tests/run/list.pyx
View file @
78df7dc4
__doc__
=
"""
>>> f(1, 2, 3, 4, 5)
[]
>>> g(1, 2, 3, 4, 5)
[2]
>>> h(1, 2, 3, 4, 5)
[2, 3]
>>> j(1, 2, 3, 4, 5)
[2, 3, 4]
>>> k(1, 2, 3, 4, 5)
[17, 42, 88]
"""
def
f
(
obj1
,
obj2
,
obj3
,
obj4
,
obj5
):
def
f
(
obj1
,
obj2
,
obj3
,
obj4
,
obj5
):
obj1
=
[]
obj1
=
[]
return
obj1
def
g
(
obj1
,
obj2
,
obj3
,
obj4
,
obj5
):
obj1
=
[
obj2
]
obj1
=
[
obj2
]
return
obj1
def
h
(
obj1
,
obj2
,
obj3
,
obj4
,
obj5
):
obj1
=
[
obj2
,
obj3
]
obj1
=
[
obj2
,
obj3
]
return
obj1
def
j
(
obj1
,
obj2
,
obj3
,
obj4
,
obj5
):
obj1
=
[
obj2
,
obj3
,
obj4
]
obj1
=
[
obj2
,
obj3
,
obj4
]
return
obj1
def
k
(
obj1
,
obj2
,
obj3
,
obj4
,
obj5
):
obj1
=
[
17
,
42
,
88
]
obj1
=
[
17
,
42
,
88
]
return
obj1
\ No newline at end of file
tests/run/literals.pyx
View file @
78df7dc4
__doc__
=
"""
>>> foo()
"""
def
foo
():
def
foo
():
a
=
42
a
=
42
a1
=
0123
a1
=
0123
...
...
tests/run/multass.pyx
View file @
78df7dc4
cdef
void
f
():
__doc__
=
"""
>>> f()
(1, 2, 1, 2)
>>> g()
(1, 1, 2, 2, 3, 3)
>>> h()
(1, 'test', 3, 1, 'test', 3)
>>> j()
(2, 1, 4, 2, 6, 3)
"""
def
f
():
cdef
object
obj1a
,
obj2a
,
obj3a
,
obj1b
,
obj2b
,
obj3b
cdef
object
obj1a
,
obj2a
,
obj3a
,
obj1b
,
obj2b
,
obj3b
cdef
int
int1
,
int2
obj1b
,
obj2b
,
obj3b
=
1
,
2
,
3
cdef
char
*
ptr1
,
*
ptr2
obj1a
,
obj2a
=
obj1b
,
obj2b
obj1a
,
obj2a
=
obj1b
,
obj2b
return
obj1a
,
obj2a
,
obj1b
,
obj2b
def
g
():
cdef
object
obj1a
,
obj2a
,
obj3a
,
obj1b
,
obj2b
,
obj3b
obj1b
,
obj2b
,
obj3b
=
1
,
2
,
3
obj1a
,
[
obj2a
,
obj3a
]
=
[
obj1b
,
(
obj2b
,
obj3b
)]
obj1a
,
[
obj2a
,
obj3a
]
=
[
obj1b
,
(
obj2b
,
obj3b
)]
return
obj1a
,
obj1b
,
obj2a
,
obj2b
,
obj3a
,
obj3b
def
h
():
cdef
object
obj1a
,
obj2a
,
obj3a
,
obj1b
,
obj2b
,
obj3b
cdef
int
int1
,
int2
cdef
char
*
ptr1
,
*
ptr2
int2
,
ptr2
,
obj1b
=
1
,
"test"
,
3
int1
,
ptr1
,
obj1a
=
int2
,
ptr2
,
obj1b
int1
,
ptr1
,
obj1a
=
int2
,
ptr2
,
obj1b
return
int1
,
ptr1
,
obj1a
,
int2
,
ptr2
,
obj1b
def
j
():
cdef
object
obj1a
,
obj2a
,
obj3a
,
obj1b
,
obj2b
,
obj3b
obj1b
,
obj2b
,
obj3b
=
1
,
2
,
3
obj1a
,
obj2a
,
obj3a
=
obj1b
+
1
,
obj2b
+
2
,
obj3b
+
3
obj1a
,
obj2a
,
obj3a
=
obj1b
+
1
,
obj2b
+
2
,
obj3b
+
3
return
obj1a
,
obj1b
,
obj2a
,
obj2b
,
obj3a
,
obj3b
tests/run/pass.pyx
View file @
78df7dc4
__doc__
=
"""
>>> f()
"""
def
f
():
def
f
():
pass
pass
tests/run/pinard6.pyx
View file @
78df7dc4
__doc__
=
"""
>>> x
(1, 2)
"""
x
=
1
,
x
=
1
,
x
=
1
,
2
,
x
=
1
,
2
,
tests/run/pinard8.pyx
View file @
78df7dc4
__doc__
=
"""
>>> f = Fiche()
>>> f[0] = 1
>>> f.geti()
1
>>> f[1] = None
>>> f.geti()
0
>>> f[0] = 1
>>> f.geti()
1
"""
cdef
class
Fiche
:
cdef
class
Fiche
:
cdef
int
i
def
__setitem__
(
self
,
element
,
valeur
):
def
__setitem__
(
self
,
element
,
valeur
):
self
.
i
=
0
if
valeur
is
None
:
if
valeur
is
None
:
return
return
self
.
i
=
1
def
geti
(
self
):
return
self
.
i
tests/run/print.pyx
View file @
78df7dc4
__doc__
=
"""
>>> f(1, 'test')
<BLANKLINE>
1
1 test
1 test 42 spam
"""
def
f
(
a
,
b
):
def
f
(
a
,
b
):
print
print
print
a
print
a
print
a
,
b
print
a
,
b
print
a
,
b
,
print
a
,
b
,
print
42
,
"spam"
print
42
,
"spam"
\ No newline at end of file
tests/run/pyintop.pyx
View file @
78df7dc4
def
f
():
__doc__
=
"""
obj1
=
1
>>> f(1,2,3)
obj2
=
2
3
obj3
=
3
>>> g(1,2,3)
1
>>> h(1,2,3)
2
>>> j(1,2,3)
16
>>> k(1,2,3)
0
>>> l(1,2,3)
16
"""
def
f
(
obj1
,
obj2
,
obj3
):
obj1
=
obj2
|
obj3
obj1
=
obj2
|
obj3
return
obj1
def
g
(
obj1
,
obj2
,
obj3
):
obj1
=
obj2
^
obj3
obj1
=
obj2
^
obj3
return
obj1
def
h
(
obj1
,
obj2
,
obj3
):
obj1
=
obj2
&
obj3
obj1
=
obj2
&
obj3
return
obj1
def
j
(
obj1
,
obj2
,
obj3
):
obj1
=
obj2
<<
obj3
obj1
=
obj2
<<
obj3
return
obj1
def
k
(
obj1
,
obj2
,
obj3
):
obj1
=
obj2
>>
obj3
obj1
=
obj2
>>
obj3
return
obj1
def
l
(
obj1
,
obj2
,
obj3
):
obj1
=
obj2
<<
obj3
|
obj2
>>
obj3
obj1
=
obj2
<<
obj3
|
obj2
>>
obj3
return
obj1
\ No newline at end of file
tests/run/r_jiba1.pyx
View file @
78df7dc4
__doc__
=
"""
>>> test()
This parrot is resting.
Lovely plumage!
"""
cdef
class
Parrot
:
cdef
class
Parrot
:
cdef
void
describe
(
self
):
cdef
void
describe
(
self
):
...
@@ -11,8 +18,9 @@ cdef class Norwegian(Parrot):
...
@@ -11,8 +18,9 @@ cdef class Norwegian(Parrot):
cdef
void
describe
(
self
):
cdef
void
describe
(
self
):
print
"Lovely plumage!"
print
"Lovely plumage!"
cdef
Parrot
p1
,
p2
def
test
():
p1
=
Parrot
()
cdef
Parrot
p1
,
p2
p2
=
Norwegian
()
p1
=
Parrot
()
p1
.
describe
()
p2
=
Norwegian
()
p2
.
describe
()
p1
.
describe
()
p2
.
describe
()
tests/run/r_mcintyre1.pyx
View file @
78df7dc4
__doc__
=
"""
>>> b = Bicycle()
>>> b.fall_off()
Falling off extremely hard
>>> b.fall_off("somewhat")
Falling off somewhat hard
"""
class
Bicycle
:
class
Bicycle
:
def
fall_off
(
self
,
how_hard
=
"extremely"
):
def
fall_off
(
self
,
how_hard
=
"extremely"
):
...
...
tests/run/r_mitch_chapman_2.pyx
View file @
78df7dc4
__doc__
=
"""
>>> boolExpressionsFail()
'Not 2b'
"""
def
boolExpressionsFail
():
def
boolExpressionsFail
():
dict
=
{
1
:
1
}
dict
=
{
1
:
1
}
if
not
dict
.
has_key
(
"2b"
):
if
not
dict
.
has_key
(
"2b"
):
...
...
tests/run/r_vree_1.pyx
View file @
78df7dc4
__doc__
=
"""
>>> test(0)
0L
>>> test(1)
1L
>>> 2**36
68719476736L
>>> test(2**36)
0L
>>> test(2L**36)
0L
"""
def
test
(
k
):
def
test
(
k
):
cdef
unsigned
long
m
cdef
unsigned
long
m
m
=
k
m
=
k
...
...
tests/run/rodriguez_1.pyx
View file @
78df7dc4
__doc__
=
"""
>>> b = B()
>>> b.t
{1: ((1, 2, 3),), 2: (1, 2, 3)}
"""
class
B
:
class
B
:
def
__init__
(
self
):
def
__init__
(
self
):
self
.
t
=
{
self
.
t
=
{
...
...
tests/run/simpcall.pyx
View file @
78df7dc4
__doc__
=
"""
>>> z(1,9.2,'test')
>>> failtype()
Traceback (most recent call last):
TypeError: an integer is required
>>> fail0(1,2)
Traceback (most recent call last):
TypeError: function takes exactly 2 arguments (0 given)
>>> fail1(1,2)
Traceback (most recent call last):
TypeError: function takes exactly 2 arguments (1 given)
"""
def
f
(
x
,
y
):
def
f
(
x
,
y
):
x
=
y
x
=
y
...
@@ -8,11 +23,16 @@ cdef h(int i, obj):
...
@@ -8,11 +23,16 @@ cdef h(int i, obj):
i
=
obj
i
=
obj
def
z
(
a
,
b
,
c
):
def
z
(
a
,
b
,
c
):
f
()
f
(
a
)
f
(
a
,
b
)
f
(
a
,
b
)
f
(
a
,
b
,)
f
(
a
,
b
,)
g
(
1
,
2.0
,
"spam"
)
g
(
1
,
2.0
,
"spam"
)
g
(
a
,
b
,
c
)
g
(
a
,
b
,
c
)
def
fail0
(
a
,
b
):
f
()
def
fail1
(
a
,
b
):
f
(
a
)
def
failtype
():
h
(
42
,
"eggs"
)
h
(
42
,
"eggs"
)
\ No newline at end of file
tests/run/slice2.pyx
View file @
78df7dc4
__doc__
=
"""
>>> l = [1,2,3,4]
>>> f(1, l, 2, 3)
[1, 2, 3, 4]
>>> l == f(1, l, 2, 3)
True
>>> l is f(1, l, 2, 3)
False
>>> g(1, [1,2,3,4], 2, 3)
[3, 4]
>>> h(1, [1,2,3,4], 2, 3)
[1, 2, 3]
>>> j(1, [1,2,3,4], 2, 3)
[3]
"""
def
f
(
obj1
,
obj2
,
obj3
,
obj4
):
def
f
(
obj1
,
obj2
,
obj3
,
obj4
):
obj1
=
obj2
[:]
obj1
=
obj2
[:]
return
obj1
def
g
(
obj1
,
obj2
,
obj3
,
obj4
):
obj1
=
obj2
[
obj3
:]
obj1
=
obj2
[
obj3
:]
return
obj1
def
h
(
obj1
,
obj2
,
obj3
,
obj4
):
obj1
=
obj2
[:
obj4
]
obj1
=
obj2
[:
obj4
]
return
obj1
def
j
(
obj1
,
obj2
,
obj3
,
obj4
):
obj1
=
obj2
[
obj3
:
obj4
]
obj1
=
obj2
[
obj3
:
obj4
]
return
obj1
tests/run/strconstinclass.pyx
View file @
78df7dc4
__doc__
=
"""
>>> c = C()
>>> print c.x
foo
"""
class
C
:
class
C
:
x
=
"foo"
x
=
"foo"
tests/run/tuple.pyx
View file @
78df7dc4
__doc__
=
"""
>>> f(1,2,3,4,5)
()
>>> g(1,2,3,4,5)
(2,)
>>> h(1,2,3,4,5)
(2, 3)
>>> j(1,2,3,4,5)
(2, 3, 4)
>>> k(1,2,3,4,5)
(2, 3, 4)
>>> l(1,2,3,4,5)
(17, 42, 88)
"""
def
f
(
obj1
,
obj2
,
obj3
,
obj4
,
obj5
):
def
f
(
obj1
,
obj2
,
obj3
,
obj4
,
obj5
):
obj1
=
()
return
obj1
def
g
(
obj1
,
obj2
,
obj3
,
obj4
,
obj5
):
obj1
=
()
obj1
=
(
obj2
,)
return
obj1
def
h
(
obj1
,
obj2
,
obj3
,
obj4
,
obj5
):
obj1
=
()
obj1
=
(
obj2
,)
obj1
=
obj2
,
obj3
return
obj1
def
j
(
obj1
,
obj2
,
obj3
,
obj4
,
obj5
):
obj1
=
()
obj1
=
(
obj2
,)
obj1
=
obj2
,
obj3
obj1
=
(
obj2
,
obj3
,
obj4
)
return
obj1
def
k
(
obj1
,
obj2
,
obj3
,
obj4
,
obj5
):
obj1
=
()
obj1
=
(
obj2
,)
obj1
=
obj2
,
obj3
obj1
=
(
obj2
,
obj3
,
obj4
)
obj1
=
(
obj2
,
obj3
,
obj4
,)
return
obj1
def
l
(
obj1
,
obj2
,
obj3
,
obj4
,
obj5
):
obj1
=
()
obj1
=
()
obj1
=
(
obj2
,)
obj1
=
(
obj2
,)
obj1
=
obj2
,
obj3
obj1
=
obj2
,
obj3
obj1
=
(
obj2
,
obj3
,
obj4
)
obj1
=
(
obj2
,
obj3
,
obj4
)
obj1
=
(
obj2
,
obj3
,
obj4
,)
obj1
=
(
obj2
,
obj3
,
obj4
,)
obj1
=
17
,
42
,
88
obj1
=
17
,
42
,
88
return
obj1
tests/run/unop.pyx
View file @
78df7dc4
__doc__
=
"""
>>> f(1, 2, 3)
(-3, -4, 1)
"""
def
f
(
obj1
,
obj2
,
obj3
):
def
f
(
obj1
,
obj2
,
obj3
):
cdef
int
bool1
,
bool2
cdef
int
bool1
,
bool2
cdef
int
int1
,
int2
cdef
int
int1
,
int2
cdef
char
*
str1
cdef
char
*
str1
int2
=
obj3
str1
=
NULL
bool2
=
0
bool1
=
not
bool2
bool1
=
not
bool2
obj1
=
not
obj2
obj1
=
not
obj2
bool1
=
not
str1
bool1
=
not
str1
...
@@ -11,4 +21,4 @@ def f(obj1, obj2, obj3):
...
@@ -11,4 +21,4 @@ def f(obj1, obj2, obj3):
obj1
=
-
obj2
obj1
=
-
obj2
int1
=
~
int2
int1
=
~
int2
obj1
=
~
obj2
obj1
=
~
obj2
return
obj1
,
int1
,
bool1
\ No newline at end of file
tests/run/unpack.pyx
View file @
78df7dc4
__doc__
=
"""
>>> f(1, (2,), (3,4,5), (6,(7,(8,9))), 0)
(8, 9, (8, 9), (6, (7, (8, 9))), 0)
"""
def
f
(
obj1
,
obj2
,
obj3
,
obj4
,
obj5
):
def
f
(
obj1
,
obj2
,
obj3
,
obj4
,
obj5
):
obj1
,
=
obj2
obj1
,
=
obj2
obj1
,
=
obj2
+
obj3
obj1
,
obj2
=
obj2
+
obj2
obj1
,
obj2
,
obj3
=
obj3
obj1
,
obj2
,
obj3
=
obj3
obj1
,
(
obj2
,
obj3
)
=
obj4
obj1
,
(
obj2
,
obj3
)
=
obj4
[
obj1
,
obj2
]
=
obj3
[
obj1
,
obj2
]
=
obj3
return
obj1
,
obj2
,
obj3
,
obj4
,
obj5
\ No newline at end of file
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