test compactdefaultargs feature
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7560 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
ba8a2fbc52
commit
fff590d2e5
3 changed files with 53 additions and 0 deletions
|
|
@ -93,6 +93,7 @@ CPP_TEST_CASES += \
|
||||||
constructor_explicit \
|
constructor_explicit \
|
||||||
constructor_value \
|
constructor_value \
|
||||||
contract \
|
contract \
|
||||||
|
compactdefaultargs \
|
||||||
conversion \
|
conversion \
|
||||||
conversion_namespace \
|
conversion_namespace \
|
||||||
conversion_ns_template \
|
conversion_ns_template \
|
||||||
|
|
|
||||||
32
Examples/test-suite/compactdefaultargs.i
Normal file
32
Examples/test-suite/compactdefaultargs.i
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
%module compactdefaultargs
|
||||||
|
|
||||||
|
// compactdefaultargs off by default
|
||||||
|
|
||||||
|
// The following should compile with compactdefaultargs off
|
||||||
|
%inline %{
|
||||||
|
class Defaults1 {
|
||||||
|
static const int private_default = -1;
|
||||||
|
public:
|
||||||
|
static const double public_default = -1.0;
|
||||||
|
Defaults1(int a = private_default) {}
|
||||||
|
double ret(double d = public_default) { return d; }
|
||||||
|
};
|
||||||
|
%}
|
||||||
|
|
||||||
|
|
||||||
|
// compactdefaultargs now on by default
|
||||||
|
%feature("compactdefaultargs");
|
||||||
|
|
||||||
|
// Turn compactdefaultargs off for the ret method which can't work with this feature
|
||||||
|
%feature("compactdefaultargs", "0") Defaults2(int a = private_default);
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
class Defaults2 {
|
||||||
|
static const int private_default = -1;
|
||||||
|
public:
|
||||||
|
static const double public_default = -1.0;
|
||||||
|
Defaults2(int a = private_default) {}
|
||||||
|
double ret(double d = public_default) { return d; }
|
||||||
|
};
|
||||||
|
%}
|
||||||
|
|
||||||
20
Examples/test-suite/python/compactdefaultargs_runme.py
Normal file
20
Examples/test-suite/python/compactdefaultargs_runme.py
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
from compactdefaultargs import *
|
||||||
|
|
||||||
|
defaults1 = Defaults1(1000)
|
||||||
|
defaults1 = Defaults1()
|
||||||
|
|
||||||
|
if defaults1.ret(10.0) != 10.0:
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
|
if defaults1.ret() != -1.0:
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
|
defaults2 = Defaults2(1000)
|
||||||
|
defaults2 = Defaults2()
|
||||||
|
|
||||||
|
if defaults2.ret(10.0) != 10.0:
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
|
if defaults2.ret() != -1.0:
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue