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
144c66ee
Commit
144c66ee
authored
Feb 09, 2010
by
Craig Citro
Browse files
Options
Browse Files
Download
Plain Diff
merge
parents
34741cc4
1dcb8c52
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
270 additions
and
17 deletions
+270
-17
runtests.py
runtests.py
+24
-17
tests/bugs.txt
tests/bugs.txt
+2
-0
tests/wrappers/cpp_overload_wrapper.pyx
tests/wrappers/cpp_overload_wrapper.pyx
+36
-0
tests/wrappers/cpp_overload_wrapper_lib.cpp
tests/wrappers/cpp_overload_wrapper_lib.cpp
+55
-0
tests/wrappers/cpp_overload_wrapper_lib.h
tests/wrappers/cpp_overload_wrapper_lib.h
+22
-0
tests/wrappers/cpp_overload_wrapper_lib.pxd
tests/wrappers/cpp_overload_wrapper_lib.pxd
+14
-0
tests/wrappers/cppwrap.pyx
tests/wrappers/cppwrap.pyx
+30
-0
tests/wrappers/cppwrap_lib.cpp
tests/wrappers/cppwrap_lib.cpp
+55
-0
tests/wrappers/cppwrap_lib.h
tests/wrappers/cppwrap_lib.h
+20
-0
tests/wrappers/cppwrap_lib.pxd
tests/wrappers/cppwrap_lib.pxd
+12
-0
No files found.
runtests.py
View file @
144c66ee
...
...
@@ -28,8 +28,8 @@ from distutils.core import Extension
from
distutils.command.build_ext
import
build_ext
as
_build_ext
distutils_distro
=
Distribution
()
TEST_DIRS
=
[
'compile'
,
'errors'
,
'run'
,
'pyregr'
]
TEST_RUN_DIRS
=
[
'run'
,
'pyregr'
]
TEST_DIRS
=
[
'compile'
,
'errors'
,
'run'
,
'
wrappers'
,
'
pyregr'
]
TEST_RUN_DIRS
=
[
'run'
,
'
wrappers'
,
'
pyregr'
]
# Lists external modules, and a matcher matching tests
# which should be excluded if the module is not present.
...
...
@@ -200,10 +200,10 @@ class TestBuilder(object):
fork
=
self
.
fork
)
class
CythonCompileTestCase
(
unittest
.
TestCase
):
def
__init__
(
self
,
directory
,
workdir
,
module
,
language
=
'c'
,
def
__init__
(
self
,
test_
directory
,
workdir
,
module
,
language
=
'c'
,
expect_errors
=
False
,
annotate
=
False
,
cleanup_workdir
=
True
,
cleanup_sharedlibs
=
True
,
cython_only
=
False
,
fork
=
True
):
self
.
directory
=
directory
self
.
test_directory
=
test_
directory
self
.
workdir
=
workdir
self
.
module
=
module
self
.
language
=
language
...
...
@@ -257,8 +257,8 @@ class CythonCompileTestCase(unittest.TestCase):
self
.
runCompileTest
()
def
runCompileTest
(
self
):
self
.
compile
(
self
.
directory
,
self
.
module
,
self
.
workdir
,
self
.
directory
,
self
.
expect_errors
,
self
.
annotate
)
self
.
compile
(
self
.
test_
directory
,
self
.
module
,
self
.
workdir
,
self
.
test_
directory
,
self
.
expect_errors
,
self
.
annotate
)
def
find_module_source_file
(
self
,
source_file
):
if
not
os
.
path
.
exists
(
source_file
):
...
...
@@ -269,8 +269,15 @@ class CythonCompileTestCase(unittest.TestCase):
target
=
'%s.%s'
%
(
module_name
,
self
.
language
)
return
target
def
split_source_and_output
(
self
,
directory
,
module
,
workdir
):
source_file
=
os
.
path
.
join
(
directory
,
module
)
+
'.pyx'
def
find_source_files
(
self
,
test_directory
,
module_name
):
is_related
=
re
.
compile
(
'%s_.*[.]%s'
%
(
module_name
,
self
.
language
)).
match
return
[
self
.
build_target_filename
(
module_name
)]
+
[
os
.
path
.
join
(
test_directory
,
filename
)
for
filename
in
os
.
listdir
(
test_directory
)
if
is_related
(
filename
)
and
os
.
path
.
isfile
(
os
.
path
.
join
(
test_directory
,
filename
))
]
def
split_source_and_output
(
self
,
test_directory
,
module
,
workdir
):
source_file
=
os
.
path
.
join
(
test_directory
,
module
)
+
'.pyx'
source_and_output
=
codecs
.
open
(
self
.
find_module_source_file
(
source_file
),
'rU'
,
'ISO-8859-1'
)
out
=
codecs
.
open
(
os
.
path
.
join
(
workdir
,
module
+
'.pyx'
),
...
...
@@ -289,12 +296,12 @@ class CythonCompileTestCase(unittest.TestCase):
else
:
return
geterrors
()
def
run_cython
(
self
,
directory
,
module
,
targetdir
,
incdir
,
annotate
):
def
run_cython
(
self
,
test_
directory
,
module
,
targetdir
,
incdir
,
annotate
):
include_dirs
=
INCLUDE_DIRS
[:]
if
incdir
:
include_dirs
.
append
(
incdir
)
source
=
self
.
find_module_source_file
(
os
.
path
.
join
(
directory
,
module
+
'.pyx'
))
os
.
path
.
join
(
test_
directory
,
module
+
'.pyx'
))
target
=
os
.
path
.
join
(
targetdir
,
self
.
build_target_filename
(
module
))
options
=
CompilationOptions
(
pyrex_default_options
,
...
...
@@ -309,7 +316,7 @@ class CythonCompileTestCase(unittest.TestCase):
cython_compile
(
source
,
options
=
options
,
full_module_name
=
module
)
def
run_distutils
(
self
,
module
,
workdir
,
incdir
):
def
run_distutils
(
self
,
test_directory
,
module
,
workdir
,
incdir
):
cwd
=
os
.
getcwd
()
os
.
chdir
(
workdir
)
try
:
...
...
@@ -324,7 +331,7 @@ class CythonCompileTestCase(unittest.TestCase):
ext_include_dirs
+=
get_additional_include_dirs
()
extension
=
Extension
(
module
,
sources
=
[
self
.
build_target_filename
(
module
)]
,
sources
=
self
.
find_source_files
(
test_directory
,
module
)
,
include_dirs
=
ext_include_dirs
,
extra_compile_args
=
CFLAGS
,
)
...
...
@@ -337,19 +344,19 @@ class CythonCompileTestCase(unittest.TestCase):
finally
:
os
.
chdir
(
cwd
)
def
compile
(
self
,
directory
,
module
,
workdir
,
incdir
,
def
compile
(
self
,
test_
directory
,
module
,
workdir
,
incdir
,
expect_errors
,
annotate
):
expected_errors
=
errors
=
()
if
expect_errors
:
expected_errors
=
self
.
split_source_and_output
(
directory
,
module
,
workdir
)
directory
=
workdir
test_
directory
,
module
,
workdir
)
test_
directory
=
workdir
if
WITH_CYTHON
:
old_stderr
=
sys
.
stderr
try
:
sys
.
stderr
=
ErrorWriter
()
self
.
run_cython
(
directory
,
module
,
workdir
,
incdir
,
annotate
)
self
.
run_cython
(
test_
directory
,
module
,
workdir
,
incdir
,
annotate
)
errors
=
sys
.
stderr
.
geterrors
()
finally
:
sys
.
stderr
=
old_stderr
...
...
@@ -373,7 +380,7 @@ class CythonCompileTestCase(unittest.TestCase):
raise
else
:
if
not
self
.
cython_only
:
self
.
run_distutils
(
module
,
workdir
,
incdir
)
self
.
run_distutils
(
test_directory
,
module
,
workdir
,
incdir
)
class
CythonRunTestCase
(
CythonCompileTestCase
):
def
shortDescription
(
self
):
...
...
tests/bugs.txt
View file @
144c66ee
...
...
@@ -10,3 +10,5 @@ cfunc_call_tuple_args_T408
cascaded_list_unpacking_T467
compile.cpp_operators
cpp_nested_templates
cppwrap
cpp_overload_wrapper
tests/wrappers/cpp_overload_wrapper.pyx
0 → 100644
View file @
144c66ee
cimport
cppwrap_lib
cdef
class
DoubleKeeper
:
cdef
cppwrap_lib
.
DoubleKeeper
*
keeper
def
__cinit__
(
self
,
number
=
None
):
if
number
is
None
:
self
.
keeper
=
new
cppwrap_lib
.
DoubleKeeper
()
else
:
self
.
keeper
=
new
cppwrap_lib
.
DoubleKeeper
(
number
)
def
__dealloc__
(
self
):
del
self
.
keeper
def
set_number
(
self
,
number
=
None
):
if
number
is
None
:
self
.
keeper
.
set_number
()
else
:
self
.
keeper
.
set_number
(
number
)
def
get_number
(
self
):
return
self
.
keeper
.
get_number
()
def
transmogrify
(
self
,
double
value
):
return
self
.
keeper
.
transmogrify
(
value
)
def
voidfunc
():
cppwrap_lib
.
voidfunc
()
def
doublefunc
(
double
x
,
double
y
,
double
z
):
return
cppwrap_lib
.
doublefunc
(
x
,
y
,
z
)
def
transmogrify_from_cpp
(
DoubleKeeper
obj
not
None
,
double
value
):
return
cppwrap_lib
.
transmogrify_from_cpp
(
obj
.
keeper
,
value
)
tests/wrappers/cpp_overload_wrapper_lib.cpp
0 → 100644
View file @
144c66ee
#include "cppwrap_lib.h"
void
voidfunc
(
void
)
{
}
double
doublefunc
(
double
a
,
double
b
,
double
c
)
{
return
a
+
b
+
c
;
}
DoubleKeeper
::
DoubleKeeper
()
:
number
(
1.0
)
{
}
DoubleKeeper
::
DoubleKeeper
(
double
factor
)
:
number
(
factor
)
{
}
DoubleKeeper
::~
DoubleKeeper
()
{
}
double
DoubleKeeper
::
get_number
()
const
{
return
number
;
}
void
DoubleKeeper
::
set_number
(
double
f
)
{
number
=
f
;
}
void
DoubleKeeper
::
set_number
()
{
number
=
1.0
;
}
double
DoubleKeeper
::
transmogrify
(
double
value
)
const
{
return
value
*
number
;
}
double
transmogrify_from_cpp
(
DoubleKeeper
const
*
obj
,
double
value
)
{
return
obj
->
transmogrify
(
value
);
}
tests/wrappers/cpp_overload_wrapper_lib.h
0 → 100644
View file @
144c66ee
void
voidfunc
(
void
);
double
doublefunc
(
double
a
,
double
b
,
double
c
);
class
DoubleKeeper
{
double
number
;
public:
DoubleKeeper
();
DoubleKeeper
(
double
number
);
virtual
~
DoubleKeeper
();
void
set_number
(
double
num
);
void
set_number
(
void
);
double
get_number
()
const
;
virtual
double
transmogrify
(
double
value
)
const
;
};
double
transmogrify_from_cpp
(
DoubleKeeper
const
*
obj
,
double
value
);
tests/wrappers/cpp_overload_wrapper_lib.pxd
0 → 100644
View file @
144c66ee
cdef
extern
from
"testapi.h"
:
void
voidfunc
()
double
doublefunc
(
double
a
,
double
b
,
double
c
)
cdef
cppclass
DoubleKeeper
:
DoubleKeeper
()
DoubleKeeper
(
double
factor
)
void
set_number
()
void
set_number
(
double
f
)
double
get_number
()
double
transmogrify
(
double
value
)
double
transmogrify_from_cpp
(
DoubleKeeper
*
obj
,
double
value
)
tests/wrappers/cppwrap.pyx
0 → 100644
View file @
144c66ee
cimport
cppwrap_lib
cdef
class
DoubleKeeper
:
cdef
cppwrap_lib
.
DoubleKeeper
*
keeper
def
__cinit__
(
self
,
double
number
):
self
.
keeper
=
new
cppwrap_lib
.
DoubleKeeper
(
number
)
def
__dealloc__
(
self
):
del
self
.
keeper
def
set_number
(
self
,
double
number
):
self
.
keeper
.
set_number
(
number
)
def
get_number
(
self
):
return
self
.
keeper
.
get_number
()
def
transmogrify
(
self
,
double
value
):
return
self
.
keeper
.
transmogrify
(
value
)
def
voidfunc
():
cppwrap_lib
.
voidfunc
()
def
doublefunc
(
double
x
,
double
y
,
double
z
):
return
cppwrap_lib
.
doublefunc
(
x
,
y
,
z
)
def
transmogrify_from_cpp
(
DoubleKeeper
obj
not
None
,
double
value
):
return
cppwrap_lib
.
transmogrify_from_cpp
(
obj
.
keeper
,
value
)
tests/wrappers/cppwrap_lib.cpp
0 → 100644
View file @
144c66ee
#include "cppwrap_lib.h"
void
voidfunc
(
void
)
{
}
double
doublefunc
(
double
a
,
double
b
,
double
c
)
{
return
a
+
b
+
c
;
}
DoubleKeeper
::
DoubleKeeper
()
:
number
(
1.0
)
{
}
DoubleKeeper
::
DoubleKeeper
(
double
factor
)
:
number
(
factor
)
{
}
DoubleKeeper
::~
DoubleKeeper
()
{
}
double
DoubleKeeper
::
get_number
()
const
{
return
number
;
}
void
DoubleKeeper
::
set_number
(
double
f
)
{
number
=
f
;
}
void
DoubleKeeper
::
set_number
()
{
number
=
1.0
;
}
double
DoubleKeeper
::
transmogrify
(
double
value
)
const
{
return
value
*
number
;
}
double
transmogrify_from_cpp
(
DoubleKeeper
const
*
obj
,
double
value
)
{
return
obj
->
transmogrify
(
value
);
}
tests/wrappers/cppwrap_lib.h
0 → 100644
View file @
144c66ee
void
voidfunc
(
void
);
double
doublefunc
(
double
a
,
double
b
,
double
c
);
class
DoubleKeeper
{
double
number
;
public:
DoubleKeeper
(
double
number
);
virtual
~
DoubleKeeper
();
void
set_number
(
double
num
);
double
get_number
()
const
;
virtual
double
transmogrify
(
double
value
)
const
;
};
double
transmogrify_from_cpp
(
DoubleKeeper
const
*
obj
,
double
value
);
tests/wrappers/cppwrap_lib.pxd
0 → 100644
View file @
144c66ee
cdef
extern
from
"testapi.h"
:
void
voidfunc
()
double
doublefunc
(
double
a
,
double
b
,
double
c
)
cdef
cppclass
DoubleKeeper
:
DoubleKeeper
(
double
factor
)
void
set_number
(
double
f
)
double
get_number
()
double
transmogrify
(
double
value
)
double
transmogrify_from_cpp
(
DoubleKeeper
*
obj
,
double
value
)
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