octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

OOP test patch


From: Robert T. Short
Subject: OOP test patch
Date: Sun, 21 Jun 2009 08:24:46 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.21) Gecko/20090402 SeaMonkey/1.1.16

Attached is a patch that includes a set of OOP tests in the test framework.

- Changed run-octave to exclude @-files
- Added a bunch of classes to the test directory
- Put the tests into ov-class.cc

Note that in run-octave.in, there were CVS path exclusions. I took these out since there are no such files any more. If anybody objects, I will put them back.

Bob

# HG changeset patch
# User Robert T. Short <address@hidden>
# Date 1245597553 25200
# Node ID fb05277a7969318028dd24d9ecf1a8f8866d0bbd
# Parent  ff612fdaee956d05a5bae9c34dfdcc3f3a6b5a32
  * run-octave.in: Exclude @-files from path.  Remove CVS exclusions.
  * test: Add class directories for testing.
  * ov-class.cc: Add tests.

diff -r ff612fdaee95 -r fb05277a7969 ChangeLog
--- a/ChangeLog Sat Jun 20 10:13:30 2009 +0200
+++ b/ChangeLog Sun Jun 21 08:19:13 2009 -0700
@@ -1,3 +1,7 @@
+2009-06-21  Robert T. Short  <address@hidden>
+
+       * run-octave.in: Exclude @-files from path.  Remove CVS exclusions.
+
 2009-06-19  Jaroslav Hajek  <address@hidden>
 
        * NEWS: Update.
diff -r ff612fdaee95 -r fb05277a7969 run-octave.in
--- a/run-octave.in     Sat Jun 20 10:13:30 2009 +0200
+++ b/run-octave.in     Sun Jun 21 08:19:13 2009 -0700
@@ -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; }'`
diff -r ff612fdaee95 -r fb05277a7969 src/ChangeLog
--- a/src/ChangeLog     Sat Jun 20 10:13:30 2009 +0200
+++ b/src/ChangeLog     Sun Jun 21 08:19:13 2009 -0700
@@ -1,3 +1,7 @@
+2009-06-21  Robert T. Short  <address@hidden>
+
+       * ov-class.cc: Added tests.
+
 2009-06-20  Jaroslav Hajek  <address@hidden>
 
        * ov.cc (Fsubsasgn): Uniquify shared value before assigning to it.
diff -r ff612fdaee95 -r fb05277a7969 src/ov-class.cc
--- a/src/ov-class.cc   Sat Jun 20 10:13:30 2009 +0200
+++ b/src/ov-class.cc   Sun Jun 21 08:19:13 2009 -0700
@@ -1964,6 +1964,192 @@
 }
 
 /*
+%%  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'))
+ */
+
+/*
 ;;; Local Variables: ***
 ;;; mode: C++ ***
 ;;; End: ***
diff -r ff612fdaee95 -r fb05277a7969 test/@Blork/Blork.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Blork/Blork.m       Sun Jun 21 08:19:13 2009 -0700
@@ -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
diff -r ff612fdaee95 -r fb05277a7969 test/@Blork/bleek.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Blork/bleek.m       Sun Jun 21 08:19:13 2009 -0700
@@ -0,0 +1,10 @@
+function [ out ] = bleek( in, val )
+
+  if (nargin==1) 
+    out = in.bleek;
+  else
+    in.bleek = val;
+    out = in;
+  end
+        
+end
diff -r ff612fdaee95 -r fb05277a7969 test/@Blork/display.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Blork/display.m     Sun Jun 21 08:19:13 2009 -0700
@@ -0,0 +1,7 @@
+function display( s )
+
+  disp([inputname(1),'.bleek = '])
+  disp(' ');
+  disp(s.bleek);
+
+end
\ No newline at end of file
diff -r ff612fdaee95 -r fb05277a7969 test/@Blork/get.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Blork/get.m Sun Jun 21 08:19:13 2009 -0700
@@ -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
diff -r ff612fdaee95 -r fb05277a7969 test/@Blork/set.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Blork/set.m Sun Jun 21 08:19:13 2009 -0700
@@ -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
diff -r ff612fdaee95 -r fb05277a7969 test/@Cork/Cork.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Cork/Cork.m Sun Jun 21 08:19:13 2009 -0700
@@ -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
diff -r ff612fdaee95 -r fb05277a7969 test/@Cork/click.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Cork/click.m        Sun Jun 21 08:19:13 2009 -0700
@@ -0,0 +1,10 @@
+function [ out ] = click( in, val )
+
+  if (nargin==1) 
+    out = in.click;
+  else
+    in.click = val;
+    out = in;
+  end
+        
+end
diff -r ff612fdaee95 -r fb05277a7969 test/@Cork/display.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Cork/display.m      Sun Jun 21 08:19:13 2009 -0700
@@ -0,0 +1,7 @@
+function display( s )
+
+  disp([inputname(1),'.click = ']);
+  disp(' ');
+  disp(s.click);
+
+end
\ No newline at end of file
diff -r ff612fdaee95 -r fb05277a7969 test/@Cork/get.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Cork/get.m  Sun Jun 21 08:19:13 2009 -0700
@@ -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
diff -r ff612fdaee95 -r fb05277a7969 test/@Cork/set.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Cork/set.m  Sun Jun 21 08:19:13 2009 -0700
@@ -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
diff -r ff612fdaee95 -r fb05277a7969 test/@Dork/Dork.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Dork/Dork.m Sun Jun 21 08:19:13 2009 -0700
@@ -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
diff -r ff612fdaee95 -r fb05277a7969 test/@Dork/bling.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Dork/bling.m        Sun Jun 21 08:19:13 2009 -0700
@@ -0,0 +1,5 @@
+function [ out ] = bling( m1, m2 )
+
+  out = 1;
+        
+end
diff -r ff612fdaee95 -r fb05277a7969 test/@Dork/display.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Dork/display.m      Sun Jun 21 08:19:13 2009 -0700
@@ -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
diff -r ff612fdaee95 -r fb05277a7969 test/@Dork/gack.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Dork/gack.m Sun Jun 21 08:19:13 2009 -0700
@@ -0,0 +1,10 @@
+function [ out ] = gack( in, val )
+
+  if (nargin==1) 
+    out = in.gack;
+  else
+    in.gack = val;
+    out = in;
+  end
+        
+end
diff -r ff612fdaee95 -r fb05277a7969 test/@Dork/get.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Dork/get.m  Sun Jun 21 08:19:13 2009 -0700
@@ -0,0 +1,10 @@
+function [ v ] = get( s, propName )
+
+  switch propName
+    case 'gack'
+      v = s.gack;
+    otherwise
+      v = get(s.Snork,propName);
+  end
+
+end
diff -r ff612fdaee95 -r fb05277a7969 test/@Dork/getStash.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Dork/getStash.m     Sun Jun 21 08:19:13 2009 -0700
@@ -0,0 +1,5 @@
+function [ out ] = getStash(cls)
+
+  out = myStash();
+        
+end
diff -r ff612fdaee95 -r fb05277a7969 test/@Dork/private/myStash.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Dork/private/myStash.m      Sun Jun 21 08:19:13 2009 -0700
@@ -0,0 +1,5 @@
+function [ out ] = myStash()
+
+  out = 2;
+
+end
diff -r ff612fdaee95 -r fb05277a7969 test/@Dork/set.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Dork/set.m  Sun Jun 21 08:19:13 2009 -0700
@@ -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
diff -r ff612fdaee95 -r fb05277a7969 test/@Gork/Gork.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Gork/Gork.m Sun Jun 21 08:19:13 2009 -0700
@@ -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
diff -r ff612fdaee95 -r fb05277a7969 test/@Gork/cork.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Gork/cork.m Sun Jun 21 08:19:13 2009 -0700
@@ -0,0 +1,10 @@
+function [ out ] = cork( in, val )
+
+  if (nargin==1) 
+    out = in.Cork;
+  else
+    in.Cork = val;
+    out = in;
+  end
+        
+end
diff -r ff612fdaee95 -r fb05277a7969 test/@Gork/display.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Gork/display.m      Sun Jun 21 08:19:13 2009 -0700
@@ -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
diff -r ff612fdaee95 -r fb05277a7969 test/@Gork/gark.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Gork/gark.m Sun Jun 21 08:19:13 2009 -0700
@@ -0,0 +1,10 @@
+function [ out ] = gark( in, val )
+
+  if (nargin==1) 
+    out = in.gark;
+  else
+    in.gark = val;
+    out = in;
+  end
+        
+end
diff -r ff612fdaee95 -r fb05277a7969 test/@Gork/get.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Gork/get.m  Sun Jun 21 08:19:13 2009 -0700
@@ -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
diff -r ff612fdaee95 -r fb05277a7969 test/@Gork/set.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Gork/set.m  Sun Jun 21 08:19:13 2009 -0700
@@ -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
diff -r ff612fdaee95 -r fb05277a7969 test/@Gork/subsasgn.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Gork/subsasgn.m     Sun Jun 21 08:19:13 2009 -0700
@@ -0,0 +1,9 @@
+function g = subsasgn(g, s, x)
+
+  switch s.type
+  case '.'
+    switch s.subs
+    case 'gyrk'
+      g.gyrk = x; 
+  end
+end
diff -r ff612fdaee95 -r fb05277a7969 test/@Gork/subsref.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Gork/subsref.m      Sun Jun 21 08:19:13 2009 -0700
@@ -0,0 +1,9 @@
+function x = subsref(g, s)
+
+  switch s.type
+  case '.'
+    switch s.subs
+    case 'gyrk'
+      x = g.gyrk;
+  end
+end
diff -r ff612fdaee95 -r fb05277a7969 test/@Pork/Pork.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Pork/Pork.m Sun Jun 21 08:19:13 2009 -0700
@@ -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
diff -r ff612fdaee95 -r fb05277a7969 test/@Pork/bling.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Pork/bling.m        Sun Jun 21 08:19:13 2009 -0700
@@ -0,0 +1,5 @@
+function [ out ] = bling( m1, m2 )
+
+  out = 2;
+        
+end
diff -r ff612fdaee95 -r fb05277a7969 test/@Pork/display.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Pork/display.m      Sun Jun 21 08:19:13 2009 -0700
@@ -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
diff -r ff612fdaee95 -r fb05277a7969 test/@Pork/get.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Pork/get.m  Sun Jun 21 08:19:13 2009 -0700
@@ -0,0 +1,10 @@
+function [ v ] = get( s, propName )
+
+  switch propName
+    case 'gurk'
+      v = s.gurk;
+    otherwise
+      v = get(s.Spork,propName);
+  end
+
+end
diff -r ff612fdaee95 -r fb05277a7969 test/@Pork/gurk.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Pork/gurk.m Sun Jun 21 08:19:13 2009 -0700
@@ -0,0 +1,10 @@
+function [ out ] = gurk( in, val )
+
+  if (nargin==1) 
+    out = in.gurk;
+  else
+    in.gurk = val;
+    out = in;
+  end
+        
+end
diff -r ff612fdaee95 -r fb05277a7969 test/@Pork/private/myStash.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Pork/private/myStash.m      Sun Jun 21 08:19:13 2009 -0700
@@ -0,0 +1,5 @@
+function [ out ] = myStash()
+
+  out = 4;
+
+end
diff -r ff612fdaee95 -r fb05277a7969 test/@Pork/set.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Pork/set.m  Sun Jun 21 08:19:13 2009 -0700
@@ -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
diff -r ff612fdaee95 -r fb05277a7969 test/@Sneetch/Sneetch.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Sneetch/Sneetch.m   Sun Jun 21 08:19:13 2009 -0700
@@ -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
diff -r ff612fdaee95 -r fb05277a7969 test/@Sneetch/display.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Sneetch/display.m   Sun Jun 21 08:19:13 2009 -0700
@@ -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
diff -r ff612fdaee95 -r fb05277a7969 test/@Snork/Snork.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Snork/Snork.m       Sun Jun 21 08:19:13 2009 -0700
@@ -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
diff -r ff612fdaee95 -r fb05277a7969 test/@Snork/cack.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Snork/cack.m        Sun Jun 21 08:19:13 2009 -0700
@@ -0,0 +1,5 @@
+function [ out ] = cack( in )
+
+  out = in.cack;
+        
+end
diff -r ff612fdaee95 -r fb05277a7969 test/@Snork/display.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Snork/display.m     Sun Jun 21 08:19:13 2009 -0700
@@ -0,0 +1,7 @@
+function display( s )
+
+  disp([inputname(1),'.gick = ']);
+  disp(' ');
+  disp(s.gick);
+
+end
\ No newline at end of file
diff -r ff612fdaee95 -r fb05277a7969 test/@Snork/end.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Snork/end.m Sun Jun 21 08:19:13 2009 -0700
@@ -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
diff -r ff612fdaee95 -r fb05277a7969 test/@Snork/get.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Snork/get.m Sun Jun 21 08:19:13 2009 -0700
@@ -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
diff -r ff612fdaee95 -r fb05277a7969 test/@Snork/getStash.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Snork/getStash.m    Sun Jun 21 08:19:13 2009 -0700
@@ -0,0 +1,5 @@
+function [ out ] = getStash(cls)
+
+  out = myStash();
+        
+end
diff -r ff612fdaee95 -r fb05277a7969 test/@Snork/gick.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Snork/gick.m        Sun Jun 21 08:19:13 2009 -0700
@@ -0,0 +1,10 @@
+function [ out ] = gick( in, val )
+
+  if (nargin==1) 
+    out = in.gick;
+  else
+    in.gick = val;
+    out = in;
+  end
+        
+end
diff -r ff612fdaee95 -r fb05277a7969 test/@Snork/loadobj.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Snork/loadobj.m     Sun Jun 21 08:19:13 2009 -0700
@@ -0,0 +1,6 @@
+function [ out ] = loadobj( in )
+
+  out = in;
+  out.cack = [-1 -2 -3 -4];
+        
+end
diff -r ff612fdaee95 -r fb05277a7969 test/@Snork/private/myStash.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Snork/private/myStash.m     Sun Jun 21 08:19:13 2009 -0700
@@ -0,0 +1,5 @@
+function [ out ] = myStash()
+
+  out = 1;
+        
+end
diff -r ff612fdaee95 -r fb05277a7969 test/@Snork/saveobj.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Snork/saveobj.m     Sun Jun 21 08:19:13 2009 -0700
@@ -0,0 +1,6 @@
+function [ out ] = saveobj( in )
+
+  out = in;
+  out.cack = [];
+        
+end
diff -r ff612fdaee95 -r fb05277a7969 test/@Snork/set.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Snork/set.m Sun Jun 21 08:19:13 2009 -0700
@@ -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
diff -r ff612fdaee95 -r fb05277a7969 test/@Snork/subsasgn.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Snork/subsasgn.m    Sun Jun 21 08:19:13 2009 -0700
@@ -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
diff -r ff612fdaee95 -r fb05277a7969 test/@Snork/subsindex.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Snork/subsindex.m   Sun Jun 21 08:19:13 2009 -0700
@@ -0,0 +1,5 @@
+function [ out ] = subsindex( obj )
+
+  out = 0;
+        
+end
diff -r ff612fdaee95 -r fb05277a7969 test/@Snork/subsref.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Snork/subsref.m     Sun Jun 21 08:19:13 2009 -0700
@@ -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
diff -r ff612fdaee95 -r fb05277a7969 test/@Spork/Spork.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Spork/Spork.m       Sun Jun 21 08:19:13 2009 -0700
@@ -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
diff -r ff612fdaee95 -r fb05277a7969 test/@Spork/cack.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Spork/cack.m        Sun Jun 21 08:19:13 2009 -0700
@@ -0,0 +1,5 @@
+function [ out ] = cack( in )
+
+  out = in.cack;
+        
+end
diff -r ff612fdaee95 -r fb05277a7969 test/@Spork/display.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Spork/display.m     Sun Jun 21 08:19:13 2009 -0700
@@ -0,0 +1,7 @@
+function display( s )
+
+  disp([inputname(1),'.geek = '])
+  disp(' ');
+  disp(s.geek);
+
+end
\ No newline at end of file
diff -r ff612fdaee95 -r fb05277a7969 test/@Spork/geek.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Spork/geek.m        Sun Jun 21 08:19:13 2009 -0700
@@ -0,0 +1,10 @@
+function [ out ] = geek( in, val )
+
+  if (nargin==1) 
+    out = in.geek;
+  else
+    in.geek = val;
+    out = in;
+  end
+        
+end
diff -r ff612fdaee95 -r fb05277a7969 test/@Spork/get.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Spork/get.m Sun Jun 21 08:19:13 2009 -0700
@@ -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
diff -r ff612fdaee95 -r fb05277a7969 test/@Spork/getStash.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Spork/getStash.m    Sun Jun 21 08:19:13 2009 -0700
@@ -0,0 +1,5 @@
+function [ out ] = getStash(cls)
+
+  out = myStash();
+        
+end
diff -r ff612fdaee95 -r fb05277a7969 test/@Spork/loadobj.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Spork/loadobj.m     Sun Jun 21 08:19:13 2009 -0700
@@ -0,0 +1,8 @@
+function [ out ] = loadobj( in )
+
+  out = in;
+  if (~isa(in,'Spork'))
+    out.cack=[];
+  end
+        
+end
diff -r ff612fdaee95 -r fb05277a7969 test/@Spork/private/myStash.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Spork/private/myStash.m     Sun Jun 21 08:19:13 2009 -0700
@@ -0,0 +1,5 @@
+function [ out ] = myStash()
+
+  out = 3;
+        
+end
diff -r ff612fdaee95 -r fb05277a7969 test/@Spork/saveobj.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Spork/saveobj.m     Sun Jun 21 08:19:13 2009 -0700
@@ -0,0 +1,6 @@
+function [ out ] = saveobj( in )
+
+  out = in;
+  %rmfield(out,'cack');
+        
+end
diff -r ff612fdaee95 -r fb05277a7969 test/@Spork/set.m
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/test/@Spork/set.m Sun Jun 21 08:19:13 2009 -0700
@@ -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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]