From e0dbc02e102600bb3355c4f3ee68480d66d94ae1 Mon Sep 17 00:00:00 2001 From: Marcelo Matus Date: Thu, 7 Oct 2004 21:53:29 +0000 Subject: [PATCH] more ugly tests git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@6367 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../python/template_default_arg_runme.py | 5 ++ .../test-suite/template_default_arg.i | 47 ++++++++++++++----- 2 files changed, 40 insertions(+), 12 deletions(-) create mode 100644 SWIG/Examples/test-suite/python/template_default_arg_runme.py diff --git a/SWIG/Examples/test-suite/python/template_default_arg_runme.py b/SWIG/Examples/test-suite/python/template_default_arg_runme.py new file mode 100644 index 000000000..0a4f699ee --- /dev/null +++ b/SWIG/Examples/test-suite/python/template_default_arg_runme.py @@ -0,0 +1,5 @@ +import template_default_arg + +fz = template_default_arg.Foo_Z_8() +x = template_default_arg.X_Foo_Z_8() +fzc = x.meth(fz) diff --git a/SWIG/Examples/test-suite/template_default_arg.i b/SWIG/Examples/test-suite/template_default_arg.i index 56ac4f57b..aa4fbc733 100644 --- a/SWIG/Examples/test-suite/template_default_arg.i +++ b/SWIG/Examples/test-suite/template_default_arg.i @@ -1,9 +1,17 @@ %module template_default_arg -%warnfilter(801) hi; /* Ruby, wrong class name */ %warnfilter(801) Hello; /* Ruby, wrong class name */ %inline %{ + template + struct Foo + { + typedef unsigned int size_type; + Foo(size_type n = size_type(0) ) { } + }; + + int foob(Foo h = Foo()) {return 1; } + template struct Hello { @@ -21,18 +29,29 @@ }; template struct X { - X(T t = T()) {} - X(double a, T t = T(0)) {} - T meth(double a, T t = T(0)) { return t; } - T meth(T t = T(0)) { return t; } - }; - template class Y : private X { - public: - // test using on templated class with default args in the method - using X::meth; + X(const T& t = T()) {} + X(double a, const T& t = T(0)) {} + T meth(double a, const T& t = T(0)) { return t; } + const T& meth(const T& t = T(0)) { return t; } }; + + template class Y : private X { + public: + // test using on templated class with default args in the method + using X::meth; + }; + + template struct Z + { + Z(int t = V) {} + // and also: + Z(double a, int t = V){} + }; + + %} +%template(Foo_int) Foo; %template(Hello_int) Hello; %template(X_int) X; %template(X_longlong) X; @@ -41,12 +60,16 @@ %template(X_hello_unsigned) X >; %template(Y_hello_unsigned) Y >; +%template(X_Foo_Foo_int) X > >; +%template(Z_8) Z<8>; +%template(Foo_Z_8) Foo >; +%template(X_Foo_Z_8) X > >; %inline %{ - struct hi : Hello + struct Bar : Hello { - hi(size_type n) : Hello(n) + Bar(size_type n) : Hello(n) { }