Skip to content

Commit

Permalink
Added testcase for function objects.
Browse files Browse the repository at this point in the history
  • Loading branch information
matevz committed Jul 18, 2009
1 parent 523817e commit e949fa3
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Examples/test-suite/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
18 changes: 18 additions & 0 deletions Examples/test-suite/cpp0x_function_objects.i
Original file line number Diff line number Diff line change
@@ -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 changes: 12 additions & 0 deletions Examples/test-suite/python/cpp0x_function_objects_runme.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e949fa3

Please sign in to comment.