# HG changeset patch # User Julien Bect # Date 1359286140 -3600 # Node ID f75ffcc82acbbd7e0c769b7f674b793da98eb8ff # Parent 1eb3c67139f6915bfa07285404490993913adced Added tests for the legacy class system. * double.m, eq.m, ge.m, gt.m, horzcat.m, ldivide.m, le.m, lt.m, minus.m, mldivide.m, mpower.m, mrdivide.m, mtimes.m, ne.m, plus.m, power.m, rdivide.m, times.m, uminus.m, uplus.m, vertcat.m: New overloaded class methods. * test_classes.m: Add tests. Rewrite some tests to ensure they run in Matlab without modification. diff -r 1eb3c67139f6 -r f75ffcc82acb test/classes/@Snork/double.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/classes/@Snork/double.m Sun Jan 27 12:29:00 2013 +0100 @@ -0,0 +1,6 @@ +function x = double(snk) + + x = snk.gick; + +end + diff -r 1eb3c67139f6 -r f75ffcc82acb test/classes/@Snork/eq.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/classes/@Snork/eq.m Sun Jan 27 12:29:00 2013 +0100 @@ -0,0 +1,8 @@ +function b = eq(s1, s2) + + x1 = double(s1); + x2 = double(s2); + + b = isequal(x1, x2); + +end \ No newline at end of file diff -r 1eb3c67139f6 -r f75ffcc82acb test/classes/@Snork/ge.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/classes/@Snork/ge.m Sun Jan 27 12:29:00 2013 +0100 @@ -0,0 +1,8 @@ +function b = ge(s1, s2) + + x1 = double(s1); + x2 = double(s2); + + b = (x1(1) >= x2(1)); + +end diff -r 1eb3c67139f6 -r f75ffcc82acb test/classes/@Snork/gt.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/classes/@Snork/gt.m Sun Jan 27 12:29:00 2013 +0100 @@ -0,0 +1,8 @@ +function b = gt(s1, s2) + + x1 = double(s1); + x2 = double(s2); + + b = (x1(1) > x2(1)); + +end diff -r 1eb3c67139f6 -r f75ffcc82acb test/classes/@Snork/horzcat.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/classes/@Snork/horzcat.m Sun Jan 27 12:29:00 2013 +0100 @@ -0,0 +1,8 @@ +function s = horzcat(s1, s2) + + x1 = double(s1); + x2 = double(s2); + + s = Snork([x1 x2]); + +end diff -r 1eb3c67139f6 -r f75ffcc82acb test/classes/@Snork/ldivide.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/classes/@Snork/ldivide.m Sun Jan 27 12:29:00 2013 +0100 @@ -0,0 +1,8 @@ +function s = ldivide(s1, s2) + + x1 = double(s1); + x2 = double(s2); + + s = Snork(x1 .\ x2); + +end diff -r 1eb3c67139f6 -r f75ffcc82acb test/classes/@Snork/le.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/classes/@Snork/le.m Sun Jan 27 12:29:00 2013 +0100 @@ -0,0 +1,8 @@ +function b = le(s1, s2) + + x1 = double(s1); + x2 = double(s2); + + b = (x1(1) <= x2(1)); + +end diff -r 1eb3c67139f6 -r f75ffcc82acb test/classes/@Snork/lt.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/classes/@Snork/lt.m Sun Jan 27 12:29:00 2013 +0100 @@ -0,0 +1,8 @@ +function b = lt(s1, s2) + + x1 = double(s1); + x2 = double(s2); + + b = (x1(1) < x2(1)); + +end diff -r 1eb3c67139f6 -r f75ffcc82acb test/classes/@Snork/minus.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/classes/@Snork/minus.m Sun Jan 27 12:29:00 2013 +0100 @@ -0,0 +1,8 @@ +function s = minus(s1, s2) + + x1 = double(s1); + x2 = double(s2); + + s = Snork(x1 - x2); + +end diff -r 1eb3c67139f6 -r f75ffcc82acb test/classes/@Snork/mldivide.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/classes/@Snork/mldivide.m Sun Jan 27 12:29:00 2013 +0100 @@ -0,0 +1,8 @@ +function s = mldivide(s1, s2) + + x1 = double(s1); + x2 = double(s2); + + s = Snork(x1 \ x2); + +end diff -r 1eb3c67139f6 -r f75ffcc82acb test/classes/@Snork/mpower.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/classes/@Snork/mpower.m Sun Jan 27 12:29:00 2013 +0100 @@ -0,0 +1,10 @@ +function s = mpower(s1, x) + + if ~isa(s1, 'Snork') || isa(x, 'Snork') + error('mpower Snork!!!'); + end + + s = s1; + s.gick = s.gick ^ x; + +end diff -r 1eb3c67139f6 -r f75ffcc82acb test/classes/@Snork/mrdivide.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/classes/@Snork/mrdivide.m Sun Jan 27 12:29:00 2013 +0100 @@ -0,0 +1,8 @@ +function s = mrdivide(s1, s2) + + x1 = double(s1); + x2 = double(s2); + + s = Snork(x1 / x2); + +end diff -r 1eb3c67139f6 -r f75ffcc82acb test/classes/@Snork/mtimes.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/classes/@Snork/mtimes.m Sun Jan 27 12:29:00 2013 +0100 @@ -0,0 +1,8 @@ +function s = mtimes(s1, s2) + + x1 = double(s1); + x2 = double(s2); + + s = Snork(x1 * x2); + +end diff -r 1eb3c67139f6 -r f75ffcc82acb test/classes/@Snork/ne.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/classes/@Snork/ne.m Sun Jan 27 12:29:00 2013 +0100 @@ -0,0 +1,5 @@ +function b = ne(s1, s2) + + b = ~(s1 == s2); + +end diff -r 1eb3c67139f6 -r f75ffcc82acb test/classes/@Snork/plus.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/classes/@Snork/plus.m Sun Jan 27 12:29:00 2013 +0100 @@ -0,0 +1,8 @@ +function s = plus(s1, s2) + + x1 = double(s1); + x2 = double(s2); + + s = Snork(x1 + x2); + +end \ No newline at end of file diff -r 1eb3c67139f6 -r f75ffcc82acb test/classes/@Snork/power.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/classes/@Snork/power.m Sun Jan 27 12:29:00 2013 +0100 @@ -0,0 +1,10 @@ +function s = power(s1, x) + + if ~isa(s1, 'Snork') || isa(x, 'Snork') + error('power Snork!!!'); + end + + s = s1; + s.gick = s.gick .^ x; + +end diff -r 1eb3c67139f6 -r f75ffcc82acb test/classes/@Snork/rdivide.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/classes/@Snork/rdivide.m Sun Jan 27 12:29:00 2013 +0100 @@ -0,0 +1,8 @@ +function s = rdivide(s1, s2) + + x1 = double(s1); + x2 = double(s2); + + s = Snork(x1 ./ x2); + +end diff -r 1eb3c67139f6 -r f75ffcc82acb test/classes/@Snork/times.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/classes/@Snork/times.m Sun Jan 27 12:29:00 2013 +0100 @@ -0,0 +1,8 @@ +function s = times(s1, s2, s3) + + x1 = double(s1); + x2 = double(s2); + + s = Snork(x1 .* x2); + +end diff -r 1eb3c67139f6 -r f75ffcc82acb test/classes/@Snork/uminus.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/classes/@Snork/uminus.m Sun Jan 27 12:29:00 2013 +0100 @@ -0,0 +1,6 @@ +function s = uminus(s1) + + s = s1; + s.gick = - s.gick; + +end \ No newline at end of file diff -r 1eb3c67139f6 -r f75ffcc82acb test/classes/@Snork/uplus.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/classes/@Snork/uplus.m Sun Jan 27 12:29:00 2013 +0100 @@ -0,0 +1,5 @@ +function s = uplus(s1) + + s = s1; + +end diff -r 1eb3c67139f6 -r f75ffcc82acb test/classes/@Snork/vertcat.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/classes/@Snork/vertcat.m Sun Jan 27 12:29:00 2013 +0100 @@ -0,0 +1,8 @@ +function s = vertcat(s1, s2) + + x1 = double(s1); + x2 = double(s2); + + s = Snork([x1; x2]); + +end diff -r 1eb3c67139f6 -r f75ffcc82acb test/classes/test_classes.m --- a/test/classes/test_classes.m Sun Jan 27 18:44:53 2013 -0600 +++ b/test/classes/test_classes.m Sun Jan 27 12:29:00 2013 +0100 @@ -1,3 +1,4 @@ +## Copyright (C) 2013 Julien Bect ## Copyright (C) 2009-2012 Robert T. Short ## ## This file is part of Octave. @@ -22,6 +23,10 @@ %% Note: This script and all classes are also intended to run %% in MATLAB to test compatibility. Don't break that! %% +%% Note(JBect, 2013/01/27) : in order to ease to process of testing +%% Matlab compatibility, the syntax assert(observed, expected) should +%% be avoided. I use assert(isequal(observed, expected) instead. +%% %% To Do: This script tests to ensure that things done correctly work %% corrrectly. It should also check that things done incorrectly %% error properly. @@ -37,40 +42,40 @@ %% features. %!shared snk, snk1, snk2 %!test snk = Snork(); -%! assert(gick(snk),1) -%! assert(snk.gick,1) -%! assert(snk(2),1); -%! assert(snk{end},3); -%!test snk = gick(snk,2); -%! assert(gick(snk),2) -%!test snk = set(snk,'gick',7); -%! assert(get(snk, 'gick'), 7) +%! assert (isequal (gick (snk), 1)) +%! assert (isequal (snk.gick, 1)) +%! assert (isequal (snk(2), 1)); +%! assert (isequal (snk{end}, 3)); +%!test snk = gick (snk, 2); +%! assert (isequal (gick (snk), 2)) +%!test snk = set (snk, 'gick', 7); +%! assert (isequal (get (snk, 'gick'), 7)) %!test snk.gick = 4; -%! assert(gick(snk),4) -%! snk(1) = 3; +%! assert (isequal (gick (snk),4)) +%! snk(1) = 3; %!test snk{end} = 9; -%! assert(cack(snk),[3 1 2 9]) -%! assert(getStash(snk),1) % Check private functions. -%! assert(isobject(snk)) -%! assert(class(snk),'Snork') -%! assert(isa(snk,'Snork')) -%! assert(~isa(snk,'Sneetch')) -%! assert(ismethod(snk,'gick')) -%! assert(~ismethod(snk,'bletch')) -%! assert(exist('snk')) -%! assert(~exist('blink')) +%! assert (isequal (cack (snk), [3 1 2 9])) +%! assert (isequal (getStash (snk), 1)) % Check private functions. +%! assert (isobject (snk)) +%! assert (isequal (class (snk), 'Snork')) +%! assert (isa (snk, 'Snork')) +%! assert (~isa (snk, 'Sneetch')) +%! assert (ismethod (snk, 'gick')) +%! assert (~ismethod (snk, 'bletch')) +%! assert (exist ('snk') == 1) +%! assert (exist ('blink') == 0) %!test snk1 = Snork(snk); -%! assert(class(snk1),'Snork') -%! assert(gick(snk1),4) +%! assert (isequal (class (snk1), 'Snork')) +%! assert (isequal (gick (snk1), 4)) %!test snk2 = Snork(-3); -%! assert(class(snk2),'Snork') -%! assert(gick(snk2),-3) -%!test x=[1 2 3 4]; -%! assert(x(snk),1); -%% x=methods('Snork'); % Need to test the methods function. +%! assert (isequal (class (snk2), 'Snork')) +%! assert (isequal (gick (snk2), -3)) +%!test x = [1 2 3 4]; +%! assert (isequal (x(snk), 1)) +%% x = methods('Snork'); % Need to test the methods function. %% save temp snk; %% load temp % This load causes a segment fault. -%% assert(cack(snk),[-1 -2 -3 -4]); % This is a major bug! +%% assert (isequal(cack(snk), [-1 -2 -3 -4])); % This is a major bug! %% The Spork class is a near clone of Snork but without as many standard %% methods. We are testing no new octave features, but this is makes @@ -78,13 +83,13 @@ %% changes. We use Spork in the class hierarchy. %!shared sprk %!test sprk = Spork(); -%! assert(geek(sprk),1) -%!test sprk = geek(sprk,3); -%! assert(geek(sprk),3) -%!test sprk = set(sprk,'geek',7); -%! assert(get(sprk, 'geek'), 7) -%! assert(class(sprk),'Spork'); -%! assert(isa(sprk,'Spork')) +%! assert (isequal (geek (sprk), 1)) +%!test sprk = geek (sprk, 3); +%! assert (isequal (geek (sprk), 3)) +%!test sprk = set (sprk,'geek',7); +%! assert (isequal (get (sprk, 'geek'), 7)) +%! assert (isequal (class (sprk), 'Spork')) +%! assert (isa (sprk, 'Spork')) %% The Blork class is a near clone of Snork but without as many standard %% methods. We are testing no new octave features, but this is makes @@ -92,13 +97,13 @@ %% changes. We use Blork in the class hierarchy. %!shared blrk %!test blrk = Blork(); -%! assert(bleek(blrk),1) -%!test blrk = bleek(blrk,3); -%! assert(bleek(blrk),3) -%!test blrk = set(blrk,'bleek',13); -%! assert(get(blrk, 'bleek'), 13) -%! assert(class(blrk),'Blork'); -%! assert(isa(blrk,'Blork')) +%! assert (isequal (bleek(blrk), 1)) +%!test blrk = bleek (blrk, 3); +%! assert (isequal (bleek (blrk), 3)) +%!test blrk = set (blrk, 'bleek', 13); +%! assert (isequal (get (blrk, 'bleek'), 13)) +%! assert (isequal (class (blrk), 'Blork')) +%! assert (isa (blrk,'Blork')) %% The Cork class is a near clone of Snork but without as many standard %% methods. We are testing no new octave features, but this is makes @@ -106,96 +111,207 @@ %% changes. We use Cork in the class hierarchy. %!shared crk %!test crk = Cork(23); -%! assert(click(crk),23) +%! assert (isequal (click(crk), 23)) %!test crk = click(crk,3); -%! assert(click(crk),3) -%!test crk = set(crk,'click',13); -%! assert(get(crk, 'click'), 13) -%! assert(class(crk),'Cork'); -%! assert(isa(crk,'Cork')) +%! assert (isequal (click(crk), 3)) +%!test crk = set (crk, 'click', 13); +%! assert (isequal (get (crk, 'click'), 13)) +%! assert (isequal (class (crk),'Cork')) +%! assert (isa (crk, 'Cork')) %% The Dork class tests single inheritance. %!shared drk %!test drk = Dork(); -%! assert(gack(drk),0) -%!test drk = gack(drk,-2); -%! assert(gack(drk),-2) -%!test drk = gick(drk,2); -%! assert(gick(drk),2); -%!test drk = set(drk, 'gick',3, 'gack',-3); -%! assert(get(drk, 'gick'), 3) -%! assert(get(drk, 'gack'), -3) -%! assert(class(drk),'Dork') -%! assert(isa(drk,'Dork')) -%! assert(isa(drk,'Snork')) -%! assert(getStash(drk),2) +%! assert (isequal (gack (drk),0)) +%!test drk = gack (drk,-2); +%! assert (isequal (gack (drk),-2)) +%!test drk = gick (drk,2); +%! assert (isequal (gick (drk),2)) +%!test drk = set (drk, 'gick',3, 'gack',-3); +%! assert (isequal (get (drk, 'gick'), 3)) +%! assert (isequal (get (drk, 'gack'), -3)) +%! assert (isequal (class (drk),'Dork')) +%! assert (isa (drk, 'Dork')) +%! assert (isa (drk, 'Snork')) +%! assert (isequal (getStash (drk), 2)) %!test drk1 = Dork(drk); -%! assert(class(drk1),'Dork') -%! assert(isa(drk1,'Snork')) -%! assert(gick(drk1),3) -%! assert(gack(drk1),-3) -%!test drk2 = Dork(-4,4); -%! assert(class(drk2),'Dork') -%! assert(isa(drk2,'Snork')) -%! assert(gick(drk2),-4) -%! assert(gack(drk2),4) +%! assert (isequal (class (drk1), 'Dork')) +%! assert (isa (drk1, 'Snork')) +%! assert (isequal (gick (drk1), 3)) +%! assert (isequal (gack (drk1), -3)) +%!test drk2 = Dork(-4, 4); +%! assert (isequal (class (drk2), 'Dork')) +%! assert (isa (drk2, 'Snork')) +%! assert (isequal (gick (drk2), -4)) +%! assert (isequal (gack (drk2), 4)) %% The Pork class is essentially a clone of Dork. It is used as part %% of the multiple inheritance test. %!shared prk, drk %!test prk = Pork(); -%! assert(geek(prk),1) -%! assert(gurk(prk),0) -%!test prk = gurk(prk,-3); -%! assert(gurk(prk),-3) -%!test prk = geek(prk,9); -%! assert(geek(prk),9) -%! assert(class(prk),'Pork') -%! assert(isa(prk,'Pork')) -%! assert(isa(prk,'Spork')) +%! assert (isequal (geek (prk), 1)) +%! assert (isequal (gurk (prk), 0)) +%!test prk = gurk (prk,-3); +%! assert (isequal (gurk (prk), -3)) +%!test prk = geek (prk,9); +%! assert (isequal (geek (prk), 9)) +%! assert (isequal (class (prk), 'Pork')) +%! assert (isa (prk, 'Pork')) +%! assert (isa (prk, 'Spork')) %!test drk = Dork(); % Precedence. -%! assert(bling(drk,prk),2) -%! assert(bling(prk,drk),2) +%! assert (isequal (bling (drk, prk), 2)) +%! assert (isequal (bling (prk, drk), 2)) %% The Gork class tests aggregation and multiple inheritance. %!shared grk %!test grk = Gork(); -%! assert(gick(grk),1) -%! assert(geek(grk),1) -%! assert(gack(grk),0) -%! assert(gurk(grk),0) -%! assert(bleek(grk),1) -%! assert(gark(grk),-2) -%! assert(click(cork(grk)),17) -%! assert(class(cork(grk)),'Cork') -%!test grk = gick(grk,3); -%!test grk = geek(grk,4); -%!test grk = gack(grk,-9); -%!test grk = gurk(grk,-8); -%!test grk = bleek(grk,-7); -%!test grk = gark(grk,-6); -%!test grk = cork(grk,click(cork(grk),23)); -%! assert(gick(grk),3) -%! assert(geek(grk),4) -%! assert(gack(grk),-9) -%! assert(gurk(grk),-8) -%! assert(bleek(grk),-7) -%! assert(gark(grk),-6) -%! assert(click(cork(grk)),23) +%! assert (isequal (gick (grk), 1)) +%! assert (isequal (geek (grk), 1)) +%! assert (isequal (gack (grk), 0)) +%! assert (isequal (gurk (grk), 0)) +%! assert (isequal (bleek (grk), 1)) +%! assert (isequal (gark(grk), -2)) +%! assert (isequal (click (cork (grk)), 17)) +%! assert (isequal (class (cork (grk)), 'Cork')) +%!test grk = gick (grk, 3); +%!test grk = geek (grk, 4); +%!test grk = gack (grk, -9); +%!test grk = gurk (grk, -8); +%!test grk = bleek (grk, -7); +%!test grk = gark (grk, -6); +%!test grk = cork (grk, click (cork (grk), 23)); +%! assert (isequal (gick (grk), 3)) +%! assert (isequal (geek (grk), 4)) +%! assert (isequal (gack (grk), -9)) +%! assert (isequal (gurk (grk), -8)) +%! assert (isequal (bleek (grk), -7)) +%! assert (isequal (gark (grk), -6)) +%! assert (isequal (click (cork (grk)), 23)) %!test -%! cork1 = Cork(13); -%! grk = set(grk, 'gick',-5, 'gack',-6, 'gark',-7, 'cork',cork1); -%! assert(get(grk,'gick'),-5) -%! assert(get(grk,'gack'),-6) -%! assert(get(grk,'gark'),-7) -%! assert(click(get(grk, 'cork')),13); -%!test grk = set(grk, 'cork',12); -%! assert(click(get(grk, 'cork')),12); -%! assert(class(cork(grk)),'Cork') -%! assert(class(grk),'Gork') -%! assert(isa(grk,'Gork')) -%! assert(isa(grk,'Dork')) -%! assert(isa(grk,'Pork')) -%! assert(isa(grk,'Blork')) -%! assert(isa(grk,'Snork')) -%! assert(isa(grk,'Spork')) +%! cork1 = Cork(13); +%! grk = set (grk, 'gick', -5, 'gack', -6, 'gark', -7, 'cork', cork1); +%! assert (isequal (get (grk, 'gick'), -5)) +%! assert (isequal (get (grk, 'gack'), -6)) +%! assert (isequal (get (grk, 'gark'), -7)) +%! assert (isequal (click(get (grk, 'cork')), 13)) +%!test grk = set (grk, 'cork', 12); +%! assert (isequal (click(get (grk, 'cork')),12)); +%! assert (isequal (class (cork(grk)), 'Cork')) +%! assert (isequal (class (grk), 'Gork')) +%! assert (isa (grk, 'Gork')) +%! assert (isa (grk, 'Dork')) +%! assert (isa (grk, 'Pork')) +%! assert (isa (grk, 'Blork')) +%! assert (isa (grk, 'Snork')) +%! assert (isa (grk, 'Spork')) + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Testing (some) overloaded operators %% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%% Common variables for testing overloaded operators +%!shared x1, x2, x3, s1, s2, s3 +%! x1 = 1 + rand(3); s1 = Snork(x1); +%! x2 = 1 + rand(3); s2 = Snork(x2); +%! x3 = diag([1 2 3]); s3 = Snork(x3); + +%% Test overloaded plus (+) and uplus (unitary +) for the Snork class +%!test s = s1 + s2; assert (isa (s, 'Snork') && isequal (s.gick, x1 + x2)); +%!test s = s1 + x2; assert (isa (s, 'Snork') && isequal (s.gick, x1 + x2)); +%!test s = x1 + s2; assert (isa (s, 'Snork') && isequal (s.gick, x1 + x2)); +%!test s = +s1; assert (isequal (s, s1)); + +%% Test overloaded minus (-) for the Snork class +%!test s = s1 - s2; assert (isa (s, 'Snork') && isequal (s.gick, x1 - x2)); +%!test s = s1 - x2; assert (isa (s, 'Snork') && isequal (s.gick, x1 - x2)); +%!test s = x1 - s2; assert (isa (s, 'Snork') && isequal (s.gick, x1 - x2)); +%!test s = -s1; assert (isequal (s, Snork(-x1))); + +%% Test overloaded mtimes (*) for the Snork class +%!test s = s1 * s2; assert (isa (s, 'Snork') && isequal (s.gick, x1 * x2)); +%!test s = s1 * x2; assert (isa (s, 'Snork') && isequal (s.gick, x1 * x2)); +%!test s = x1 * s2; assert (isa (s, 'Snork') && isequal (s.gick, x1 * x2)); + +%% Test overloaded times (.*) for the Snork class +%!test s = s1 .* s2; assert (isa (s, 'Snork') && isequal (s.gick, x1 .* x2)); +%!test s = s1 .* x2; assert (isa (s, 'Snork') && isequal (s.gick, x1 .* x2)); +%!test s = x1 .* s2; assert (isa (s, 'Snork') && isequal (s.gick, x1 .* x2)); + +%% Test overloaded mpower (^) for the Snork class +%!test s = s1 ^ 3; assert (isa (s, 'Snork') && isequal (s.gick, x1 ^ 3)); +%!error s = s1 ^ s1; +%!error s = 20 ^ s1; + +%% Test overloaded power (.^) for the Snork class +%!test s = s1 .^ 2; assert (isa (s, 'Snork') && isequal (s.gick, x1 .^ 2)); +%!error s = s1 .^ s1; +%!error s = 20 .^ s1; + +%% Test overloaded rdivide (./) for the Snork class +%!test s = s1 ./ s2; assert (isa (s, 'Snork') && isequal (s.gick, x1 ./ x2)); +%!test s = s1 ./ x2; assert (isa (s, 'Snork') && isequal (s.gick, x1 ./ x2)); +%!test s = x1 ./ s2; assert (isa (s, 'Snork') && isequal (s.gick, x1 ./ x2)); + +%% Test overloaded ldivide (.\) for the Snork class +%!test s = s1 .\ s2; assert (isa (s, 'Snork') && isequal (s.gick, x1 .\ x2)); +%!test s = s1 .\ x2; assert (isa (s, 'Snork') && isequal (s.gick, x1 .\ x2)); +%!test s = x1 .\ s2; assert (isa (s, 'Snork') && isequal (s.gick, x1 .\ x2)); + +%% Test overloaded mrdivide (/) for the Snork class +%!test s = s1 / s3; assert (isa (s, 'Snork') && isequal (s.gick, x1 / x3)); +%!test s = s1 / x3; assert (isa (s, 'Snork') && isequal (s.gick, x1 / x3)); +%!test s = x1 / s3; assert (isa (s, 'Snork') && isequal (s.gick, x1 / x3)); + +%% Test overloaded mldivide (\) for the Snork class +%!test s = s3 \ s2; assert (isa (s, 'Snork') && isequal (s.gick, x3 \ x2)); +%!test s = s3 \ x2; assert (isa (s, 'Snork') && isequal (s.gick, x3 \ x2)); +%!test s = x3 \ s2; assert (isa (s, 'Snork') && isequal (s.gick, x3 \ x2)); + +%% Test overloaded eq (==) for the Snork class +%!assert (s1 == s1); +%!assert (s1 == x1); +%!assert (x1 == s1); +%!assert (~(s1 == (s1 + 1))); +%!assert (~(s1 == (x1 + 1))); +%!assert (~(x1 == (s1 + 1))); + +%% Test overloaded ne (~=) for the Snork class +%!assert (~(s1 ~= s1)); +%!assert (~(s1 ~= x1)); +%!assert (~(x1 ~= s1)); +%!assert (s1 ~= (s1 + 1)) +%!assert (x1 ~= (s1 + 1)) +%!assert (s1 ~= (x1 + 1)) + +%% Test overloaded lt (<) for the Snork class +%!assert (s1 < (s1 + 1)) +%!assert (s1 < (x1 + 1)) +%!assert (x1 < (s1 + 1)) + +%% Test overloaded gt (>) for the Snork class +%!assert (s1 > (s1 - 1)) +%!assert (s1 > (x1 - 1)) +%!assert (x1 > (s1 - 1)) + +%% Test overloaded lt (<=) for the Snork class +%!assert (s1 <= (s1 + 1)) +%!assert (s1 <= (x1 + 1)) +%!assert (x1 <= (s1 + 1)) + +%% Test overloaded gt (>=) for the Snork class +%!assert (s1 >= (s1 - 1)) +%!assert (s1 >= (x1 - 1)) +%!assert (x1 >= (s1 - 1)) + +%% Test overloaded vertcat() for the Snork class +%% See bug #38170 (http://savannah.gnu.org/bugs/?38170) +%!test s = [s1; s2]; assert (isa (s, 'Snork') && isequal (s.gick, [x1; x2])); +%!xtest s = [s1; x2]; assert (isa (s, 'Snork') && isequal (s.gick, [x1; x2])); +%!xtest s = [x1; s2]; assert (isa (s, 'Snork') && isequal (s.gick, [x1; x2])); + +%% Test overloaded horzcat() for the Snork class +%% See bug #38170 (http://savannah.gnu.org/bugs/?38170) +%!test s = [s1 s2]; assert (isa (s, 'Snork') && isequal (s.gick, [x1 x2])); +%!xtest s = [s1 x2]; assert (isa (s, 'Snork') && isequal (s.gick, [x1 x2])); +%!xtest s = [x1 s2]; assert (isa (s, 'Snork') && isequal (s.gick, [x1 x2])); +