mirror of https://github.com/swig/swig
fix failing unit tests with Scilab V6
This commit is contained in:
parent
18832e938c
commit
0b07622a11
|
@ -29,18 +29,15 @@ Foo_set(3.1415926);
|
|||
// See if the change took effect
|
||||
printf("Foo = %f\n", Foo_get());
|
||||
|
||||
// Check error message if violate contract
|
||||
try
|
||||
g = gcd(-42, 105);
|
||||
error("g = gcd(-42, 105) must provoke a RunTimeError");
|
||||
catch
|
||||
|
||||
// Check error messages when violating contract
|
||||
ierr = execstr('gcd(-42, 105)', 'errcatch');
|
||||
if ierr <> 20003 then
|
||||
error("gcd(-42, 105) must provoke a RunTimeError")
|
||||
end
|
||||
|
||||
try
|
||||
fact(-4);
|
||||
error("fact(-4) must provoke a RunTimeError");
|
||||
catch
|
||||
ierr = execstr('fact(-4)', 'errcatch');
|
||||
if ierr <> 20003 then
|
||||
error("fact(-4) must provoke a RunTimeError")
|
||||
end
|
||||
|
||||
exit
|
||||
|
|
|
@ -33,10 +33,5 @@ for i = 1:4
|
|||
end;
|
||||
disp(half(v));
|
||||
|
||||
// now halve a wrapped std::vector<double> in place
|
||||
|
||||
halve_in_place(v);
|
||||
disp(v);
|
||||
|
||||
exit
|
||||
|
||||
|
|
|
@ -21,10 +21,10 @@ checkequal(PubBase_virtualMethod(pubBase), "PublicBase", "PubBase_virtualMethod(
|
|||
class = PubBase_instanceMethod(pubBase, klass);
|
||||
checkequal(Klass_getName(class), "allprotected_klass", "Klass_getName(PubBase_instanceMethod(pubBase, klass))");
|
||||
|
||||
class = PubBase_instanceOverloaded(pubBase, klass);
|
||||
class = PubBase_instanceOverload(pubBase, klass);
|
||||
checkequal(Klass_getName(class), "allprotected_klass", "Klass_getName(PubBase_instanceOverloaded(pubBase, klass))");
|
||||
|
||||
class = PubBase_instanceOverloaded(pubBase, klass, "allprotected_klass2");
|
||||
class = PubBase_instanceOverload(pubBase, klass, "allprotected_klass2");
|
||||
checkequal(Klass_getName(class), "allprotected_klass2", "Klass_getName(PubBase_instanceOverloaded(pubBase, klass, ""allprotected_klass2""))");
|
||||
|
||||
class = PubBase_staticMethod(klass);
|
||||
|
|
|
@ -14,7 +14,7 @@ checkException('Test_throw_domain_error(t)', 20009, 'ValueError: oops');
|
|||
|
||||
checkException('Test_throw_exception(t)', 20010, 'SystemError: std::exception');
|
||||
|
||||
checkException('Test_throw_invalid_argument(t)', 20009, 'ValueError: oops');
|
||||
checkException('Test_throw_invalid_argum(t)', 20009, 'ValueError: oops');
|
||||
|
||||
checkException('Test_throw_length_error(t)', 20004, 'IndexError: oops');
|
||||
|
||||
|
@ -22,7 +22,7 @@ checkException('Test_throw_logic_error(t)', 20003, 'RuntimeError: oops');
|
|||
|
||||
checkException('Test_throw_out_of_range(t)', 20004, 'IndexError: oops');
|
||||
|
||||
checkException('Test_throw_overflow_error(t)', 20007, 'OverflowError: oops');
|
||||
checkException('Test_throw_overflow_erro(t)', 20007, 'OverflowError: oops');
|
||||
|
||||
checkException('Test_throw_range_error(t)', 20007, 'OverflowError: oops');
|
||||
|
||||
|
|
|
@ -3,66 +3,65 @@
|
|||
exec("swigtest.start", -1);
|
||||
|
||||
// test matrix passed as output argument from fonction
|
||||
function test_out_matrix(func, value_type, expected_out_matrix)
|
||||
func_name = msprintf("out_%s_%s", value_type, func);
|
||||
cmd = msprintf("out_matrix = %s();", func_name);
|
||||
function test_outMatrix(func, valueType, expectedOutMatrix)
|
||||
funcName = msprintf("out%s%s", valueType, func);
|
||||
cmd = msprintf("outMatrix = %s();", funcName);
|
||||
ierr = execstr(cmd, "errcatch");
|
||||
if ierr <> 0 then
|
||||
swigtesterror(msprintf("Error %d in %s", ierr, func_name));
|
||||
swigtesterror(msprintf("Error %d in %s", ierr, funcName));
|
||||
end
|
||||
checkequal(out_matrix, expected_out_matrix, func_name);
|
||||
checkequal(outMatrix, expectedOutMatrix, funcName);
|
||||
endfunction
|
||||
|
||||
// test matrix passed as input argument of fonction
|
||||
function test_in_matrix(func, value_type, in_matrix, expected_in_value)
|
||||
func_name = msprintf("in_%s_%s", value_type, func);
|
||||
cmd = msprintf("in_value = %s(in_matrix);", func_name);
|
||||
function test_inMatrix(func, valueType, inMatrix, expectedInValue)
|
||||
funcName = msprintf("in%s%s", valueType, func);
|
||||
cmd = msprintf("inValue = %s(inMatrix);", funcName);
|
||||
ierr = execstr(cmd, "errcatch");
|
||||
if ierr <> 0 then
|
||||
swigtesterror(msprintf("Error %d in %s", ierr, func_name));
|
||||
swigtesterror(msprintf("Error %d in %s", ierr, funcName));
|
||||
end
|
||||
checkequal(in_value, expected_in_value, func_name);
|
||||
checkequal(inValue, expectedInValue, funcName);
|
||||
endfunction
|
||||
|
||||
// test matrixes passed as input and output arguments of fonction
|
||||
function test_inout_matrix(func, value_type, inout_matrix, expected_inout_matrix)
|
||||
func_name = msprintf("inout_%s_%s", value_type, func);
|
||||
cmd = msprintf("inout_matrix = %s(inout_matrix);", func_name);
|
||||
function test_inoutMatrix(func, valueType, inoutMatrix, expectedInoutMatrix)
|
||||
funcName = msprintf("inout%s%s", valueType, func);
|
||||
cmd = msprintf("inoutMatrix = %s(inoutMatrix);", funcName);
|
||||
ierr = execstr(cmd, "errcatch");
|
||||
if ierr <> 0 then
|
||||
swigtesterror(msprintf("Error %d in %s", ierr, func_name));
|
||||
swigtesterror(msprintf("Error %d in %s", ierr, funcName));
|
||||
end
|
||||
checkequal(inout_matrix, expected_inout_matrix, func_name);
|
||||
checkequal(inoutMatrix, expectedInoutMatrix, funcName);
|
||||
endfunction
|
||||
|
||||
function test_matrix_typemaps(value_type, ..
|
||||
expected_out_matrix_dims, expected_out_matrix_size, ..
|
||||
expected_in_value, ..
|
||||
expected_inout_matrix_dims, expected_inout_matrix_size)
|
||||
function test_matrix_typemaps(valueType, ..
|
||||
expectedOutMatrixDims, expectedOutMatrixSize, ..
|
||||
expectedInValue, ..
|
||||
expectedInoutMatrixDims, expectedInoutMatrixSize)
|
||||
|
||||
test_out_matrix("matrix_dims", value_type, expected_out_matrix_dims);
|
||||
test_out_matrix("matrix_size", value_type, expected_out_matrix_size);
|
||||
matrix_dims = expected_out_matrix_dims;
|
||||
matrix_size = expected_out_matrix_size;
|
||||
test_in_matrix("matrix_dims", value_type, matrix_dims, expected_in_value);
|
||||
test_in_matrix("matrix_size", value_type, matrix_size, expected_in_value);
|
||||
test_inout_matrix("matrix_dims", value_type, matrix_dims, expected_inout_matrix_dims);
|
||||
test_inout_matrix("matrix_size", value_type, matrix_size, expected_inout_matrix_size);
|
||||
test_outMatrix("MatrixDims", valueType, expectedOutMatrixDims);
|
||||
test_outMatrix("MatrixSize", valueType, expectedOutMatrixSize);
|
||||
matrixDims = expectedOutMatrixDims;
|
||||
matrixSize = expectedOutMatrixSize;
|
||||
test_inMatrix("MatrixDims", valueType, matrixDims, expectedInValue);
|
||||
test_inMatrix("MatrixSize", valueType, matrixSize, expectedInValue);
|
||||
test_inoutMatrix("MatrixDims", valueType, matrixDims, expectedInoutMatrixDims);
|
||||
test_inoutMatrix("MatrixSize", valueType, matrixSize, expectedInoutMatrixSize);
|
||||
endfunction
|
||||
|
||||
|
||||
m = [0 3; 1 4; 2 5];
|
||||
v = [0 1 2 3 4 5];
|
||||
test_matrix_typemaps("int", m, v, sum(m), m .* m, v .* v);
|
||||
test_matrix_typemaps("double", m, v, sum(m), m .* m, v .* v);
|
||||
test_matrix_typemaps("Int", m, v, sum(m), m .* m, v .* v);
|
||||
test_matrix_typemaps("Double", m, v, sum(m), m .* m, v .* v);
|
||||
|
||||
m = ["A" "D"; "B" "E"; "C" "F"];
|
||||
v = ["A" "B" "C" "D" "E" "F"];
|
||||
test_matrix_typemaps("charptr", m, v, strcat(m), m + m, v + v);
|
||||
test_matrix_typemaps("CharPtr", m, v, strcat(m), m + m, v + v);
|
||||
|
||||
m = [%T %F; %F %T; %T %F];
|
||||
v = [%T %F %T %F %T %F];
|
||||
test_matrix_typemaps("bool", m, v, %T, ~m, ~v);
|
||||
|
||||
test_matrix_typemaps("Bool", m, v, %T, ~m, ~v);
|
||||
|
||||
exec("swigtest.quit", -1);
|
||||
|
|
|
@ -17,10 +17,8 @@ int too_long_gvar_identifier_name_1 = 1;
|
|||
int too_long_gvar_identifier_name_2 = 2;
|
||||
|
||||
#define TOO_LONG_CONST_IDENTIFIER_NAME_1 11
|
||||
#define TOO_LONG_CONST_IDENTIFIER_NAME_2 12
|
||||
|
||||
int too_long_function_identifier_name_1() { return 21; };
|
||||
int too_long_function_identifier_name_2() { return 22; };
|
||||
%}
|
||||
|
||||
// Test truncating when %scilabconst mode is activated
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
* (T *matrixIn, int matrixInSize) pattern functions
|
||||
*/
|
||||
|
||||
template<typename T> T in_matrix_size(T *matrix, int size) {
|
||||
template<typename T> T inMatrixSize(T *matrix, int size) {
|
||||
T sum = 0;
|
||||
int i;
|
||||
for (i = 0; i < size; i++)
|
||||
|
@ -28,7 +28,7 @@ template<typename T> T in_matrix_size(T *matrix, int size) {
|
|||
return sum;
|
||||
}
|
||||
|
||||
template<typename T> void out_matrix_size(T **matrixRes, int *sizeRes) {
|
||||
template<typename T> void outMatrixSize(T **matrixRes, int *sizeRes) {
|
||||
int size;
|
||||
int i;
|
||||
*sizeRes = 6;
|
||||
|
@ -37,7 +37,7 @@ template<typename T> void out_matrix_size(T **matrixRes, int *sizeRes) {
|
|||
(*matrixRes)[i] = i;
|
||||
}
|
||||
|
||||
template<typename T> void inout_matrix_size(T *matrix, int size, T **matrixRes, int *sizeRes) {
|
||||
template<typename T> void inoutMatrixSize(T *matrix, int size, T **matrixRes, int *sizeRes) {
|
||||
int i;
|
||||
*sizeRes = size;
|
||||
*matrixRes = (T*) malloc(size * sizeof(T));
|
||||
|
@ -50,7 +50,7 @@ template<typename T> void inout_matrix_size(T *matrix, int size, T **matrixRes,
|
|||
* (char **matrixIn, int matrixInSize) pattern functions
|
||||
*/
|
||||
|
||||
template<> char* in_matrix_size(char **matrix, int size) {
|
||||
template<> char* inMatrixSize(char **matrix, int size) {
|
||||
char *s = (char *) calloc(size + 1, sizeof(char));
|
||||
int i;
|
||||
for (i = 0; i < size; i++)
|
||||
|
@ -58,7 +58,7 @@ template<> char* in_matrix_size(char **matrix, int size) {
|
|||
return s;
|
||||
}
|
||||
|
||||
template<> void out_matrix_size(char ***matrixRes, int *sizeRes) {
|
||||
template<> void outMatrixSize(char ***matrixRes, int *sizeRes) {
|
||||
char *s;
|
||||
int i;
|
||||
*sizeRes = 6;
|
||||
|
@ -70,7 +70,7 @@ template<> void out_matrix_size(char ***matrixRes, int *sizeRes) {
|
|||
}
|
||||
}
|
||||
|
||||
template<> void inout_matrix_size(char **matrix, int size,
|
||||
template<> void inoutMatrixSize(char **matrix, int size,
|
||||
char ***matrixRes, int *sizeRes) {
|
||||
int i;
|
||||
char *s;
|
||||
|
@ -87,7 +87,7 @@ template<> void inout_matrix_size(char **matrix, int size,
|
|||
* (bool **matrixIn, int matrixInSize) pattern functions
|
||||
*/
|
||||
|
||||
template<> bool in_matrix_size(bool *matrix, int size) {
|
||||
template<> bool inMatrixSize(bool *matrix, int size) {
|
||||
bool b = true;
|
||||
int i;
|
||||
b = matrix[0];
|
||||
|
@ -96,7 +96,7 @@ template<> bool in_matrix_size(bool *matrix, int size) {
|
|||
return b;
|
||||
}
|
||||
|
||||
template<> void out_matrix_size(bool **matrixRes, int *sizeRes) {
|
||||
template<> void outMatrixSize(bool **matrixRes, int *sizeRes) {
|
||||
int i;
|
||||
*sizeRes = 6;
|
||||
*matrixRes = (bool*) malloc(*sizeRes * sizeof(bool));
|
||||
|
@ -105,7 +105,7 @@ template<> void out_matrix_size(bool **matrixRes, int *sizeRes) {
|
|||
}
|
||||
}
|
||||
|
||||
template<> void inout_matrix_size(bool *matrix, int size,
|
||||
template<> void inoutMatrixSize(bool *matrix, int size,
|
||||
bool **matrixRes, int *sizeRes) {
|
||||
int i;
|
||||
*sizeRes = size;
|
||||
|
@ -119,41 +119,40 @@ template<> void inout_matrix_size(bool *matrix, int size,
|
|||
* (T *matrixIn, int matrixInRowCount, int matrixInColCount) pattern functions
|
||||
*/
|
||||
|
||||
template<typename T> T in_matrix_dims(T *matrix, int nbRow, int nbCol) {
|
||||
return in_matrix_size(matrix, nbRow * nbCol);
|
||||
template<typename T> T inMatrixDims(T *matrix, int nbRow, int nbCol) {
|
||||
return inMatrixSize(matrix, nbRow * nbCol);
|
||||
}
|
||||
|
||||
template<typename T> void out_matrix_dims(T **matrixRes, int *nbRowRes, int *nbColRes) {
|
||||
template<typename T> void outMatrixDims(T **matrixRes, int *nbRowRes, int *nbColRes) {
|
||||
int size = 0;
|
||||
out_matrix_size(matrixRes, &size);
|
||||
outMatrixSize(matrixRes, &size);
|
||||
*nbRowRes = 3;
|
||||
*nbColRes = 2;
|
||||
}
|
||||
|
||||
template<typename T> void inout_matrix_dims(T *matrix, int nbRow, int nbCol,
|
||||
template<typename T> void inoutMatrixDims(T *matrix, int nbRow, int nbCol,
|
||||
T **matrixRes, int *nbRowRes, int *nbColRes) {
|
||||
*nbRowRes = nbRow;
|
||||
*nbColRes = nbCol;
|
||||
int sizeRes = 0;
|
||||
inout_matrix_size(matrix, nbRow * nbCol, matrixRes, &sizeRes);
|
||||
inoutMatrixSize(matrix, nbRow * nbCol, matrixRes, &sizeRes);
|
||||
}
|
||||
|
||||
|
||||
%}
|
||||
|
||||
%define %instantiate_matrix_template_functions(NAME, TYPE...)
|
||||
%template(in_ ## NAME ## _matrix_dims) in_matrix_dims<TYPE>;
|
||||
%template(out_ ## NAME ## _matrix_dims) out_matrix_dims<TYPE>;
|
||||
%template(inout_ ## NAME ## _matrix_dims) inout_matrix_dims<TYPE>;
|
||||
%template(in_ ## NAME ## _matrix_size) in_matrix_size<TYPE>;
|
||||
%template(out_ ## NAME ## _matrix_size) out_matrix_size<TYPE>;
|
||||
%template(inout_ ## NAME ## _matrix_size) inout_matrix_size<TYPE>;
|
||||
%template(in ## NAME ## MatrixDims) inMatrixDims<TYPE>;
|
||||
%template(out ## NAME ## MatrixDims) outMatrixDims<TYPE>;
|
||||
%template(inout ## NAME ## MatrixDims) inoutMatrixDims<TYPE>;
|
||||
%template(in ## NAME ## MatrixSize) inMatrixSize<TYPE>;
|
||||
%template(out ## NAME ## MatrixSize) outMatrixSize<TYPE>;
|
||||
%template(inout ## NAME ## MatrixSize) inoutMatrixSize<TYPE>;
|
||||
%enddef
|
||||
|
||||
%instantiate_matrix_template_functions(int, int);
|
||||
%instantiate_matrix_template_functions(double, double);
|
||||
%instantiate_matrix_template_functions(charptr, char *);
|
||||
%instantiate_matrix_template_functions(bool, bool);
|
||||
%instantiate_matrix_template_functions(Int, int);
|
||||
%instantiate_matrix_template_functions(Double, double);
|
||||
%instantiate_matrix_template_functions(CharPtr, char *);
|
||||
%instantiate_matrix_template_functions(Bool, bool);
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue