------------------------->  GNU Sather - sourcefile  <-------------------------
-- Copyright (C) 1995 by International Computer Science Institute            --
-- This file is part of the GNU Sather library. It is free software; you may --
-- redistribute  and/or modify it under the terms of the GNU Library General --
-- Public  License (LGPL)  as published  by the  Free  Software  Foundation; --
-- either version 2 of the license, or (at your option) any later version.   --
-- This  library  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/LGPL 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>  <--------------

-- Author: Benedict A. Gomes <gomes@samosa.ICSI.Berkeley.EDU>

class AREF_TEST is
   include TEST;
   
   main is
      class_name("AREF{INT}");
      a ::= #AREF{INT}(5);
      a[0] := 0; a[1] := 1; a[2] := 2; a[3]:=3; a[4]:=4;
      test("aset and aget",a[2].str,"2");
      res::=""; loop res := res+" "+a.aelt!; end;
      test("aelt!",res," 0 1 2 3 4");
      res:=""; loop res := res+" "+a.aelt!(1); end;
      test("aelt!(beg)",res," 1 2 3 4");
      res:=""; loop res := res+" "+a.aelt!(1,2); end;
      test("aelt!(1,2)",res," 1 2");
      res:=""; loop res := res+" "+a.aelt!(1,2,2); end;
      test("aelt!(1,2,2)",res," 1 3");


      b ::=#AREF{INT}(a.asize);  
      
      b.acopy(a);
      res:=""; loop res := res+" "+b.aelt!; end;
      test("acopy",res," 0 1 2 3 4");
      
      c ::= #AREF{INT}(3);
      c.acopy(a);
      res:=""; loop res := res+" "+c.aelt!; end;
      test("acopy",res," 0 1 2");
      
      loop b.aset!(1); end;
      res:=""; loop res := res+" "+b.aelt!; end;
      test("aset",res," 1 1 1 1 1");
      
      b.acopy(a);
      loop b.aset!(3,1); end;
      res:=""; loop res := res+" "+b.aelt!; end;
      test("aset(3,1)",res," 0 1 2 1 1");
      
      b.acopy(a);
      loop b.aset!(2,2,7); end;
      res:=""; loop res := res+" "+b.aelt!; end;
      test("aset(2,2,7)",res," 0 1 7 7 4");

      b.acopy(a);
      loop b.aset!(1,2,2,9); end;
      res:=""; loop res := res+" "+b.aelt!; end;
      test("aset(1,2,2,9)",res," 0 9 2 9 4");
      
      b.acopy(1,a);
      res:=""; loop res := res+" "+b.aelt!; end;
      test("acopy(1)",res," 0 0 1 2 3");
      
      b.aclear;
      res:=""; loop res := res+" "+b.aelt!; end;
      test("acopy(1)",res," 0 0 0 0 0");
      
      b.acopy(2,2,a);
      res:=""; loop res := res+" "+b.aelt!; end;
      test("acopy(2,2)",res," 0 0 0 1 0");

      b.acopy(2,2,2,a);
      res:=""; loop res := res+" "+b.aelt!; end;
      test("acopy(2,2)",res," 0 0 2 3 0");
      finish;
      end;
   
end; 

-------------------------------------------------------------------
