Mercurial > hg > octave-terminal
changeset 9381:f9ab19428cd8
* run-octave.in: Exclude @-files from path. Remove CVS exclusions.
* test: Add class directories for testing.
* ov-class.cc: Add tests.
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-06-23 Robert T. Short <octave@phaselockedsystems.com> + + * run-octave.in: Exclude @-files from path. Remove CVS exclusions. + 2009-06-19 Jaroslav Hajek <highegg@gmail.com> * NEWS: Update.
--- a/run-octave.in +++ b/run-octave.in @@ -39,10 +39,10 @@ d3="$builddir/scripts" d4="$builddir/src" -d1_list=`$FIND "$d1" -type d -a ! \( \( -name CVS -o -name private \) -a -prune \) -exec echo '{}' ';' | $SED 's/$/:/'` -d2_list=`$FIND "$d2" -type d -a ! \( \( -name CVS -o -name private \) -a -prune \) -exec echo '{}' ';' | $SED 's/$/:/'` -d3_list=`$FIND "$d3" -type d -a ! \( \( -name CVS -o -name private \) -a -prune \) -exec echo '{}' ';' | $SED 's/$/:/'` -d4_list=`$FIND "$d4" -type d -a ! \( \( -name CVS -o -name private \) -a -prune \) -exec echo '{}' ';' | $SED 's/$/:/'` +d1_list=`$FIND "$d1" -type d -a ! \( \( -name private -o -name '@*' \) -a -prune \) -exec echo '{}' ';' | $SED 's/$/:/'` +d2_list=`$FIND "$d2" -type d -a ! \( \( -name private -o -name '@*' \) -a -prune \) -exec echo '{}' ';' | $SED 's/$/:/'` +d3_list=`$FIND "$d3" -type d -a ! \( \( -name private -o -name '@*' \) -a -prune \) -exec echo '{}' ';' | $SED 's/$/:/'` +d4_list=`$FIND "$d4" -type d -a ! \( \( -name private -o -name '@*' \) -a -prune \) -exec echo '{}' ';' | $SED 's/$/:/'` d1_path=`echo "$d1_list" | $AWK '{ t = (s $0); s = t; } END { sub (/:$/, "", s); print s; }'` d2_path=`echo "$d2_list" | $AWK '{ t = (s $0); s = t; } END { sub (/:$/, "", s); print s; }'`
new file mode 100644 --- /dev/null +++ b/test/@Blork/Blork.m @@ -0,0 +1,16 @@ +function [ s ] = Blork( bleek ) +% Test class. + + if (nargin==1) && isa(bleek, 'Blork') + s = bleek; + else + if nargin==0 + s.bleek = 1; + else + s.bleek = bleek; + end + s = class(s, 'Blork'); + + end + +end
new file mode 100644 --- /dev/null +++ b/test/@Blork/bleek.m @@ -0,0 +1,10 @@ +function [ out ] = bleek( in, val ) + + if (nargin==1) + out = in.bleek; + else + in.bleek = val; + out = in; + end + +end
new file mode 100644 --- /dev/null +++ b/test/@Blork/display.m @@ -0,0 +1,7 @@ +function display( s ) + + disp([inputname(1),'.bleek = ']) + disp(' '); + disp(s.bleek); + +end \ No newline at end of file
new file mode 100644 --- /dev/null +++ b/test/@Blork/get.m @@ -0,0 +1,10 @@ +function [ v ] = get( s, propName ) + + switch propName + case 'bleek' + v = s.bleek; + otherwise + error([propName, ' is not a valid Blork property']); + end + +end
new file mode 100644 --- /dev/null +++ b/test/@Blork/set.m @@ -0,0 +1,16 @@ +function [ s ] = set( s, varargin ) + + propArgs = varargin; + while (length(propArgs) >= 2) + propName = propArgs{1}; + propValue = propArgs{2}; + propArgs = propArgs(3:end); + switch propName + case 'bleek' + s.bleek = propValue; + otherwise + error([propName, ' is not a valid Blork property']); + end + end + +end
new file mode 100644 --- /dev/null +++ b/test/@Cork/Cork.m @@ -0,0 +1,16 @@ +function [ s ] = Cork( click ) +% Test class. + + if ( (nargin==1) && (isa(click, 'Cork')) ) + s = click; + return; + end + + if( nargin<1 ) + s.click = 1; + else + s.click = click; + end + s = class(s, 'Cork'); + +end
new file mode 100644 --- /dev/null +++ b/test/@Cork/click.m @@ -0,0 +1,10 @@ +function [ out ] = click( in, val ) + + if (nargin==1) + out = in.click; + else + in.click = val; + out = in; + end + +end
new file mode 100644 --- /dev/null +++ b/test/@Cork/display.m @@ -0,0 +1,7 @@ +function display( s ) + + disp([inputname(1),'.click = ']); + disp(' '); + disp(s.click); + +end \ No newline at end of file
new file mode 100644 --- /dev/null +++ b/test/@Cork/get.m @@ -0,0 +1,10 @@ +function [ v ] = get( s, propName ) + + switch propName + case 'click' + v = s.click; + otherwise + error([propName, ' is not a valid Cork property']); + end + +end
new file mode 100644 --- /dev/null +++ b/test/@Cork/set.m @@ -0,0 +1,16 @@ +function [ s ] = set( s, varargin ) + + propArgs = varargin; + while (length(propArgs) >= 2) + propName = propArgs{1}; + propValue = propArgs{2}; + propArgs = propArgs(3:end); + switch propName + case 'click' + s.click = propValue; + otherwise + error([propName, ' is not a valid Cork property']); + end + end + +end
new file mode 100644 --- /dev/null +++ b/test/@Dork/Dork.m @@ -0,0 +1,18 @@ +function [ s ] = Dork( gick, gack ) + + if (nargin==1) && isa(gick,'Dork') + s = gick; + else + s.gack = 0; + if nargin == 0 + s0 = Snork(); + elseif nargin==1 + s0 = Snork(gick); + else + s0 = Snork(gick); + s.gack = gack; + end + s = class(s,'Dork',s0); + end + +end
new file mode 100644 --- /dev/null +++ b/test/@Dork/bling.m @@ -0,0 +1,5 @@ +function [ out ] = bling( m1, m2 ) + + out = 1; + +end
new file mode 100644 --- /dev/null +++ b/test/@Dork/display.m @@ -0,0 +1,13 @@ +function display( s ) +% Display the critical info for an amplifier + + gick = get(s,'gick'); + disp([inputname(1),'.gick = ']) + disp(' '); + disp(gick); + disp(' '); + disp([inputname(1),'.gack = ']) + disp(' '); + disp(s.gack); + +end
new file mode 100644 --- /dev/null +++ b/test/@Dork/gack.m @@ -0,0 +1,10 @@ +function [ out ] = gack( in, val ) + + if (nargin==1) + out = in.gack; + else + in.gack = val; + out = in; + end + +end
new file mode 100644 --- /dev/null +++ b/test/@Dork/get.m @@ -0,0 +1,10 @@ +function [ v ] = get( s, propName ) + + switch propName + case 'gack' + v = s.gack; + otherwise + v = get(s.Snork,propName); + end + +end
new file mode 100644 --- /dev/null +++ b/test/@Dork/getStash.m @@ -0,0 +1,5 @@ +function [ out ] = getStash(cls) + + out = myStash(); + +end
new file mode 100644 --- /dev/null +++ b/test/@Dork/private/myStash.m @@ -0,0 +1,5 @@ +function [ out ] = myStash() + + out = 2; + +end
new file mode 100644 --- /dev/null +++ b/test/@Dork/set.m @@ -0,0 +1,16 @@ +function [ s ] = set( s, varargin ) + + propArgs = varargin; + while (length(propArgs) >= 2) + propName = propArgs{1}; + propValue = propArgs{2}; + propArgs = propArgs(3:end); + switch propName + case 'gack' + s.gack = propValue; + otherwise + s.Snork = set(s.Snork, propName, propValue); + end + end + +end
new file mode 100644 --- /dev/null +++ b/test/@Gork/Gork.m @@ -0,0 +1,15 @@ +function [ s ] = Gork( g ) + if (nargin==1) && isa(g,'Gork') + s = sprk; + return; + end + + drk = Dork(); + prk = Pork(); + blrk = Blork(); + s.Cork = Cork(17); % Aggregation. + s.gark = -2; + s.gyrk = -3; + s = class(s,'Gork',drk,prk,blrk); + +end
new file mode 100644 --- /dev/null +++ b/test/@Gork/cork.m @@ -0,0 +1,10 @@ +function [ out ] = cork( in, val ) + + if (nargin==1) + out = in.Cork; + else + in.Cork = val; + out = in; + end + +end
new file mode 100644 --- /dev/null +++ b/test/@Gork/display.m @@ -0,0 +1,16 @@ +function display( s ) +% Display the critical info for a Gork. + + dork_base = s.Dork + %pork_base = s.Pork + %sprk = s.sprk; + gark = get(s,'gark'); + disp([inputname(1),'.gark = ']) + disp(' '); + disp(gark); + disp([inputname(1),'.Cork= ']) + disp(' '); + disp(click(s.Cork)); + + +end
new file mode 100644 --- /dev/null +++ b/test/@Gork/gark.m @@ -0,0 +1,10 @@ +function [ out ] = gark( in, val ) + + if (nargin==1) + out = in.gark; + else + in.gark = val; + out = in; + end + +end
new file mode 100644 --- /dev/null +++ b/test/@Gork/get.m @@ -0,0 +1,14 @@ +function [ v ] = get( s, propName ) + + switch propName + case 'cork' + v = s.Cork; + case 'gark' + v = s.gark; + otherwise + % Note that get/set for multiple parents is hard. We only do one + % branch of the parent tree just to test this stuff out. + v = get(s.Dork,propName); + end + +end
new file mode 100644 --- /dev/null +++ b/test/@Gork/set.m @@ -0,0 +1,24 @@ +function [ s ] = set( s, varargin ) + + propArgs = varargin; + while (length(propArgs) >= 2) + propName = propArgs{1}; + propValue = propArgs{2}; + propArgs = propArgs(3:end); + switch propName + case 'cork' + if(isa(propValue,'Cork')) + s.Cork = propValue; + else + s.Cork = set(s.Cork, 'click',propValue); + end + case 'gark' + s.gark = propValue; + otherwise + % Note that get/set for multiple parents is hard. We only do one + % branch of the parent tree just to test this stuff out. + s.Dork = set(s.Dork, propName, propValue); + end + end + +end
new file mode 100644 --- /dev/null +++ b/test/@Gork/subsasgn.m @@ -0,0 +1,9 @@ +function g = subsasgn(g, s, x) + + switch s.type + case '.' + switch s.subs + case 'gyrk' + g.gyrk = x; + end +end
new file mode 100644 --- /dev/null +++ b/test/@Gork/subsref.m @@ -0,0 +1,9 @@ +function x = subsref(g, s) + + switch s.type + case '.' + switch s.subs + case 'gyrk' + x = g.gyrk; + end +end
new file mode 100644 --- /dev/null +++ b/test/@Pork/Pork.m @@ -0,0 +1,19 @@ +function [ s ] = Pork( geek, gurk ) + + if (nargin==1) && isa(geek,'Pork') + s = geek; + else + s.gurk = 0; + if nargin == 0 + s0 = Spork(); + elseif nargin==1 + s0 = Spork(geek); + else + s0 = Spork(geek); + s.gurk = gurk; + end + s = class(s,'Pork',s0); + end + superiorto('Dork'); + +end
new file mode 100644 --- /dev/null +++ b/test/@Pork/bling.m @@ -0,0 +1,5 @@ +function [ out ] = bling( m1, m2 ) + + out = 2; + +end
new file mode 100644 --- /dev/null +++ b/test/@Pork/display.m @@ -0,0 +1,13 @@ +function display( s ) +% Display the critical info for an amplifier + + geek = get(s,'geek'); + disp([inputname(1),'.geek = ']) + disp(' '); + disp(geek); + disp(' '); + disp([inputname(1),'.gurk = ']) + disp(' '); + disp(s.gurk); + +end
new file mode 100644 --- /dev/null +++ b/test/@Pork/get.m @@ -0,0 +1,10 @@ +function [ v ] = get( s, propName ) + + switch propName + case 'gurk' + v = s.gurk; + otherwise + v = get(s.Spork,propName); + end + +end
new file mode 100644 --- /dev/null +++ b/test/@Pork/gurk.m @@ -0,0 +1,10 @@ +function [ out ] = gurk( in, val ) + + if (nargin==1) + out = in.gurk; + else + in.gurk = val; + out = in; + end + +end
new file mode 100644 --- /dev/null +++ b/test/@Pork/private/myStash.m @@ -0,0 +1,5 @@ +function [ out ] = myStash() + + out = 4; + +end
new file mode 100644 --- /dev/null +++ b/test/@Pork/set.m @@ -0,0 +1,16 @@ +function [ s ] = set( s, varargin ) + + propArgs = varargin; + while (length(propArgs) >= 2) + propName = propArgs{1}; + propValue = propArgs{2}; + propArgs = propArgs(3:end); + switch propName + case 'gurk' + s.gurk = propValue; + otherwise + s.Spork = set(s.Spork, propName, propValue); + end + end + +end
new file mode 100644 --- /dev/null +++ b/test/@Sneetch/Sneetch.m @@ -0,0 +1,16 @@ +function [ s ] = Sneetch( mcbean ) +% Test class: should produce error. + + if (nargin==1) && isa(mcbean, 'Sneetch') + s = mcbean; + else + if nargin==0 + s.mcbean = 1; + else + s.mcbean = mcbean; + end + s = class(s, 'Sneetch'); + s.sylvester = 1; + end + +end
new file mode 100644 --- /dev/null +++ b/test/@Sneetch/display.m @@ -0,0 +1,10 @@ +function display( s ) + + disp([inputname(1),'.mcbean = ']) + disp(' '); + disp(s.mcbean); + disp([inputname(1),'.sylvester = ']) + disp(' '); + disp(s.sylvester); + +end \ No newline at end of file
new file mode 100644 --- /dev/null +++ b/test/@Snork/Snork.m @@ -0,0 +1,17 @@ +function [ s ] = Snork( gick ) +% Test class. + + if ( (nargin==1) && (isa(gick, 'Snork')) ) + s = gick; + else + s.cack = [0 1 2 3]; + if nargin==0 + s.gick = 1; + else + s.gick = gick; + end + s = class(s, 'Snork'); + + end + +end
new file mode 100644 --- /dev/null +++ b/test/@Snork/cack.m @@ -0,0 +1,5 @@ +function [ out ] = cack( in ) + + out = in.cack; + +end
new file mode 100644 --- /dev/null +++ b/test/@Snork/display.m @@ -0,0 +1,7 @@ +function display( s ) + + disp([inputname(1),'.gick = ']); + disp(' '); + disp(s.gick); + +end \ No newline at end of file
new file mode 100644 --- /dev/null +++ b/test/@Snork/end.m @@ -0,0 +1,9 @@ +function r = end (snk, index_pos, num_indices) + + if (num_indices ~= 1) + error ('Snork object may only have one index') + end + + r = length (snk.cack); + +end
new file mode 100644 --- /dev/null +++ b/test/@Snork/get.m @@ -0,0 +1,10 @@ +function [ v ] = get( s, propName ) + + switch propName + case 'gick' + v = s.gick; + otherwise + error([propName, ' is not a valid Snork property']); + end + +end
new file mode 100644 --- /dev/null +++ b/test/@Snork/getStash.m @@ -0,0 +1,5 @@ +function [ out ] = getStash(cls) + + out = myStash(); + +end
new file mode 100644 --- /dev/null +++ b/test/@Snork/gick.m @@ -0,0 +1,10 @@ +function [ out ] = gick( in, val ) + + if (nargin==1) + out = in.gick; + else + in.gick = val; + out = in; + end + +end
new file mode 100644 --- /dev/null +++ b/test/@Snork/loadobj.m @@ -0,0 +1,6 @@ +function [ out ] = loadobj( in ) + + out = in; + out.cack = [-1 -2 -3 -4]; + +end
new file mode 100644 --- /dev/null +++ b/test/@Snork/private/myStash.m @@ -0,0 +1,5 @@ +function [ out ] = myStash() + + out = 1; + +end
new file mode 100644 --- /dev/null +++ b/test/@Snork/saveobj.m @@ -0,0 +1,6 @@ +function [ out ] = saveobj( in ) + + out = in; + out.cack = []; + +end
new file mode 100644 --- /dev/null +++ b/test/@Snork/set.m @@ -0,0 +1,16 @@ +function [ s ] = set( s, varargin ) + + propArgs = varargin; + while (length(propArgs) >= 2) + propName = propArgs{1}; + propValue = propArgs{2}; + propArgs = propArgs(3:end); + switch propName + case 'gick' + s.gick = propValue; + otherwise + error([propName, ' is not a valid Snork property']); + end + end + +end
new file mode 100644 --- /dev/null +++ b/test/@Snork/subsasgn.m @@ -0,0 +1,38 @@ +function snk = subsasgn (snk, s, val) + if (length (s) < 1) + error ('Snork: needs index'); + end + switch (s(1).type) + case '()' + ind = s(1).subs; + if (numel (ind) ~= 1) + error ('Snork: need exactly one index'); + else + if (length (s) == 1) + snk.cack(ind{1}) = val; + else + error ('Snork: chained subscripts not allowed for {}'); + end + end + case '{}' + ind = s(1).subs; + if (numel (ind) ~= 1) + error ('Snork: need exactly one index'); + else + if (length (s) == 1) + snk.cack(ind{1}) = val; + else + error ('Snork: chained subscripts not allowed for {}'); + end + end + case '.' + fld = s(1).subs; + if (strcmp (fld, 'gick')) + snk.gick = val; + else + error ('Snork/subsasgn: invalid property \"%s\"', fld); + end + otherwise + error ('invalid subscript type'); + end +end
new file mode 100644 --- /dev/null +++ b/test/@Snork/subsindex.m @@ -0,0 +1,5 @@ +function [ out ] = subsindex( obj ) + + out = 0; + +end
new file mode 100644 --- /dev/null +++ b/test/@Snork/subsref.m @@ -0,0 +1,30 @@ +function b = subsref (snk, s) + if (isempty (s)) + error ('Snork: missing index'); + end + switch (s(1).type) + case '()' + ind = s(1).subs; + if (numel (ind) ~= 1) + error ('Snork: need exactly one index'); + else + b = snk.cack(ind{1}); + end + case '{}' + ind = s(1).subs; + if (numel (ind) ~= 1) + error ('Snork: need exactly one index'); + else + b = snk.cack(ind{1}); + end + case '.' + fld = s.subs; + if (strcmp (fld, 'gick')) + b = snk.gick; + else + error ('Snork/subsref: invalid property \"%s\"', fld); + end + otherwise + error ('invalid subscript type'); + end +end
new file mode 100644 --- /dev/null +++ b/test/@Spork/Spork.m @@ -0,0 +1,17 @@ +function [ s ] = Spork( geek ) +% Test class. + + if (nargin==1) && isa(geek, 'Spork') + s = geek; + else + s.cack = [-1 -2 -3 -4]; + if nargin==0 + s.geek = 1; + else + s.geek = geek; + end + s = class(s, 'Spork'); + + end + +end
new file mode 100644 --- /dev/null +++ b/test/@Spork/cack.m @@ -0,0 +1,5 @@ +function [ out ] = cack( in ) + + out = in.cack; + +end
new file mode 100644 --- /dev/null +++ b/test/@Spork/display.m @@ -0,0 +1,7 @@ +function display( s ) + + disp([inputname(1),'.geek = ']) + disp(' '); + disp(s.geek); + +end \ No newline at end of file
new file mode 100644 --- /dev/null +++ b/test/@Spork/geek.m @@ -0,0 +1,10 @@ +function [ out ] = geek( in, val ) + + if (nargin==1) + out = in.geek; + else + in.geek = val; + out = in; + end + +end
new file mode 100644 --- /dev/null +++ b/test/@Spork/get.m @@ -0,0 +1,10 @@ +function [ v ] = get( s, propName ) + + switch propName + case 'geek' + v = s.geek; + otherwise + error([propName, ' is not a valid Spork property']); + end + +end
new file mode 100644 --- /dev/null +++ b/test/@Spork/getStash.m @@ -0,0 +1,5 @@ +function [ out ] = getStash(cls) + + out = myStash(); + +end
new file mode 100644 --- /dev/null +++ b/test/@Spork/loadobj.m @@ -0,0 +1,8 @@ +function [ out ] = loadobj( in ) + + out = in; + if (~isa(in,'Spork')) + out.cack=[]; + end + +end
new file mode 100644 --- /dev/null +++ b/test/@Spork/private/myStash.m @@ -0,0 +1,5 @@ +function [ out ] = myStash() + + out = 3; + +end
new file mode 100644 --- /dev/null +++ b/test/@Spork/saveobj.m @@ -0,0 +1,6 @@ +function [ out ] = saveobj( in ) + + out = in; + %rmfield(out,'cack'); + +end
new file mode 100644 --- /dev/null +++ b/test/@Spork/set.m @@ -0,0 +1,16 @@ +function [ s ] = set( s, varargin ) + + propArgs = varargin; + while (length(propArgs) >= 2) + propName = propArgs{1}; + propValue = propArgs{2}; + propArgs = propArgs(3:end); + switch propName + case 'geek' + s.geek = propValue; + otherwise + error([propName, ' is not a valid Spork property']); + end + end + +end
--- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,23 @@ +2009-06-23 Robert T. Short <octave@phaselockedsystems.com> + + * @Blork/Blork.m, @Blork/bleek.m, @Blork/display.m, @Blork/get.m, + @Blork/set.m, @Cork/Cork.m, @Cork/click.m, @Cork/display.m, + @Cork/get.m, @Cork/set.m, @Dork/Dork.m, @Dork/bling.m, + @Dork/display.m, @Dork/gack.m, @Dork/get.m, @Dork/getStash.m, + @Dork/private/myStash.m, @Dork/set.m, @Gork/Gork.m, @Gork/cork.m, + @Gork/display.m, @Gork/gark.m, @Gork/get.m, @Gork/set.m, + @Gork/subsasgn.m, @Gork/subsref.m, @Pork/Pork.m, @Pork/bling.m, + @Pork/display.m, @Pork/get.m, @Pork/gurk.m, + @Pork/private/myStash.m, @Pork/set.m, @Sneetch/Sneetch.m, + @Sneetch/display.m, @Snork/Snork.m, @Snork/cack.m, + @Snork/display.m, @Snork/end.m, @Snork/get.m, @Snork/getStash.m, + @Snork/gick.m, @Snork/loadobj.m, @Snork/private/myStash.m, + @Snork/saveobj.m, @Snork/set.m, @Snork/subsasgn.m, + @Snork/subsindex.m, @Snork/subsref.m, @Spork/Spork.m, + @Spork/cack.m, @Spork/display.m, @Spork/geek.m, @Spork/get.m, + @Spork/getStash.m, @Spork/loadobj.m, @Spork/private/myStash.m, + @Spork/saveobj.m, @Spork/set.m, test_classes.m: New files. + 2009-06-22 Jaroslav Hajek <highegg@gmail.com> * test_null_assign.m: Fix test.
new file mode 100644 --- /dev/null +++ b/test/test_classes.m @@ -0,0 +1,201 @@ +## Copyright (C) 2009 Robert T. Short +## +## This file is part of Octave. +## +## Octave is free software; you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 3 of the License, or (at +## your option) any later version. +## +## Octave is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Octave; see the file COPYING. If not, see +## <http://www.gnu.org/licenses/>. + +%% Test script for legacy OOP. +%% Requires the path to contain the test classes. +%% +%% Note: This script and all classes are also intended to run +%% in MATLAB to test compatibility. Don't break that! +%% +%% To Do: This script tests to ensure that things done correctly work +%% corrrectly. It should also check that things done incorrectly +%% error properly. +%% +%% The classes used for the tests reside in the test directory. +%% +%% The classes provide the ability to test most of the major features +%% of the legacy OOP facilities. There are a number of classes, mostly +%% kind of the same, that create a hierarchy. + +%% Test the Snork class. The Snork class has a number of the standard +%% methods that the others don't so we can test indexing and other +%% 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) +%!test snk.gick = 4; +%! assert(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')) +%!test snk1 = Snork(snk); +%! assert(class(snk1),'Snork') +%! assert(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. +%% save temp snk; +%% load temp % This load causes a segment fault. +%% assert(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 +%% sure that we haven't bollixed up the Spork class if we should make +%% 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')) + +%% 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 +%% sure that we haven't bollixed up the Blork class if we should make +%% 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')) + +%% 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 +%% sure that we haven't bollixed up the Cork class if we should make +%% changes. We use Cork in the class hierarchy. +%!shared crk +%!test crk = Cork(23); +%! assert(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')) + +%% 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) +%!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) + +%% 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')) +%!test drk = Dork(); % Precedence. +%! assert(bling(drk,prk),2) +%! assert(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) +%!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'))