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