stack_test.sa


Generated by gen_html_sa_files from ICSI. Contact gomes@icsi.berkeley.edu for details
 
---------------------------> Sather 1.1 source file <--------------------------
-- Author: Benedict A. Gomes <gomes@samosa.ICSI.Berkeley.EDU>
-- Copyright (C) 1995, International Computer Science Institute
-- $Id: stack_test.sa,v 1.3 1996/04/09 10:05:29 borisv Exp $
--
-- COPYRIGHT NOTICE: This code is provided WITHOUT ANY WARRANTY
-- and is subject to the terms of the SATHER LIBRARY GENERAL PUBLIC
-- LICENSE contained in the file: Sather/Doc/License of the
-- Sather distribution. The license is also available from ICSI,
-- 1947 Center St., Suite 600, Berkeley CA 94704, USA.


class TEST_STACK

class TEST_STACK 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;