------------------------->  GNU Sather - sourcefile  <-------------------------
-- Copyright (C) 1996 by International Computer Science Institute            --
-- This file is part of the GNU Sather package. It is free software; you may --
-- redistribute  and/or modify it under the terms of the  GNU General Public --
-- License (GPL)  as  published  by the  Free  Software  Foundation;  either --
-- version 2 of the license, or (at your option) any later version.          --
-- This  program  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 Doc/GPL for more details.        --
-- The license text is also available from:  Free Software Foundation, Inc., --
-- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA                     --
-------------->  Please email comments to <bug-sather@gnu.org>  <--------------

-- test-partial.sa: test partial classes and stub routines
-- Author: Boris Vaysman <borisv@crape.ICSI.Berkeley.EDU>

class TEST_PARTIAL is
   include TEST;
   
   create:SAME is return new; end;
   
   main is
      class_name("PARTIAL");
      
      a0:A0 := #;
      test("simple partial class", "1",a0.foo(0));
      a1:AT0 := #;
      test("parametrized partial class test", "2", a1.foo(1));
      a2:A1 := #;      
      test("conflicting included stubs test", "3", a2.foo(2));
      
      a3:A3 := #;
      test("Private implementation of a stub test", "4", a3.bar(3));      
      
      a4:A4 := #;
      test("Stub implemented by different partial class", "5", a4.foo(4));
      
      a5:A5 := #;
      test("Stub received by transitive inclusion test", "6", a5.foo(5));   
      
      a6:A6 := #;
      test("Partial classes under abstraction test 1", "7", a6.foo(6));
      
      a7:A7 := #;
      test("Partial classes under abstraction test 2", "8", a7.foo(7));   
      
      a8:A8 := #;
      test("Partial classes under abstraction test 3", "9", a8.bar(8));   
      
      a9:A9 := #;
      test("Partial classes under abstraction test 4", "10", a9.foo(8));
      
   end;

end; -- class TEST_PARTIAL
-------------------------------------------------------------------



partial class FOO is
   create:SAME is return new; end;
   
   foo(i:INT):INT is
      return i+1;
   end;
end;

---------------------------------
partial class AP0 is
   stub foo(i:INT):INT;
end;

partial class AP1 is
   stub foo(i:INT):INT;
end;

partial class AP2 is
   foo(i:INT):INT is
      return i+1;
   end;
end;


partial class AP3 is
   include APA1;
   
   private stub foo(i:INT):INT;
end;

partial class AP4 is
   include AP1;
end; 

partial class AP5 is
   private stub foo(i:INT):INT;
end;
---------------------------------
partial class APT0{T} is
   stub foo(i:T):T;
end;

---------------------------------
abstract class $AFOO is
   foo(i:INT):INT;
end;

partial class APA1 < $AFOO is
   stub foo(i:INT):INT;
end;
---------------------------------

class A0 is
   include FOO;
   include AP0;
end;

class A1 is
   include AP0;
   include AP1;
   include FOO;
   
   foo(i:INT):INT is
      return i+1;
   end;
end;

class A3 is
   include AP0;
   include FOO foo-> private foo;
   
   bar(i:INT):INT is
      return i+1;
   end;
end;

class A4 is 
   include AP2;
   include FOO foo->;
end;

class A5 is
   include AP4;
   
   create:SAME is return new; end;
   foo(i:INT):INT is
      return i+1;
   end;
end;

class A6 is
   include APA1;
   include FOO;
end;

class A7 < $AFOO is
   include APA1;
   include FOO;
end;

class A8 is
   include APA1;
   include FOO;
   
   private foo(i:INT):INT is
      return i+1;
   end;
   
   bar (i:INT):INT is
      return i+1;
   end;
end;

class A9 < $AFOO is
   include AP5;
   include FOO foo->bar;
   
   foo(i:INT):INT is
      return i+2;
   end;
end;
   
class AT0 is
   include APT0{INT};
   include FOO;
end;


	 

