From 8fc108f4efa58143a21426683875dd6e06f2506e Mon Sep 17 00:00:00 2001 From: Kris Thielemans Date: Sun, 6 Sep 2015 00:23:43 +0100 Subject: [PATCH] [MATLAB] fixes to test-suite runme files - 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() --- .../test-suite/matlab/director_unroll_runme.m | 9 +++++---- Examples/test-suite/matlab/imports_runme.m | 9 +++++---- Examples/test-suite/matlab/li_carrays_runme.m | 2 +- Examples/test-suite/matlab/li_cmalloc_runme.m | 2 +- .../matlab/li_std_pair_extra_runme.m | 5 +++-- .../test-suite/matlab/nested_structs_runme.m | 9 +++++---- .../test-suite/matlab/overload_extend_runme.m | 5 ++++- .../matlab/preproc_constants_runme.m | 10 +++++----- .../matlab/preproc_constants_test_global.m | 11 ++++++----- .../matlab/smart_pointer_member_runme.m | 7 ++++--- .../test-suite/matlab/std_containers_runme.m | 7 ++++--- Examples/test-suite/matlab/swigobject_runme.m | 19 ++++++++++--------- .../matlab/template_typedef_cplx2_runme.m | 14 +++++++------- .../matlab/template_typedef_cplx_runme.m | 12 ++++++------ .../matlab/template_typedef_runme.m | 19 ++++++++++--------- Examples/test-suite/matlab/unions_runme.m | 4 +--- Examples/test-suite/matlab/voidtest_runme.m | 19 ++++++++++--------- 17 files changed, 87 insertions(+), 76 deletions(-) diff --git a/Examples/test-suite/matlab/director_unroll_runme.m b/Examples/test-suite/matlab/director_unroll_runme.m index 27e36378bb2..6997fbd9f2a 100644 --- a/Examples/test-suite/matlab/director_unroll_runme.m +++ b/Examples/test-suite/matlab/director_unroll_runme.m @@ -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 diff --git a/Examples/test-suite/matlab/imports_runme.m b/Examples/test-suite/matlab/imports_runme.m index 547bd12ebcd..1c641852c3d 100644 --- a/Examples/test-suite/matlab/imports_runme.m +++ b/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(); @@ -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))); diff --git a/Examples/test-suite/matlab/li_carrays_runme.m b/Examples/test-suite/matlab/li_carrays_runme.m index 84ebd36e244..5077965821c 100644 --- a/Examples/test-suite/matlab/li_carrays_runme.m +++ b/Examples/test-suite/matlab/li_carrays_runme.m @@ -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 diff --git a/Examples/test-suite/matlab/li_cmalloc_runme.m b/Examples/test-suite/matlab/li_cmalloc_runme.m index fbac31b9f2a..d3491c3de06 100644 --- a/Examples/test-suite/matlab/li_cmalloc_runme.m +++ b/Examples/test-suite/matlab/li_cmalloc_runme.m @@ -12,6 +12,6 @@ end if (ok ~= 1) - error + error('test should have thrown an error') end diff --git a/Examples/test-suite/matlab/li_std_pair_extra_runme.m b/Examples/test-suite/matlab/li_std_pair_extra_runme.m index 8a55874f868..3e5f130b58c 100644 --- a/Examples/test-suite/matlab/li_std_pair_extra_runme.m +++ b/Examples/test-suite/matlab/li_std_pair_extra_runme.m @@ -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()}); diff --git a/Examples/test-suite/matlab/nested_structs_runme.m b/Examples/test-suite/matlab/nested_structs_runme.m index ba93b7acebd..27d87690554 100644 --- a/Examples/test-suite/matlab/nested_structs_runme.m +++ b/Examples/test-suite/matlab/nested_structs_runme.m @@ -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); + diff --git a/Examples/test-suite/matlab/overload_extend_runme.m b/Examples/test-suite/matlab/overload_extend_runme.m index c53b7a83f86..f6282b478f3 100644 --- a/Examples/test-suite/matlab/overload_extend_runme.m +++ b/Examples/test-suite/matlab/overload_extend_runme.m @@ -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 diff --git a/Examples/test-suite/matlab/preproc_constants_runme.m b/Examples/test-suite/matlab/preproc_constants_runme.m index 7a31703b7c4..4de1487b01a 100644 --- a/Examples/test-suite/matlab/preproc_constants_runme.m +++ b/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 diff --git a/Examples/test-suite/matlab/preproc_constants_test_global.m b/Examples/test-suite/matlab/preproc_constants_test_global.m index 4dfd8ead828..94e380eaac7 100644 --- a/Examples/test-suite/matlab/preproc_constants_test_global.m +++ b/Examples/test-suite/matlab/preproc_constants_test_global.m @@ -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 diff --git a/Examples/test-suite/matlab/smart_pointer_member_runme.m b/Examples/test-suite/matlab/smart_pointer_member_runme.m index 98c97515690..1ae6cdf8b95 100644 --- a/Examples/test-suite/matlab/smart_pointer_member_runme.m +++ b/Examples/test-suite/matlab/smart_pointer_member_runme.m @@ -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 diff --git a/Examples/test-suite/matlab/std_containers_runme.m b/Examples/test-suite/matlab/std_containers_runme.m index 581f04aa5cb..fc917af5d9a 100644 --- a/Examples/test-suite/matlab/std_containers_runme.m +++ b/Examples/test-suite/matlab/std_containers_runme.m @@ -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]); diff --git a/Examples/test-suite/matlab/swigobject_runme.m b/Examples/test-suite/matlab/swigobject_runme.m index add198ec1e6..62ef17cc189 100644 --- a/Examples/test-suite/matlab/swigobject_runme.m +++ b/Examples/test-suite/matlab/swigobject_runme.m @@ -5,18 +5,19 @@ 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); @@ -24,5 +25,5 @@ v1 = v_ptr(a); v2 = v_ptr(a); if (uint64(v1) ~= uint64(v2)) - error + error('Failed!!') end diff --git a/Examples/test-suite/matlab/template_typedef_cplx2_runme.m b/Examples/test-suite/matlab/template_typedef_cplx2_runme.m index 22a5d0908fd..0203688f193 100644 --- a/Examples/test-suite/matlab/template_typedef_cplx2_runme.m +++ b/Examples/test-suite/matlab/template_typedef_cplx2_runme.m @@ -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') @@ -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') @@ -38,7 +38,7 @@ try c = make_Identity_complex(); - a = swig_this(c); + %a = swig_this(c); catch c error('is not an instance') @@ -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') @@ -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') @@ -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') diff --git a/Examples/test-suite/matlab/template_typedef_cplx_runme.m b/Examples/test-suite/matlab/template_typedef_cplx_runme.m index f4d7b345419..c53999b09d1 100644 --- a/Examples/test-suite/matlab/template_typedef_cplx_runme.m +++ b/Examples/test-suite/matlab/template_typedef_cplx_runme.m @@ -6,7 +6,7 @@ try d = make_Identity_double(); - a = swig_this(d); + %a = swig_this(d); catch d error('is not an instance') @@ -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 @@ -36,7 +36,7 @@ try c = make_Identity_complex(); - a = swig_this(c); + %a = swig_this(c); catch c error('is not an instance') @@ -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') @@ -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') @@ -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') diff --git a/Examples/test-suite/matlab/template_typedef_runme.m b/Examples/test-suite/matlab/template_typedef_runme.m index fd739307ef2..4309eaae652 100644 --- a/Examples/test-suite/matlab/template_typedef_runme.m +++ b/Examples/test-suite/matlab/template_typedef_runme.m @@ -4,16 +4,17 @@ 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') @@ -21,7 +22,7 @@ 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'); @@ -29,7 +30,7 @@ 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 diff --git a/Examples/test-suite/matlab/unions_runme.m b/Examples/test-suite/matlab/unions_runme.m index ec2d0930dd1..6170ca44636 100644 --- a/Examples/test-suite/matlab/unions_runme.m +++ b/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; diff --git a/Examples/test-suite/matlab/voidtest_runme.m b/Examples/test-suite/matlab/voidtest_runme.m index c5d3cce2b5a..a350806e0ab 100644 --- a/Examples/test-suite/matlab/voidtest_runme.m +++ b/Examples/test-suite/matlab/voidtest_runme.m @@ -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();