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
11fd96e0
Commit
11fd96e0
authored
Feb 18, 2011
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
git://github.com/cython/cython
parents
d1ff05f2
475e9a08
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
5 deletions
+14
-5
Cython/Build/Tests/TestInline.py
Cython/Build/Tests/TestInline.py
+14
-5
No files found.
Cython/Build/Tests/TestInline.py
View file @
11fd96e0
import
os
,
tempfile
from
Cython.Shadow
import
inline
from
Cython.Shadow
import
inline
from
Cython.Build.Inline
import
safe_type
from
Cython.Build.Inline
import
safe_type
from
Cython.TestUtils
import
CythonTest
from
Cython.TestUtils
import
CythonTest
...
@@ -13,23 +14,31 @@ test_kwds = dict(force=True, quiet=True)
...
@@ -13,23 +14,31 @@ test_kwds = dict(force=True, quiet=True)
global_value
=
100
global_value
=
100
class
TestInline
(
CythonTest
):
class
TestInline
(
CythonTest
):
def
setUp
(
self
):
CythonTest
.
setUp
(
self
)
self
.
test_kwds
=
dict
(
test_kwds
)
if
os
.
path
.
isdir
(
'BUILD'
):
lib_dir
=
os
.
path
.
join
(
'BUILD'
,
'inline'
)
else
:
lib_dir
=
tempfile
.
mkdtemp
(
prefix
=
'cython_inline_'
)
self
.
test_kwds
[
'lib_dir'
]
=
lib_dir
def
test_simple
(
self
):
def
test_simple
(
self
):
self
.
assertEquals
(
inline
(
"return 1+2"
,
**
test_kwds
),
3
)
self
.
assertEquals
(
inline
(
"return 1+2"
,
**
self
.
test_kwds
),
3
)
def
test_types
(
self
):
def
test_types
(
self
):
self
.
assertEquals
(
inline
(
"""
self
.
assertEquals
(
inline
(
"""
cimport cython
cimport cython
return cython.typeof(a), cython.typeof(b)
return cython.typeof(a), cython.typeof(b)
"""
,
a
=
1.0
,
b
=
[],
**
test_kwds
),
(
'double'
,
'list object'
))
"""
,
a
=
1.0
,
b
=
[],
**
self
.
test_kwds
),
(
'double'
,
'list object'
))
def
test_locals
(
self
):
def
test_locals
(
self
):
a
=
1
a
=
1
b
=
2
b
=
2
self
.
assertEquals
(
inline
(
"return a+b"
,
**
test_kwds
),
3
)
self
.
assertEquals
(
inline
(
"return a+b"
,
**
self
.
test_kwds
),
3
)
def
test_globals
(
self
):
def
test_globals
(
self
):
self
.
assertEquals
(
inline
(
"return global_value + 1"
,
**
test_kwds
),
global_value
+
1
)
self
.
assertEquals
(
inline
(
"return global_value + 1"
,
**
self
.
test_kwds
),
global_value
+
1
)
if
has_numpy
:
if
has_numpy
:
...
@@ -38,4 +47,4 @@ class TestInline(CythonTest):
...
@@ -38,4 +47,4 @@ class TestInline(CythonTest):
a
=
numpy
.
ndarray
((
10
,
20
))
a
=
numpy
.
ndarray
((
10
,
20
))
a
[
0
,
0
]
=
10
a
[
0
,
0
]
=
10
self
.
assertEquals
(
safe_type
(
a
),
'numpy.ndarray[numpy.float64_t, ndim=2]'
)
self
.
assertEquals
(
safe_type
(
a
),
'numpy.ndarray[numpy.float64_t, ndim=2]'
)
self
.
assertEquals
(
inline
(
"return a[0,0]"
,
a
=
a
,
**
test_kwds
),
10.0
)
self
.
assertEquals
(
inline
(
"return a[0,0]"
,
a
=
a
,
**
self
.
test_kwds
),
10.0
)
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