From 200111d52d9bc951d198554ca4877524e1d6f012 Mon Sep 17 00:00:00 2001 From: Marcelo Matus Date: Wed, 6 Oct 2004 17:32:03 +0000 Subject: [PATCH] more cases, and C/C++ compatibility git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6349 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/common.mk | 1 + Examples/test-suite/overload_extend.i | 8 ++++++-- Examples/test-suite/python/overload_extend_runme.py | 5 +++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index bc309cf76..59142d5a0 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -308,6 +308,7 @@ C_TEST_CASES += \ name \ nested \ newobject2 \ + overload_extend \ overload_extendc \ preproc \ ret_by_value \ diff --git a/Examples/test-suite/overload_extend.i b/Examples/test-suite/overload_extend.i index a892fd9a4..65206c359 100644 --- a/Examples/test-suite/overload_extend.i +++ b/Examples/test-suite/overload_extend.i @@ -1,14 +1,18 @@ %module overload_extend +#ifndef __cplusplus +%typemap(default) double y "$1=1000;"; +#endif + #pragma SWIG nowarn=-302 %extend Foo { int test() { return 0; } int test(int x) { x = 0; return 1; } int test(char *s) { s = 0; return 2; } #ifdef __cplusplus - int test(double x, double y = 0) { x = 0; y = 0; return 3; } + double test(double x, double y = 1000) { return x + y; } #else - int test(double x, double y) { x = 0; y = 0; return 3; } + double test(double x, double y) { return x + y; } #endif }; diff --git a/Examples/test-suite/python/overload_extend_runme.py b/Examples/test-suite/python/overload_extend_runme.py index 48b76c385..7d08d482b 100644 --- a/Examples/test-suite/python/overload_extend_runme.py +++ b/Examples/test-suite/python/overload_extend_runme.py @@ -7,7 +7,8 @@ if f.test(3) != 1: raise RuntimeError if f.test("hello") != 2: raise RuntimeError -if f.test(3.5,2.5) != 3: +if f.test(3,2) != 5: + raise RuntimeError +if f.test(3.0) != 1003: raise RuntimeError -