Fixes to run on Mono 1.1
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7032 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
fd1f0b5df6
commit
9f10b7bff0
1 changed files with 25 additions and 22 deletions
|
|
@ -46,7 +46,7 @@ public class runme
|
||||||
try {
|
try {
|
||||||
csharp_exceptions.ExceptionSpecificationInteger();
|
csharp_exceptions.ExceptionSpecificationInteger();
|
||||||
testFailed = true;
|
testFailed = true;
|
||||||
} catch (ApplicationException e) {
|
} catch (ApplicationException) {
|
||||||
}
|
}
|
||||||
if (testFailed) throw new Exception("ExceptionSpecificationInteger not working");
|
if (testFailed) throw new Exception("ExceptionSpecificationInteger not working");
|
||||||
|
|
||||||
|
|
@ -106,81 +106,82 @@ public class runme
|
||||||
try {
|
try {
|
||||||
csharp_exceptions.MemoryLeakCheck();
|
csharp_exceptions.MemoryLeakCheck();
|
||||||
throw new Exception("MemoryLeakCheck not working");
|
throw new Exception("MemoryLeakCheck not working");
|
||||||
} catch (DivideByZeroException e) {
|
} catch (DivideByZeroException) {
|
||||||
}
|
}
|
||||||
if (Counter.count != 0) throw new Exception("Memory leaks when throwing exception. count: " + Counter.count);
|
if (Counter.count != 0) throw new Exception("Memory leaks when throwing exception. count: " + Counter.count);
|
||||||
|
|
||||||
// test exception pending in the csconstruct typemap
|
// test exception pending in the csconstruct typemap
|
||||||
try {
|
try {
|
||||||
constructor c = new constructor(null);
|
new constructor(null);
|
||||||
throw new Exception("constructor 1 not working");
|
throw new Exception("constructor 1 not working");
|
||||||
} catch (NullReferenceException e) {
|
} catch (NullReferenceException) {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
constructor c = new constructor();
|
new constructor();
|
||||||
throw new Exception("constructor 2 not working");
|
throw new Exception("constructor 2 not working");
|
||||||
} catch (ApplicationException e) {
|
} catch (ApplicationException) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test exception pending in the csout typemaps
|
// test exception pending in the csout typemaps
|
||||||
try {
|
try {
|
||||||
csharp_exceptions.ushorttest();
|
csharp_exceptions.ushorttest();
|
||||||
throw new Exception("csout not working");
|
throw new Exception("csout not working");
|
||||||
} catch (IndexOutOfRangeException e) {
|
} catch (IndexOutOfRangeException) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test exception pending in the csvarout/csvarin typemaps and canthrow attribute in unmanaged code typemaps (1) global variables
|
// test exception pending in the csvarout/csvarin typemaps and canthrow attribute in unmanaged code typemaps (1) global variables
|
||||||
// 1) global variables
|
// 1) global variables
|
||||||
|
int numberout = 0;
|
||||||
try {
|
try {
|
||||||
csharp_exceptions.numberin = -1;
|
csharp_exceptions.numberin = -1;
|
||||||
throw new Exception("global csvarin not working");
|
throw new Exception("global csvarin not working");
|
||||||
} catch (IndexOutOfRangeException e) {
|
} catch (IndexOutOfRangeException) {
|
||||||
}
|
}
|
||||||
csharp_exceptions.numberin = 5;
|
csharp_exceptions.numberin = 5;
|
||||||
if (csharp_exceptions.numberin != 5)
|
if (csharp_exceptions.numberin != 5)
|
||||||
throw new Exception("global numberin not 5");
|
throw new Exception("global numberin not 5");
|
||||||
csharp_exceptions.numberout = 20;
|
csharp_exceptions.numberout = 20;
|
||||||
try {
|
try {
|
||||||
int numberout = csharp_exceptions.numberout;
|
numberout += csharp_exceptions.numberout;
|
||||||
throw new Exception("global csvarout not working");
|
throw new Exception("global csvarout not working");
|
||||||
} catch (IndexOutOfRangeException e) {
|
} catch (IndexOutOfRangeException) {
|
||||||
}
|
}
|
||||||
// 2) static member variables
|
// 2) static member variables
|
||||||
try {
|
try {
|
||||||
InOutStruct.staticnumberin = -1;
|
InOutStruct.staticnumberin = -1;
|
||||||
throw new Exception("static csvarin not working");
|
throw new Exception("static csvarin not working");
|
||||||
} catch (IndexOutOfRangeException e) {
|
} catch (IndexOutOfRangeException) {
|
||||||
}
|
}
|
||||||
InOutStruct.staticnumberin = 5;
|
InOutStruct.staticnumberin = 5;
|
||||||
if (InOutStruct.staticnumberin != 5)
|
if (InOutStruct.staticnumberin != 5)
|
||||||
throw new Exception("static staticnumberin not 5");
|
throw new Exception("static staticnumberin not 5");
|
||||||
InOutStruct.staticnumberout = 20;
|
InOutStruct.staticnumberout = 20;
|
||||||
try {
|
try {
|
||||||
int numberout = InOutStruct.staticnumberout;
|
numberout += InOutStruct.staticnumberout;
|
||||||
throw new Exception("static csvarout not working");
|
throw new Exception("static csvarout not working");
|
||||||
} catch (IndexOutOfRangeException e) {
|
} catch (IndexOutOfRangeException) {
|
||||||
}
|
}
|
||||||
// 3) member variables
|
// 3) member variables
|
||||||
InOutStruct io = new InOutStruct();
|
InOutStruct io = new InOutStruct();
|
||||||
try {
|
try {
|
||||||
io.numberin = -1;
|
io.numberin = -1;
|
||||||
throw new Exception("member csvarin not working");
|
throw new Exception("member csvarin not working");
|
||||||
} catch (IndexOutOfRangeException e) {
|
} catch (IndexOutOfRangeException) {
|
||||||
}
|
}
|
||||||
io.numberin = 5;
|
io.numberin = 5;
|
||||||
if (io.numberin != 5)
|
if (io.numberin != 5)
|
||||||
throw new Exception("member numberin not 5");
|
throw new Exception("member numberin not 5");
|
||||||
io.numberout = 20;
|
io.numberout = 20;
|
||||||
try {
|
try {
|
||||||
int numberout = io.numberout;
|
numberout += io.numberout;
|
||||||
throw new Exception("member csvarout not working");
|
throw new Exception("member csvarout not working");
|
||||||
} catch (IndexOutOfRangeException e) {
|
} catch (IndexOutOfRangeException) {
|
||||||
}
|
}
|
||||||
// test SWIG_exception macro - it must return from unmanaged code without executing any further unmanaged code
|
// test SWIG_exception macro - it must return from unmanaged code without executing any further unmanaged code
|
||||||
try {
|
try {
|
||||||
csharp_exceptions.exceptionmacrotest(-1);
|
csharp_exceptions.exceptionmacrotest(-1);
|
||||||
throw new Exception("exception macro not working");
|
throw new Exception("exception macro not working");
|
||||||
} catch (IndexOutOfRangeException e) {
|
} catch (IndexOutOfRangeException) {
|
||||||
}
|
}
|
||||||
if (csharp_exceptions.exception_macro_run_flag)
|
if (csharp_exceptions.exception_macro_run_flag)
|
||||||
throw new Exception("exceptionmacrotest was executed");
|
throw new Exception("exceptionmacrotest was executed");
|
||||||
|
|
@ -251,21 +252,21 @@ public class runme
|
||||||
csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedArgumentException);
|
csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedArgumentException);
|
||||||
throw new Exception("ArgumentException not caught");
|
throw new Exception("ArgumentException not caught");
|
||||||
} catch (ArgumentException e) {
|
} catch (ArgumentException e) {
|
||||||
if (e.Message != "msg\nParameter name: parm") throw new Exception("ArgumentException msg incorrect");
|
if (e.Message.Replace(CRLF,"\n") != "msg\nParameter name: parm") throw new Exception("ArgumentException msg incorrect");
|
||||||
if (e.ParamName != "parm") throw new Exception("ArgumentException parm incorrect");
|
if (e.ParamName != "parm") throw new Exception("ArgumentException parm incorrect");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedArgumentNullException);
|
csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedArgumentNullException);
|
||||||
throw new Exception("ArgumentNullException not caught");
|
throw new Exception("ArgumentNullException not caught");
|
||||||
} catch (ArgumentNullException e) {
|
} catch (ArgumentNullException e) {
|
||||||
if (e.Message != "msg\nParameter name: parm") throw new Exception("ArgumentNullException msg incorrect");
|
if (e.Message.Replace(CRLF,"\n") != "msg\nParameter name: parm") throw new Exception("ArgumentNullException msg incorrect");
|
||||||
if (e.ParamName != "parm") throw new Exception("ArgumentNullException parm incorrect");
|
if (e.ParamName != "parm") throw new Exception("ArgumentNullException parm incorrect");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedArgumentOutOfRangeException);
|
csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedArgumentOutOfRangeException);
|
||||||
throw new Exception("ArgumentOutOfRangeException not caught");
|
throw new Exception("ArgumentOutOfRangeException not caught");
|
||||||
} catch (ArgumentOutOfRangeException e) {
|
} catch (ArgumentOutOfRangeException e) {
|
||||||
if (e.Message != "msg\nParameter name: parm") throw new Exception("ArgumentOutOfRangeException msg incorrect");
|
if (e.Message.Replace(CRLF,"\n") != "msg\nParameter name: parm") throw new Exception("ArgumentOutOfRangeException msg incorrect");
|
||||||
if (e.ParamName != "parm") throw new Exception("ArgumentOutOfRangeException parm incorrect");
|
if (e.ParamName != "parm") throw new Exception("ArgumentOutOfRangeException parm incorrect");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -277,6 +278,7 @@ public class runme
|
||||||
Thread[] threads = new Thread[NUM_THREADS];
|
Thread[] threads = new Thread[NUM_THREADS];
|
||||||
TestThread[] testThreads = new TestThread[NUM_THREADS];
|
TestThread[] testThreads = new TestThread[NUM_THREADS];
|
||||||
// invoke the threads
|
// invoke the threads
|
||||||
|
Console.WriteLine("Thread tests");
|
||||||
for (int i=0; i<NUM_THREADS; i++) {
|
for (int i=0; i<NUM_THREADS; i++) {
|
||||||
testThreads[i] = new TestThread(throwsClass, i);
|
testThreads[i] = new TestThread(throwsClass, i);
|
||||||
threads[i] = new Thread(new ThreadStart(testThreads[i].Run));
|
threads[i] = new Thread(new ThreadStart(testThreads[i].Run));
|
||||||
|
|
@ -291,6 +293,7 @@ public class runme
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static string CRLF = "\r\n"; // Some CLR implementations use a CRLF instead of just CR
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TestThread {
|
public class TestThread {
|
||||||
|
|
@ -304,13 +307,13 @@ public class TestThread {
|
||||||
public void Run() {
|
public void Run() {
|
||||||
Failed = false;
|
Failed = false;
|
||||||
try {
|
try {
|
||||||
for (int i=0; i<4000; i++) { // run test for about 10 seconds on a 1GHz machine
|
for (int i=0; i<80000; i++) { // run test for about 30 seconds on a 1GHz machine
|
||||||
try {
|
try {
|
||||||
throwsClass.ThrowException(i);
|
throwsClass.ThrowException(i);
|
||||||
throw new Exception("No exception thrown");
|
throw new Exception("No exception thrown");
|
||||||
} catch (ArgumentOutOfRangeException e) {
|
} catch (ArgumentOutOfRangeException e) {
|
||||||
String expectedMessage = "caught:" + i + "\n" + "Parameter name: input";
|
String expectedMessage = "caught:" + i + "\n" + "Parameter name: input";
|
||||||
if (e.Message != expectedMessage)
|
if (e.Message.Replace(runme.CRLF,"\n") != expectedMessage)
|
||||||
throw new Exception("Exception message incorrect. Expected:\n[" + expectedMessage + "]\n" + "Received:\n[" + e.Message + "]");
|
throw new Exception("Exception message incorrect. Expected:\n[" + expectedMessage + "]\n" + "Received:\n[" + e.Message + "]");
|
||||||
if (e.ParamName != "input")
|
if (e.ParamName != "input")
|
||||||
throw new Exception("Exception ParamName incorrect. Expected:\n[input]\n" + "Received:\n[" + e.ParamName + "]");
|
throw new Exception("Exception ParamName incorrect. Expected:\n[input]\n" + "Received:\n[" + e.ParamName + "]");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue