beefed up the kwargs tests
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@6453 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
f635981d2f
commit
04e7f11296
2 changed files with 77 additions and 16 deletions
|
|
@ -2,29 +2,53 @@
|
|||
|
||||
%feature("kwargs");
|
||||
|
||||
//
|
||||
// No warnings nor overload methods should be generated here
|
||||
//
|
||||
|
||||
// Simple class
|
||||
%extend Foo
|
||||
{
|
||||
int efoo(int a =1, int b = 0) {return a + b; }
|
||||
static int sfoo(int a =1, int b = 0) { return a + b; }
|
||||
int efoo(int a = 1, int b = 0) {return a + b; }
|
||||
static int sfoo(int a = 1, int b = 0) { return a + b; }
|
||||
}
|
||||
|
||||
%inline %{
|
||||
|
||||
|
||||
int foo(int a =1, int b = 0) {return a + b; }
|
||||
|
||||
|
||||
|
||||
struct Foo
|
||||
{
|
||||
Foo(int a, int b = 0){}
|
||||
|
||||
int foo(int a =1, int b = 0) {return a + b; }
|
||||
static int bar(int a =1, int b = 0) {return a + b; }
|
||||
int foo(int a = 1, int b = 0) {return a + b; }
|
||||
static int statfoo(int a = 1, int b = 0) {return a + b; }
|
||||
};
|
||||
|
||||
%}
|
||||
|
||||
|
||||
// Templated class
|
||||
%extend Bar
|
||||
{
|
||||
T ebar(T a = 1, T b = 0) {return a + b; }
|
||||
static T sbar(T a = 1, T b = 0) { return a + b; }
|
||||
}
|
||||
|
||||
%inline %{
|
||||
template <typename T> struct Bar
|
||||
{
|
||||
Bar(T a, T b = 0){}
|
||||
|
||||
T bar(T a = 1, T b = 0) {return a + b; }
|
||||
static T statbar(T a = 1, T b = 0) {return a + b; }
|
||||
};
|
||||
|
||||
%}
|
||||
|
||||
%template(BarInt) Bar<int>;
|
||||
|
||||
|
||||
// Functions
|
||||
%inline %{
|
||||
int foo(int a = 1, int b = 0) {return a + b; }
|
||||
|
||||
template<typename T> T templatedfunction(T a = 1, T b = 0) { return a + b; }
|
||||
%}
|
||||
|
||||
%template(templatedfunction) templatedfunction<int>;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,44 @@
|
|||
import kwargs
|
||||
from kwargs import *
|
||||
|
||||
if kwargs.foo(a=1,b=2) != 3:
|
||||
# Simple class
|
||||
f = Foo(b=2,a=1)
|
||||
|
||||
if f.foo(b=1,a=2) != 3:
|
||||
raise RuntimeError
|
||||
|
||||
if kwargs.foo(b=2) != 3:
|
||||
if Foo.statfoo(b=2) != 3:
|
||||
raise RuntimeError
|
||||
|
||||
if f.efoo(b=2) != 3:
|
||||
raise RuntimeError
|
||||
|
||||
if Foo.sfoo(b=2) != 3:
|
||||
raise RuntimeError
|
||||
|
||||
|
||||
# Templated class
|
||||
b = BarInt(b=2,a=1)
|
||||
|
||||
if b.bar(b=1,a=2) != 3:
|
||||
raise RuntimeError
|
||||
|
||||
if BarInt.statbar(b=2) != 3:
|
||||
raise RuntimeError
|
||||
|
||||
if b.ebar(b=2) != 3:
|
||||
raise RuntimeError
|
||||
|
||||
if BarInt.sbar(b=2) != 3:
|
||||
raise RuntimeError
|
||||
|
||||
|
||||
# Functions
|
||||
if templatedfunction(b=2) != 3:
|
||||
raise RuntimeError
|
||||
|
||||
if foo(a=1,b=2) != 3:
|
||||
raise RuntimeError
|
||||
|
||||
if foo(b=2) != 3:
|
||||
raise RuntimeError
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue