Skip to content

Commit

Permalink
[MATLAB] fixes to test-suite runme files
Browse files Browse the repository at this point in the history
- commented out swig_this tests as we don't have this yet
- changed a few more Octave-syntax expressions to MATLAB
- added a few clarifying messages to calls to error()
  • Loading branch information
KrisThielemans authored and jaeandersson committed Sep 6, 2015
1 parent bcb0b3f commit 8fc108f
Show file tree
Hide file tree
Showing 17 changed files with 87 additions and 76 deletions.
9 changes: 5 additions & 4 deletions Examples/test-suite/matlab/director_unroll_runme.m
Expand Up @@ -9,8 +9,9 @@
b.set(a);
c = b.get();

if (swig_this(a) ~= swig_this(c))
a,c
error
end
% no swig_this yet
%if (swig_this(a) ~= swig_this(c))
% a,c
% error('Failed!!')
%end

9 changes: 5 additions & 4 deletions Examples/test-suite/matlab/imports_runme.m
@@ -1,7 +1,7 @@
% This is the import runtime testcase.

imports_b;
imports_a;
import imports_b.*;
import imports_a.*;

x = imports_b.B();
x.hello();
Expand All @@ -14,5 +14,6 @@

a1.hello();
a2.hello();
assert(swig_this(a1)==swig_this(a2));
assert(strcmp(swig_type(a1),swig_type(a2)));
% no swig_this yet
% assert(swig_this(a1)==swig_this(a2));
% assert(strcmp(swig_type(a1),swig_type(a2)));
2 changes: 1 addition & 1 deletion Examples/test-suite/matlab/li_carrays_runme.m
Expand Up @@ -6,5 +6,5 @@
d(5) = d(0) + 3;

if (d(5) + d(0) ~= 17)
error('Failed!!')
error('Failed!! sum is %g but should be 17', d(5)+d(0))
end
2 changes: 1 addition & 1 deletion Examples/test-suite/matlab/li_cmalloc_runme.m
Expand Up @@ -12,6 +12,6 @@
end

if (ok ~= 1)
error
error('test should have thrown an error')
end

5 changes: 3 additions & 2 deletions Examples/test-suite/matlab/li_std_pair_extra_runme.m
Expand Up @@ -59,11 +59,12 @@

p = li_std_pair_extra.paircA1(1,a);
assert(p.first==1);
assert(swig_this(p.second)==swig_this(a));
% no swig_this yet
% assert(swig_this(p.second)==swig_this(a));

p = li_std_pair_extra.paircA2(1,a);
assert(p.first==1);
assert(swig_this(p.second)==swig_this(a));
%assert(swig_this(p.second)==swig_this(a));
%pp = li_std_pair_extra.pairiiA(1,p); % conversion pb re const of pairA1/A2
pp = li_std_pair_extra.pairiiA(1,{1,A()});

9 changes: 5 additions & 4 deletions Examples/test-suite/matlab/nested_structs_runme.m
Expand Up @@ -2,13 +2,14 @@

named = nested_structs.Named();
named.val = 999;
assert(nested_structs.nestedByVal(named), 999);
assert(nested_structs.nestedByPtr(named), 999);
assert(isequal(nested_structs.nestedByVal(named), 999), 'nested_structs.nestedByVal(named) is %d but should be %d', nested_structs.nestedByVal(named), 999);
assert(isequal(nested_structs.nestedByPtr(named), 999), 'nested_structs.nestedByPtr(named) is %d but should be %d', nested_structs.nestedByPtr(named), 999);

outer = nested_structs.Outer();
outer.inside1.val = 456;
assert(nested_structs.getInside1Val(outer), 456);
assert(isequal(nested_structs.getInside1Val(outer), 456), 'nested_structs.getInside1Val(outer) is %d but should be %d', nested_structs.getInside1Val(outer), 456);

outer.inside1 = named;
assert(nested_structs.getInside1Val(outer), 999);
assert(isequal(nested_structs.getInside1Val(outer), 999), 'nested_structs.getInside1Val(outer) is %d but should be %d', nested_structs.getInside1Val(outer), 999);


5 changes: 4 additions & 1 deletion Examples/test-suite/matlab/overload_extend_runme.m
Expand Up @@ -13,7 +13,10 @@
if (f.test(3,2) ~= 5)
error('Failed!')
end
if (f.test(3.0) ~= 1003)
if (f.test(3.1) ~= 1003.1)
error('Failed!')
end
if (f.test(3.0) ~= 1003)
error('Failed to use "double" overload!')
end

10 changes: 5 additions & 5 deletions Examples/test-suite/matlab/preproc_constants_runme.m
@@ -1,10 +1,10 @@
import preproc_constants.*

assert(CONST_INT1, 10)
assert(CONST_DOUBLE3, 12.3)
assert(CONST_BOOL1, true)
assert(CONST_CHAR, 'x')
assert(CONST_STRING1, 'const string')
assert(isequal(CONST_INT1, 10), 'CONST_INT1 is %d but should be 10', CONST_INT1)
assert(isequal(CONST_DOUBLE3, 12.3), 'CONST_DOUBLE3 is %g but should be 12.3', CONST_DOUBLE3)
assert(isequal(CONST_BOOL1, true), 'CONST_BOOL1 should be true', CONST_BOOL1)
assert(isequal(CONST_CHAR, 'x'), 'CONST_CHAR is %s but should be 10', CONST_CHAR)
assert(isequal(CONST_STRING1, 'const string'), 'CONST_STRING1 is "%s" but should be "const string"', CONST_STRING1)

% Test global constants can be seen within functions

Expand Down
11 changes: 6 additions & 5 deletions Examples/test-suite/matlab/preproc_constants_test_global.m
Expand Up @@ -6,9 +6,10 @@ function test_global()
global CONST_CHAR
global CONST_STRING1

assert(CONST_INT1, 10)
assert(CONST_DOUBLE3, 12.3)
assert(CONST_BOOL1, true)
assert(CONST_CHAR, 'x')
assert(CONST_STRING1, 'const string')
assert(isequal(CONST_INT1, 10), 'in function: CONST_INT1 is %d but should be 10', CONST_INT1)
assert(isequal(CONST_DOUBLE3, 12.3), 'in function: CONST_DOUBLE3 is %g but should be 12.3', CONST_DOUBLE3)
assert(isequal(CONST_BOOL1, true), 'in function: CONST_BOOL1 should be true', CONST_BOOL1)
assert(isequal(CONST_CHAR, 'x'), 'in function: CONST_CHAR is %s but should be 10', CONST_CHAR)
assert(isequal(CONST_STRING1, 'const string'), 'in function: CONST_STRING1 is "%s" but should be "const string"', CONST_STRING1)

keyboard
7 changes: 4 additions & 3 deletions Examples/test-suite/matlab/smart_pointer_member_runme.m
Expand Up @@ -14,9 +14,10 @@
error('f.y = %i, b.y = %i',f.y,b.y)
end

if (swig_this(b.x) ~= swig_this(f.x))
error
end
% no swig_this yet
%if (swig_this(b.x) ~= swig_this(f.x))
% error('swig+this Failed!!')
%end

if (b.z ~= f.z)
error
Expand Down
7 changes: 4 additions & 3 deletions Examples/test-suite/matlab/std_containers_runme.m
Expand Up @@ -89,10 +89,11 @@
mapc ={};
c1 = std_containers.C();
c2 = std_containers.C();
mapc(1) = swig_this(c1);
mapc(2) = c2;
% no swig_this yet
% mapc(1) = swig_this(c1);
% mapc(2) = c2;

std_containers.mapidentc(mapc);
% std_containers.mapidentc(mapc);


vi = std_containers.vector_i([2,2,3,4]);
Expand Down
19 changes: 10 additions & 9 deletions Examples/test-suite/matlab/swigobject_runme.m
Expand Up @@ -5,24 +5,25 @@
a1 = a_ptr(a);
a2 = a_ptr(a);

if (swig_this(a1) ~= swig_this(a2))
error
end
% no swig_this yet
%if (swig_this(a1) ~= swig_this(a2))
% error('swig_this Failed!!')
%end


lthis = uint64(swig_this(a.this));
xstr1 = printf('0x%x',lthis);
%lthis = uint64(swig_this(a.this));
%xstr1 = printf('0x%x',lthis);
xstr2 = pointer_str(a);

if (xstr1 ~= xstr2)
error
end
%if (xstr1 ~= xstr2)
% error('Failed!!')
%end

s = str(a.this);
r = repr(a.this);

v1 = v_ptr(a);
v2 = v_ptr(a);
if (uint64(v1) ~= uint64(v2))
error
error('Failed!!')
end
14 changes: 7 additions & 7 deletions Examples/test-suite/matlab/template_typedef_cplx2_runme.m
Expand Up @@ -6,7 +6,8 @@

try
d = make_Identity_double();
a = swig_this(d);
% no swig_this yet
% a = swig_this(d);
catch
d
error('is not an instance')
Expand All @@ -15,12 +16,11 @@
if (findstr('ArithUnaryFunction',swig_type(d)) ~= 1)
d
error('is not an ArithUnaryFunction')
error
end

try
e = make_Multiplies_double_double_double_double(d, d);
a = swig_this(e);
% a = swig_this(e);
catch
e
error('is not an instance')
Expand All @@ -38,7 +38,7 @@

try
c = make_Identity_complex();
a = swig_this(c);
%a = swig_this(c);
catch
c
error('is not an instance')
Expand All @@ -51,7 +51,7 @@

try
f = make_Multiplies_complex_complex_complex_complex(c, c);
a = swig_this(f);
%a = swig_this(f);
catch
f
error('is not an instance')
Expand All @@ -68,7 +68,7 @@

try
g = make_Multiplies_double_double_complex_complex(d, c);
a = swig_this(g);
%a = swig_this(g);
catch
g
error('is not an instance')
Expand All @@ -83,7 +83,7 @@

try
h = make_Multiplies_complex_complex_double_double(c, d);
a = swig_this(h);
%a = swig_this(h);
catch
h
error('is not an instance')
Expand Down
12 changes: 6 additions & 6 deletions Examples/test-suite/matlab/template_typedef_cplx_runme.m
Expand Up @@ -6,7 +6,7 @@

try
d = make_Identity_double();
a = swig_this(d);
%a = swig_this(d);
catch
d
error('is not an instance')
Expand All @@ -19,7 +19,7 @@

try
e = make_Multiplies_double_double_double_double(d, d);
a = swig_this(e);
%a = swig_this(e);
catch
error(e, 'is not an instance')
end
Expand All @@ -36,7 +36,7 @@

try
c = make_Identity_complex();
a = swig_this(c);
%a = swig_this(c);
catch
c
error('is not an instance')
Expand All @@ -49,7 +49,7 @@

try
f = make_Multiplies_complex_complex_complex_complex(c, c);
a = swig_this(f);
%a = swig_this(f);
catch
f
error('is not an instance')
Expand All @@ -66,7 +66,7 @@

try
g = make_Multiplies_double_double_complex_complex(d, c);
a = swig_this(g);
%a = swig_this(g);
catch
g
error('is not an instance')
Expand All @@ -80,7 +80,7 @@

try
h = make_Multiplies_complex_complex_double_double(c, d);
a = swig_this(h);
%a = swig_this(h);
catch
h
error('is not an instance')
Expand Down
19 changes: 10 additions & 9 deletions Examples/test-suite/matlab/template_typedef_runme.m
Expand Up @@ -4,32 +4,33 @@
c = make_Identity_reald();


try
a = swig_this(d);
a = swig_this(c);
catch
error('Failed!!')
end
% no swig_this yet
%try
% a = swig_this(d);
% a = swig_this(c);
%catch
% error('Failed!!')
%end

try
e = make_Multiplies_float_float_float_float(d, d);
a = swig_this(e);
%a = swig_this(e);
catch
e
error('is not an instance')
end

try
f = make_Multiplies_reald_reald_reald_reald(c, c);
a = swig_this(f);
%a = swig_this(f);
catch
f
error('is not an instance');
end

try
g = make_Multiplies_float_float_reald_reald(d, c);
a = swig_this(g);
%a = swig_this(g);
catch
error(g, 'is not an instance')
end
Expand Down
4 changes: 1 addition & 3 deletions Examples/test-suite/matlab/unions_runme.m
@@ -1,9 +1,7 @@
import .*
import unions.*
% This is the union runtime testcase. It ensures that values within a
% union embedded within a struct can be set and read correctly.

unions

% Create new instances of SmallStruct and BigStruct for later use
small = unions.SmallStruct();
small.jill = 200;
Expand Down
19 changes: 10 additions & 9 deletions Examples/test-suite/matlab/voidtest_runme.m
Expand Up @@ -18,18 +18,19 @@

v1 = voidtest.vfunc1(f);
v2 = voidtest.vfunc2(f);
if (swig_this(v1) ~= swig_this(v2))
error('Failed!!')
end
% no swig_this yet
%if (swig_this(v1) ~= swig_this(v2))
% error('Failed!!')
%end

v3 = voidtest.vfunc3(v1);
if (swig_this(v3) ~= swig_this(f))
error('Failed!!')
end
%if (swig_this(v3) ~= swig_this(f))
% error('Failed!!')
%end
v4 = voidtest.vfunc1(f);
if (swig_this(v4) ~= swig_this(v1))
error('Failed!!')
end
%if (swig_this(v4) ~= swig_this(v1))
% error('Failed!!')
%end


v3.memberfunc();

0 comments on commit 8fc108f

Please sign in to comment.