------------------------->  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 STACK_TEST is
   include TEST;
   
   nr_stack is
      class_name("NR_STACK{STR}");
      s::= #NR_A_STACK{STR};
      s.push("a");
      s.push("b");
      l ::= #FLIST{STR}(|"a","b"|);
      test("push",s.str,l.str);
      test("size",s.size.str,2.str);
      s.push("c");
      s.push("d");
      l2 ::= #FLIST{STR}(|"a","b","c","d"|);
      test("push",s.str,l2.str);
      test("size",s.size.str,4.str);
      test("pop",s.pop,"d");
      test("top",s.top,"c");
      test("size",s.size.str,3.str);
      test("is_empty",s.is_empty.str,false.str);
      test("pop",s.pop,"c");
      test("pop",s.pop,"b");
      test("pop",s.pop,"a");
      test("is_empty",s.is_empty.str,true.str);
      g ::= #NR_STACK{STR};
      test("is_empty",g.is_empty.str,true.str); 
      finish;
   end;

   main is
      class_name("STACK{STR}");
      sarr ::= A_STACK{INT}::create_from(|1,2,3,4,5|);
      test("size",sarr.size,5);
      test("top",sarr.top,5);
      s::= #A_STACK{STR};
      s.push("a");
      s.push("b");
      l ::= #FLIST{STR}(|"a","b"|);
      test("push",s.str,l.str);
      test("size",s.size.str,2.str);
      s.push("c");
      s.push("d");
      l2 ::= #FLIST{STR}(|"a","b","c","d"|);
      test("push",s.str,l2.str);
      test("size",s.size.str,4.str);
      test("pop",s.pop,"d");
      test("top",s.top,"c");
      test("size",s.size.str,3.str);
      test("is_empty",s.is_empty.str,false.str);
      test("pop",s.pop,"c");
      test("pop",s.pop,"b");
      test("pop",s.pop,"a");
      test("is_empty",s.is_empty.str,true.str);
      g ::= #STACK{STR};
      test("is_empty",g.is_empty.str,true.str); 
      finish;
      nr_stack;
   end;

end;
-------------------------------------------------------------------   

