Added testcase for function objects.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-matevz@11419 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
523817e4ee
commit
e949fa3cc7
3 changed files with 34 additions and 2 deletions
|
|
@ -405,11 +405,13 @@ CPP0X_TEST_CASES = \
|
|||
cpp0x_raw_string_literals \
|
||||
cpp0x_static_assert \
|
||||
cpp0x_template_explicit \
|
||||
cpp0x_thread_local \
|
||||
cpp0x_uniform_initialization \
|
||||
cpp0x_alternate_function_syntax
|
||||
cpp0x_alternate_function_syntax \
|
||||
cpp0x_function_objects
|
||||
# cpp0x_hash_types # not fully implemented yet
|
||||
# cpp0x_smart_pointers # not supported by standard library yet
|
||||
# cpp0x_constexpr # not supported by any compilers yet
|
||||
# cpp0x_thread_local # not supported by any compilers yet
|
||||
|
||||
# Broken C++0x test cases.
|
||||
CPP0X_TEST_BROKEN =
|
||||
|
|
|
|||
18
Examples/test-suite/cpp0x_function_objects.i
Normal file
18
Examples/test-suite/cpp0x_function_objects.i
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/* This testcase checks whether Swig correctly parses function objects
|
||||
and the templates for the functions (signature).
|
||||
Function objects are objects which overload the operator() function. */
|
||||
%module cpp0x_function_objects
|
||||
|
||||
%inline %{
|
||||
//function<int ( int, int )> pF; // not supported yet by the compiler
|
||||
|
||||
struct Test {
|
||||
int value;
|
||||
|
||||
void operator()(short x, short y) {
|
||||
value=10;
|
||||
}
|
||||
|
||||
} test;
|
||||
%}
|
||||
|
||||
12
Examples/test-suite/python/cpp0x_function_objects_runme.py
Normal file
12
Examples/test-suite/python/cpp0x_function_objects_runme.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import cpp0x_function_objects
|
||||
import sys
|
||||
|
||||
t = cpp0x_function_objects.Test()
|
||||
if t.value != 0:
|
||||
raise RuntimeError,"Runtime cpp0x_function_objects failed. t.value should be 0, but is", t.value
|
||||
|
||||
t(1,2) # sets value
|
||||
|
||||
if t.value != 10:
|
||||
raise RuntimeError,"Runtime cpp0x_function_objects failed. t.value not changed - should be 10, but is", t.value
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue