-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added testcase for function objects.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-matevz@11419 626c5289-ae23-0410-ae9c-e8d60b6d4f22
- Loading branch information
Showing
3 changed files
with
34 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
12
Examples/test-suite/python/cpp0x_function_objects_runme.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|