scilab: implement & fix throw_exception test
This commit is contained in:
parent
1c207f76d0
commit
7bc8201719
3 changed files with 46 additions and 10 deletions
27
Examples/test-suite/scilab/throw_exception_runme.sci
Normal file
27
Examples/test-suite/scilab/throw_exception_runme.sci
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
exec("swigtest.start", -1);
|
||||
|
||||
foo = new_Foo();
|
||||
|
||||
ierr = execstr("Foo_test_int(foo)", 'errcatch');
|
||||
checkequal(ierr, 999, "Foo_test_int(foo): ierr");
|
||||
checkequal(lasterror(), "Exception (int) occured: 37", "Foo_test_int(foo): msg");
|
||||
|
||||
ierr = execstr("Foo_test_msg(foo)", 'errcatch');
|
||||
checkequal(ierr, 999, "Foo_test_msg(foo): ierr");
|
||||
checkequal(lasterror(), "Exception (char const *) occured: Dead", "Foo_test_msg(foo): msg");
|
||||
|
||||
ierr = execstr("Foo_test_multi(foo, 1)", 'errcatch');
|
||||
checkequal(ierr, 999, "Foo_test_multi(foo, 1): ierr");
|
||||
checkequal(lasterror(), "Exception (int) occured: 37", "Foo_test_multi(foo, 1): msg");
|
||||
|
||||
ierr = execstr("Foo_test_multi(foo, 2)", 'errcatch');
|
||||
checkequal(ierr, 999, "Foo_test_multi(foo, 2): ierr");
|
||||
checkequal(lasterror(), "Exception (char const *) occured: Dead", "Foo_test_multi(foo, 2): msg");
|
||||
|
||||
ierr = execstr("Foo_test_cls(foo)", 'errcatch');
|
||||
checkequal(ierr, 998, "Foo_test_cls(foo): ierr");
|
||||
checkequal(lasterror(), "Exception (Error) occured.", "Foo_test_cls(foo): msg");
|
||||
|
||||
delete_Foo(foo);
|
||||
|
||||
exec("swigtest.quit", -1);
|
||||
|
|
@ -236,14 +236,16 @@ SWIG_Scilab_ErrorMsg(int code, const char *msg)
|
|||
|
||||
|
||||
SWIGRUNTIME int
|
||||
SwigScilabRaise(const char *type) {
|
||||
Scierror(999, "An exception of type %s has been thrown.\n", type);
|
||||
#ifdef __cplusplus
|
||||
throw;
|
||||
#endif
|
||||
SwigScilabRaise(const char *obj, const char *type, swig_type_info *descriptor) {
|
||||
if (type) {
|
||||
if (obj)
|
||||
Scierror(999, "Exception (%s) occured: %s\n", type, obj);
|
||||
else
|
||||
Scierror(999, "Exception (%s) occured.\n", type);
|
||||
}
|
||||
}
|
||||
|
||||
#define SWIG_Scilab_Raise(obj, type, desc) SwigScilabRaise(type)
|
||||
#define SWIG_Scilab_Raise(obj, type, descriptor) SwigScilabRaise(obj, type, descriptor)
|
||||
|
||||
/*
|
||||
* Pointer utility functions
|
||||
|
|
|
|||
|
|
@ -18,12 +18,12 @@
|
|||
|
||||
/* ---------------------------------------------------------------------------*/
|
||||
/* Generic typmemaps */
|
||||
/* */
|
||||
/* This typemap is used when Scilab does not store this type directly */
|
||||
/* For example, a 'float' is stored in Scilab as a 'double' */
|
||||
/* So we read a 'double' in Scilab and cast it to a 'float' */
|
||||
/* ---------------------------------------------------------------------------*/
|
||||
|
||||
* This typemap is used when Scilab does not store this type directly
|
||||
* For example, a 'float' is stored in Scilab as a 'double'
|
||||
* So we read a 'double' in Scilab and cast it to a 'float'
|
||||
*/
|
||||
%define %scilab_in_typemap_withcast(TYPEMAPTYPE, FRAGMENTNAME, CTYPE, TEMPTYPE, TEMPINIT)
|
||||
%typemap(TYPEMAPTYPE, fragment="FRAGMENTNAME") CTYPE {
|
||||
TEMPTYPE tempValue = TEMPINIT;
|
||||
|
|
@ -203,3 +203,10 @@
|
|||
if (SWIG_CreateScilabVariable_double(pvApiCtx, "$result", $value) != SWIG_OK)
|
||||
return SWIG_ERROR;
|
||||
%}
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------*/
|
||||
/* Exception typmemaps */
|
||||
/* ---------------------------------------------------------------------------*/
|
||||
|
||||
%include "sciexception.swg"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue