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
86b46c1b
Commit
86b46c1b
authored
Nov 03, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
drop tests from pure_py.py test file that do not work in pure mode
parent
c2da6d1a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
110 additions
and
80 deletions
+110
-80
tests/run/pure.pyx
tests/run/pure.pyx
+49
-1
tests/run/pure_py.py
tests/run/pure_py.py
+61
-79
No files found.
tests/run/pure.pyx
View file @
86b46c1b
...
@@ -70,6 +70,54 @@ def test_locals(x):
...
@@ -70,6 +70,54 @@ def test_locals(x):
y
=
x
y
=
x
return
y
return
y
@
cython
.
test_assert_path_exists
(
"//TryFinallyStatNode"
,
"//TryFinallyStatNode//GILStatNode"
)
@
cython
.
test_fail_if_path_exists
(
"//TryFinallyStatNode//TryFinallyStatNode"
)
def
test_with_nogil
(
nogil
):
"""
>>> raised = []
>>> class nogil(object):
... def __enter__(self):
... pass
... def __exit__(self, exc_class, exc, tb):
... raised.append(exc)
... return exc_class is None
>>> test_with_nogil(nogil())
WORKS
True
>>> raised
[None]
"""
result
=
False
with
nogil
:
print
"WORKS"
with
cython
.
nogil
:
result
=
True
return
result
@
cython
.
test_assert_path_exists
(
"//TryFinallyStatNode"
,
"//TryFinallyStatNode//GILStatNode"
)
@
cython
.
test_fail_if_path_exists
(
"//TryFinallyStatNode//TryFinallyStatNode"
)
def
test_with_nogil_multiple
(
nogil
):
"""
>>> raised = []
>>> class nogil(object):
... def __enter__(self):
... pass
... def __exit__(self, exc_class, exc, tb):
... raised.append(exc)
... return exc_class is None
>>> test_with_nogil_multiple(nogil())
True
>>> raised
[None]
"""
result
=
False
with
nogil
,
cython
.
nogil
:
result
=
True
return
result
MyUnion
=
cython
.
union
(
n
=
cython
.
int
,
x
=
cython
.
double
)
MyUnion
=
cython
.
union
(
n
=
cython
.
int
,
x
=
cython
.
double
)
MyStruct
=
cython
.
struct
(
is_integral
=
cython
.
bint
,
data
=
MyUnion
)
MyStruct
=
cython
.
struct
(
is_integral
=
cython
.
bint
,
data
=
MyUnion
)
...
...
tests/run/pure_py.py
View file @
86b46c1b
...
@@ -10,43 +10,41 @@ def test_sizeof():
...
@@ -10,43 +10,41 @@ def test_sizeof():
True
True
"""
"""
x
=
cython
.
declare
(
cython
.
bint
)
x
=
cython
.
declare
(
cython
.
bint
)
print
sizeof
(
x
)
==
sizeof
(
cython
.
bint
)
print
cython
.
sizeof
(
x
)
==
cython
.
sizeof
(
cython
.
bint
)
print
sizeof
(
cython
.
char
)
<=
sizeof
(
cython
.
short
)
<=
sizeof
(
cython
.
int
)
<=
sizeof
(
cython
.
long
)
<=
sizeof
(
cython
.
longlong
)
print
cython
.
sizeof
(
cython
.
char
)
<=
cython
.
sizeof
(
cython
.
short
)
<=
cython
.
sizeof
(
cython
.
int
)
<=
cython
.
sizeof
(
cython
.
long
)
<=
cython
.
sizeof
(
cython
.
longlong
)
print
sizeof
(
cython
.
uint
)
==
sizeof
(
cython
.
int
)
print
cython
.
sizeof
(
cython
.
uint
)
==
cython
.
sizeof
(
cython
.
int
)
print
sizeof
(
cython
.
p_int
)
==
sizeof
(
cython
.
p_double
)
print
cython
.
sizeof
(
cython
.
p_int
)
==
cython
.
sizeof
(
cython
.
p_double
)
if
cython
.
compiled
:
if
cython
.
compiled
:
print
sizeof
(
cython
.
char
)
<
sizeof
(
cython
.
longlong
)
print
cython
.
sizeof
(
cython
.
char
)
<
cython
.
sizeof
(
cython
.
longlong
)
else
:
else
:
print
sizeof
(
cython
.
char
)
==
1
print
cython
.
sizeof
(
cython
.
char
)
==
1
def
test_declare
(
n
):
## CURRENTLY BROKEN - FIXME!!
"""
>>> test_declare(100)
## def test_declare(n):
(100, 100)
## """
>>> test_declare(100.5)
## >>> test_declare(100)
(100, 100)
## (100, 100)
>>> test_declare(None)
## >>> test_declare(100.5)
Traceback (most recent call last):
## (100, 100)
...
## >>> test_declare(None)
TypeError: an integer is required
## Traceback (most recent call last):
"""
## ...
x
=
cython
.
declare
(
cython
.
int
)
## TypeError: an integer is required
y
=
cython
.
declare
(
cython
.
int
,
n
)
## """
if
cython
.
compiled
:
## x = cython.declare(cython.int)
cython
.
declare
(
xx
=
cython
.
int
,
yy
=
cython
.
long
)
## y = cython.declare(cython.int, n)
i
=
sizeof
(
xx
)
## if cython.compiled:
ptr
=
cython
.
declare
(
cython
.
p_int
,
cython
.
address
(
y
))
## cython.declare(xx=cython.int, yy=cython.long)
return
y
,
ptr
[
0
]
## i = sizeof(xx)
## ptr = cython.declare(cython.p_int, cython.address(y))
## return y, ptr[0]
@
cython
.
locals
(
x
=
cython
.
double
,
n
=
cython
.
int
)
@
cython
.
locals
(
x
=
cython
.
double
,
n
=
cython
.
int
)
def
test_cast
(
x
):
def
test_cast
(
x
):
"""
"""
>>> test_cast(1.5)
>>> test_cast(1.5)
1
1
>>> test_cast(None)
Traceback (most recent call last):
...
TypeError: a float is required
"""
"""
n
=
cython
.
cast
(
cython
.
int
,
x
)
n
=
cython
.
cast
(
cython
.
int
,
x
)
return
n
return
n
...
@@ -60,19 +58,18 @@ def test_address(x):
...
@@ -60,19 +58,18 @@ def test_address(x):
y
=
cython
.
address
(
x
)
y
=
cython
.
address
(
x
)
return
y
[
0
]
return
y
[
0
]
@
cython
.
locals
(
x
=
cython
.
int
)
## CURRENTLY BROKEN - FIXME!!
@
cython
.
locals
(
y
=
cython
.
bint
)
def
test_locals
(
x
):
## @cython.locals(x=cython.int)
"""
## @cython.locals(y=cython.bint)
>>> test_locals(5)
## def test_locals(x):
True
## """
"""
## >>> test_locals(5)
y
=
x
## True
return
y
## """
## y = x
## return y
@
cython
.
test_assert_path_exists
(
"//TryFinallyStatNode"
,
"//TryFinallyStatNode//GILStatNode"
)
@
cython
.
test_fail_if_path_exists
(
"//TryFinallyStatNode//TryFinallyStatNode"
)
def
test_with_nogil
(
nogil
):
def
test_with_nogil
(
nogil
):
"""
"""
>>> raised = []
>>> raised = []
...
@@ -96,42 +93,21 @@ def test_with_nogil(nogil):
...
@@ -96,42 +93,21 @@ def test_with_nogil(nogil):
result
=
True
result
=
True
return
result
return
result
@
cython
.
test_assert_path_exists
(
"//TryFinallyStatNode"
,
## CURRENTLY BROKEN - FIXME!!
"//TryFinallyStatNode//GILStatNode"
)
@
cython
.
test_fail_if_path_exists
(
"//TryFinallyStatNode//TryFinallyStatNode"
)
def
test_with_nogil_multiple
(
nogil
):
"""
>>> raised = []
>>> class nogil(object):
... def __enter__(self):
... pass
... def __exit__(self, exc_class, exc, tb):
... raised.append(exc)
... return exc_class is None
>>> test_with_nogil_multiple(nogil())
True
>>> raised
[None]
"""
result
=
False
with
nogil
,
cython
.
nogil
:
result
=
True
return
result
MyUnion
=
cython
.
union
(
n
=
cython
.
int
,
x
=
cython
.
double
)
##
MyUnion = cython.union(n=cython.int, x=cython.double)
MyStruct
=
cython
.
struct
(
is_integral
=
cython
.
bint
,
data
=
MyUnion
)
##
MyStruct = cython.struct(is_integral=cython.bint, data=MyUnion)
MyStruct2
=
cython
.
typedef
(
MyStruct
[
2
])
##
MyStruct2 = cython.typedef(MyStruct[2])
def
test_struct
(
n
,
x
):
##
def test_struct(n, x):
"""
##
"""
>>> test_struct(389, 1.64493)
##
>>> test_struct(389, 1.64493)
(389, 1.64493)
##
(389, 1.64493)
"""
##
"""
a
=
cython
.
declare
(
MyStruct2
)
##
a = cython.declare(MyStruct2)
a
[
0
]
=
MyStruct
(
True
,
data
=
MyUnion
(
n
=
n
))
##
a[0] = MyStruct(True, data=MyUnion(n=n))
a
[
1
]
=
MyStruct
(
is_integral
=
False
,
data
=
{
'x'
:
x
})
##
a[1] = MyStruct(is_integral=False, data={'x': x})
return
a
[
0
].
data
.
n
,
a
[
1
].
data
.
x
##
return a[0].data.n, a[1].data.x
import
cython
as
cy
import
cython
as
cy
from
cython
import
declare
,
cast
,
locals
,
address
,
typedef
,
p_void
,
compiled
from
cython
import
declare
,
cast
,
locals
,
address
,
typedef
,
p_void
,
compiled
...
@@ -140,18 +116,24 @@ from cython import declare as my_declare, locals as my_locals, p_void as my_void
...
@@ -140,18 +116,24 @@ from cython import declare as my_declare, locals as my_locals, p_void as my_void
@
my_locals
(
a
=
cython
.
p_void
)
@
my_locals
(
a
=
cython
.
p_void
)
def
test_imports
():
def
test_imports
():
"""
"""
>>> test_imports()
>>> test_imports()
# (True, True)
True
True
"""
"""
a
=
cython
.
NULL
a
=
cython
.
NULL
b
=
declare
(
p_void
,
cython
.
NULL
)
b
=
declare
(
p_void
,
cython
.
NULL
)
c
=
my_declare
(
my_void_star
,
cython
.
NULL
)
c
=
my_declare
(
my_void_star
,
cython
.
NULL
)
d
=
cy
.
declare
(
cy
.
p_void
,
cython
.
NULL
)
d
=
cy
.
declare
(
cy
.
p_void
,
cython
.
NULL
)
return
a
==
d
and
compiled
and
my_compiled
MyStruct3
=
typedef
(
MyStruct
[
3
])
## CURRENTLY BROKEN - FIXME!!
MyStruct4
=
my_typedef
(
MyStruct
[
4
])
#return a == d, compiled == my_compiled
MyStruct5
=
cy
.
typedef
(
MyStruct
[
5
])
return
compiled
==
my_compiled
## CURRENTLY BROKEN - FIXME!!
## MyStruct3 = typedef(MyStruct[3])
## MyStruct4 = my_typedef(MyStruct[4])
## MyStruct5 = cy.typedef(MyStruct[5])
def
test_declare_c_types
(
n
):
def
test_declare_c_types
(
n
):
"""
"""
...
...
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