Merged from trunk
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@12656 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
commit
954256979c
557 changed files with 27074 additions and 5555 deletions
|
|
@ -5,6 +5,7 @@
|
|||
LANGUAGE = csharp
|
||||
SCRIPTSUFFIX = _runme.cs
|
||||
INTERPRETER = @CSHARPCILINTERPRETER@
|
||||
INTERPRETER_FLAGS = @CSHARPCILINTERPRETER_FLAGS@
|
||||
CSHARPPATHSEPARATOR = "@CSHARPPATHSEPARATOR@"
|
||||
CSHARPCYGPATH_W = @CSHARPCYGPATH_W@
|
||||
srcdir = @srcdir@
|
||||
|
|
@ -64,16 +65,17 @@ setup = \
|
|||
# Compiles C# files then runs the testcase. A testcase is only run if
|
||||
# a file is found which has _runme.cs appended after the testcase name.
|
||||
# Note C# uses LD_LIBRARY_PATH under Unix, PATH under Cygwin/Windows and SHLIB_PATH on HPUX.
|
||||
# DYLD_FALLBACK_LIBRARY_PATH is cleared for MacOSX.
|
||||
run_testcase = \
|
||||
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
$(MAKE) -f $*/$(top_builddir)/$(EXAMPLES)/Makefile \
|
||||
CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -out:$*_runme.exe' \
|
||||
CSHARPFLAGS='-nologo -debug+ $(CSHARPFLAGSSPECIAL) -out:$*_runme.exe' \
|
||||
CSHARPSRCS='`$(CSHARPCYGPATH_W) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)` `find $* -name "*.cs" -exec $(CSHARPCYGPATH_W) "{}" \+`' csharp_compile && \
|
||||
env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" $(RUNTOOL) $(INTERPRETER) $*_runme.exe; \
|
||||
env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" DYLD_FALLBACK_LIBRARY_PATH= $(RUNTOOL) $(INTERPRETER) $(INTERPRETER_FLAGS) $*_runme.exe; \
|
||||
else \
|
||||
cd $* && \
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
|
||||
CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -t:module -out:$*.netmodule' \
|
||||
CSHARPFLAGS='-nologo -debug+ $(CSHARPFLAGSSPECIAL) -t:module -out:$*.netmodule' \
|
||||
CSHARPSRCS='`find . -name "*.cs" -exec $(CSHARPCYGPATH_W) "{}" \+`' csharp_compile; \
|
||||
fi
|
||||
|
||||
|
|
|
|||
|
|
@ -55,6 +55,43 @@ public class csharp_prepost_runme {
|
|||
throw new Exception("Expecting CustomInt attribute");
|
||||
}
|
||||
}
|
||||
// Dates
|
||||
{
|
||||
// pre post typemap attributes example
|
||||
System.DateTime dateIn = new System.DateTime(2011, 4, 13);
|
||||
System.DateTime dateOut = new System.DateTime();
|
||||
|
||||
// Note in calls below, dateIn remains unchanged and dateOut
|
||||
// is set to a new value by the C++ call
|
||||
csharp_prepostNamespace.Action action = new csharp_prepostNamespace.Action(dateIn, out dateOut);
|
||||
if (dateOut != dateIn)
|
||||
throw new Exception("dates wrong");
|
||||
|
||||
dateIn = new System.DateTime(2012, 7, 14);
|
||||
action.doSomething(dateIn, out dateOut);
|
||||
if (dateOut != dateIn)
|
||||
throw new Exception("dates wrong");
|
||||
|
||||
System.DateTime refDate = new System.DateTime(1999, 12, 31);
|
||||
if (csharp_prepost.ImportantDate != refDate)
|
||||
throw new Exception("dates wrong");
|
||||
|
||||
refDate = new System.DateTime(1999, 12, 31);
|
||||
csharp_prepost.ImportantDate = refDate;
|
||||
System.DateTime importantDate = csharp_prepost.ImportantDate;
|
||||
if (importantDate != refDate)
|
||||
throw new Exception("dates wrong");
|
||||
|
||||
System.DateTime christmasEve = new System.DateTime(2000, 12, 24);
|
||||
csharp_prepost.addYears(ref christmasEve, 10);
|
||||
if (christmasEve != new System.DateTime(2010, 12, 24))
|
||||
throw new Exception("dates wrong");
|
||||
|
||||
Person person = new Person();
|
||||
person.Birthday = christmasEve;
|
||||
if (person.Birthday != christmasEve)
|
||||
throw new Exception("dates wrong");
|
||||
}
|
||||
}
|
||||
private static void Assert(double d1, double d2) {
|
||||
if (d1 != d2)
|
||||
|
|
|
|||
11
Examples/test-suite/csharp/director_alternating_runme.cs
Normal file
11
Examples/test-suite/csharp/director_alternating_runme.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
using System;
|
||||
using director_alternatingNamespace;
|
||||
|
||||
public class director_alternating_runme {
|
||||
public static void Main() {
|
||||
if (director_alternating.getBar().id() != director_alternating.idFromGetBar())
|
||||
throw new Exception("idFromGetBar failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -16,6 +16,7 @@ public class runme
|
|||
Foo f = b.create();
|
||||
FooBar fb = new FooBar();
|
||||
FooBar2 fb2 = new FooBar2();
|
||||
FooBar3 fb3 = new FooBar3();
|
||||
|
||||
String s;
|
||||
s = fb.used();
|
||||
|
|
@ -37,6 +38,21 @@ public class runme
|
|||
s = fb.pong();
|
||||
if ( s != ("Bar::pong();Foo::pong();FooBar::ping();"))
|
||||
throw new Exception("bad FooBar::pong");
|
||||
|
||||
// if (fb3.cheer() != "FooBar3::cheer();")
|
||||
// throw new Exception("bad fb3::cheer");
|
||||
|
||||
if (fb2.callping() != "FooBar2::ping();")
|
||||
throw new Exception("bad fb2.callping");
|
||||
|
||||
if (fb2.callcheer() != "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();")
|
||||
throw new Exception("bad fb2.callcheer");
|
||||
|
||||
if (fb3.callping() != "Bar::ping();")
|
||||
throw new Exception("bad fb3.callping");
|
||||
|
||||
if (fb3.callcheer() != "FooBar3::cheer();")
|
||||
throw new Exception("bad fb3.callcheer");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -69,4 +85,16 @@ class FooBar2 : Bar
|
|||
}
|
||||
}
|
||||
|
||||
class FooBar3 : Bar
|
||||
{
|
||||
public FooBar3() : base()
|
||||
{
|
||||
}
|
||||
|
||||
protected override String cheer()
|
||||
{
|
||||
return "FooBar3::cheer();";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -405,6 +405,28 @@ public class runme {
|
|||
if ((int)enum_thorough.repeatTest(repeat.llast) != 3) throw new Exception("repeatTest 5 failed");
|
||||
if ((int)enum_thorough.repeatTest(repeat.end) != 3) throw new Exception("repeatTest 6 failed");
|
||||
}
|
||||
// different types
|
||||
{
|
||||
if ((int)enum_thorough.differentTypesTest(DifferentTypes.typeint) != 10) throw new Exception("differentTypes 1 failed");
|
||||
if ((int)enum_thorough.differentTypesTest(DifferentTypes.typeboolfalse) != 0) throw new Exception("differentTypes 2 failed");
|
||||
if ((int)enum_thorough.differentTypesTest(DifferentTypes.typebooltrue) != 1) throw new Exception("differentTypes 3 failed");
|
||||
if ((int)enum_thorough.differentTypesTest(DifferentTypes.typebooltwo) != 2) throw new Exception("differentTypes 4 failed");
|
||||
if ((int)enum_thorough.differentTypesTest(DifferentTypes.typechar) != 'C') throw new Exception("differentTypes 5 failed");
|
||||
if ((int)enum_thorough.differentTypesTest(DifferentTypes.typedefaultint) != 'D') throw new Exception("differentTypes 6 failed");
|
||||
|
||||
int global_enum = enum_thorough.global_typeint;
|
||||
if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 10) throw new Exception("global differentTypes 1 failed");
|
||||
global_enum = enum_thorough.global_typeboolfalse;
|
||||
if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 0) throw new Exception("global differentTypes 2 failed");
|
||||
global_enum = enum_thorough.global_typebooltrue;
|
||||
if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 1) throw new Exception("global differentTypes 3 failed");
|
||||
global_enum = enum_thorough.global_typebooltwo;
|
||||
if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 2) throw new Exception("global differentTypes 4 failed");
|
||||
global_enum = enum_thorough.global_typechar;
|
||||
if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 'C') throw new Exception("global differentTypes 5 failed");
|
||||
global_enum = enum_thorough.global_typedefaultint;
|
||||
if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 'D') throw new Exception("global differentTypes 6 failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -405,6 +405,28 @@ public class runme {
|
|||
if (enum_thorough_simple.repeatTest(enum_thorough_simple.llast) != 3) throw new Exception("repeatTest 5 failed");
|
||||
if (enum_thorough_simple.repeatTest(enum_thorough_simple.end) != 3) throw new Exception("repeatTest 6 failed");
|
||||
}
|
||||
// different types
|
||||
{
|
||||
if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typeint) != 10) throw new Exception("differentTypes 1 failed");
|
||||
if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typeboolfalse) != 0) throw new Exception("differentTypes 2 failed");
|
||||
if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typebooltrue) != 1) throw new Exception("differentTypes 3 failed");
|
||||
if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typebooltwo) != 2) throw new Exception("differentTypes 4 failed");
|
||||
if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typechar) != 'C') throw new Exception("differentTypes 5 failed");
|
||||
if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typedefaultint) != 'D') throw new Exception("differentTypes 6 failed");
|
||||
|
||||
int global_enum = enum_thorough_simple.global_typeint;
|
||||
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 10) throw new Exception("global differentTypes 1 failed");
|
||||
global_enum = enum_thorough_simple.global_typeboolfalse;
|
||||
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 0) throw new Exception("global differentTypes 2 failed");
|
||||
global_enum = enum_thorough_simple.global_typebooltrue;
|
||||
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 1) throw new Exception("global differentTypes 3 failed");
|
||||
global_enum = enum_thorough_simple.global_typebooltwo;
|
||||
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 2) throw new Exception("global differentTypes 4 failed");
|
||||
global_enum = enum_thorough_simple.global_typechar;
|
||||
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 'C') throw new Exception("global differentTypes 5 failed");
|
||||
global_enum = enum_thorough_simple.global_typedefaultint;
|
||||
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 'D') throw new Exception("global differentTypes 6 failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -405,6 +405,28 @@ public class runme {
|
|||
if (enum_thorough_typesafe.repeatTest(repeat.llast).swigValue != 3) throw new Exception("repeatTest 5 failed");
|
||||
if (enum_thorough_typesafe.repeatTest(repeat.end).swigValue != 3) throw new Exception("repeatTest 6 failed");
|
||||
}
|
||||
// different types
|
||||
{
|
||||
if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typeint).swigValue != 10) throw new Exception("differentTypes 1 failed");
|
||||
if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typebooltrue).swigValue != 1) throw new Exception("differentTypes 2 failed");
|
||||
if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typebooltwo).swigValue != 2) throw new Exception("differentTypes 3 failed");
|
||||
if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typeboolfalse).swigValue != 0) throw new Exception("differentTypes 4 failed");
|
||||
if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typechar).swigValue != (int)'C') throw new Exception("differentTypes 5 failed");
|
||||
if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typedefaultint).swigValue != (int)'D') throw new Exception("differentTypes 6 failed");
|
||||
|
||||
int global_enum = enum_thorough_typesafe.global_typeint;
|
||||
if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 10) throw new Exception("global differentTypes 1 failed");
|
||||
global_enum = enum_thorough_typesafe.global_typeboolfalse;
|
||||
if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 0) throw new Exception("global differentTypes 2 failed");
|
||||
global_enum = enum_thorough_typesafe.global_typebooltrue;
|
||||
if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 1) throw new Exception("global differentTypes 3 failed");
|
||||
global_enum = enum_thorough_typesafe.global_typebooltwo;
|
||||
if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 2) throw new Exception("global differentTypes 4 failed");
|
||||
global_enum = enum_thorough_typesafe.global_typechar;
|
||||
if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 'C') throw new Exception("global differentTypes 5 failed");
|
||||
global_enum = enum_thorough_typesafe.global_typedefaultint;
|
||||
if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 'D') throw new Exception("global differentTypes 6 failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
43
Examples/test-suite/csharp/friends_runme.cs
Normal file
43
Examples/test-suite/csharp/friends_runme.cs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
using System;
|
||||
using friendsNamespace;
|
||||
|
||||
public class friends_runme {
|
||||
public static void Main() {
|
||||
A a = new A(2);
|
||||
|
||||
if (friends.get_val1(a) != 2)
|
||||
throw new Exception("failed");
|
||||
if (friends.get_val2(a) != 4)
|
||||
throw new Exception("failed");
|
||||
if (friends.get_val3(a) != 6)
|
||||
throw new Exception("failed");
|
||||
|
||||
// nice overload working fine
|
||||
if (friends.get_val1(1,2,3) != 1)
|
||||
throw new Exception("failed");
|
||||
|
||||
B b = new B(3);
|
||||
|
||||
// David's case
|
||||
if (friends.mix(a,b) != 5)
|
||||
throw new Exception("failed");
|
||||
|
||||
D_d di = new D_d(2);
|
||||
D_d dd = new D_d(3.3);
|
||||
|
||||
// incredible template overloading working just fine
|
||||
if (friends.get_val1(di) != 2)
|
||||
throw new Exception("failed");
|
||||
if (friends.get_val1(dd) != 3.3)
|
||||
throw new Exception("failed");
|
||||
|
||||
friends.set(di, 4);
|
||||
friends.set(dd, 1.3);
|
||||
|
||||
if (friends.get_val1(di) != 4)
|
||||
throw new Exception("failed");
|
||||
if (friends.get_val1(dd) != 1.3)
|
||||
throw new Exception("failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -68,6 +68,7 @@ public class li_std_map_runme {
|
|||
{
|
||||
IList<string> keys = new List<string>(simap.Keys);
|
||||
IList<int> values = new List<int>(simap.Values);
|
||||
Dictionary<string, int> check = new Dictionary<string, int>();
|
||||
if (keys.Count != collectionSize)
|
||||
throw new Exception("Keys count test failed");
|
||||
|
||||
|
|
@ -78,6 +79,13 @@ public class li_std_map_runme {
|
|||
{
|
||||
if (simap[keys[i]] != values[i])
|
||||
throw new Exception("Keys and values test failed for index " + i);
|
||||
check.Add(keys[i], values[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < collectionSize; i++)
|
||||
{
|
||||
if (!check.ContainsKey(i.ToString()))
|
||||
throw new Exception("Keys and Values ContainsKey test " + i + " failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ using System;
|
|||
|
||||
public class runme
|
||||
{
|
||||
static void Main()
|
||||
static void Main()
|
||||
{
|
||||
// constructors and destructors
|
||||
nspaceNamespace.Outer.Inner1.Color color1 = new nspaceNamespace.Outer.Inner1.Color();
|
||||
|
|
@ -62,7 +62,7 @@ public class runme
|
|||
throw new ApplicationException("Transmission2 wrong");
|
||||
|
||||
// turn feature off / ignoring
|
||||
nspaceNamespace.Outer.nspace ns = new nspaceNamespace.Outer.nspace();
|
||||
nspaceNamespace.Outer.namespce ns = new nspaceNamespace.Outer.namespce();
|
||||
ns.Dispose();
|
||||
nspaceNamespace.NoNSpacePlease nons = new nspaceNamespace.NoNSpacePlease();
|
||||
nons.Dispose();
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ public class pointer_reference_runme {
|
|||
Struct ss = new Struct(20);
|
||||
pointer_reference.set(ss);
|
||||
if (Struct.instance.value != 20) throw new Exception("set test failed");
|
||||
|
||||
if (pointer_reference.overloading(1) != 111) throw new Exception("overload test 1 failed");
|
||||
if (pointer_reference.overloading(ss) != 222) throw new Exception("overload test 2 failed");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
12
Examples/test-suite/csharp/rename_pcre_encoder_runme.cs
Normal file
12
Examples/test-suite/csharp/rename_pcre_encoder_runme.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
using rename_pcre_encoderNamespace;
|
||||
|
||||
public class runme {
|
||||
static void Main() {
|
||||
SomeWidget w = new SomeWidget();
|
||||
w.putBorderWidth(17);
|
||||
if ( w.getBorderWidth() != 17 )
|
||||
throw new Exception(String.Format("Border with should be 17, not {0}",
|
||||
w.getBorderWidth()));
|
||||
}
|
||||
}
|
||||
30
Examples/test-suite/csharp/rename_simple_runme.cs
Normal file
30
Examples/test-suite/csharp/rename_simple_runme.cs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
|
||||
using System;
|
||||
using rename_simpleNamespace;
|
||||
|
||||
public class rename_simple_runme {
|
||||
|
||||
public static void Main() {
|
||||
NewStruct s = new NewStruct();
|
||||
check(111, s.NewInstanceVariable, "NewInstanceVariable");
|
||||
check(222, s.NewInstanceMethod(), "NewInstanceMethod");
|
||||
check(333, NewStruct.NewStaticMethod(), "NewStaticMethod");
|
||||
check(444, NewStruct.NewStaticVariable, "NewStaticVariable");
|
||||
check(555, rename_simple.NewFunction(), "NewFunction");
|
||||
check(666, rename_simple.NewGlobalVariable, "NewGlobalVariable");
|
||||
|
||||
s.NewInstanceVariable = 1111;
|
||||
NewStruct.NewStaticVariable = 4444;
|
||||
rename_simple.NewGlobalVariable = 6666;
|
||||
|
||||
check(1111, s.NewInstanceVariable, "NewInstanceVariable");
|
||||
check(4444, NewStruct.NewStaticVariable, "NewStaticVariable");
|
||||
check(6666, rename_simple.NewGlobalVariable, "NewGlobalVariable");
|
||||
}
|
||||
|
||||
public static void check(int expected, int actual, string msg) {
|
||||
if (expected != actual)
|
||||
throw new Exception("Failed: Expected: " + expected + " actual: " + actual + " " + msg);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue