fgap_list_test.sa
Generated by gen_html_sa_files from ICSI. Contact gomes@icsi.berkeley.edu for details
---------------------------> Sather 1.1 source file <--------------------------
-- test_fgap_list.sa:
-- Author: Benedict A. Gomes <gomes@samosa.ICSI.Berkeley.EDU>
-- Copyright (C) 1995, International Computer Science Institute
-- $Id: fgap_list_test.sa,v 1.2 1996/04/09 10:04:52 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_FGAP_LIST
class TEST_FGAP_LIST is
-- Test of `FGAP_LIST{T}'.
include TEST;
main is
-- Test of `GAP_LIST{T}'.
class_name("FGAP_LIST{INT}");
l: FGAP_LIST{INT} := list_of_range(0,14);
resl:ARRAY{INT} := |0,1,2,3,4,5,6,7,8,9,10,11,12,13,14|;
test("list entries", l.str,resl.str);
test("size", l.size.str, 15.str);
test("is_empty 1", l.is_empty, false);
l := l.delete(2);
lres2 ::= #ARRAY{INT}(|0,1,3,4,5,6,7,8,9,10,11,12,13,14|);
test("delete", l,lres2.str);
l := l.insert(4, 17);
lres3 ::= #ARRAY{INT}(|0,1,3,4,17,5,6,7,8,9,10,11,12,13,14|);
test("insert", l,lres3.str);
test("get", l.get(4), 17);
l.replace(4, 19);
lres4 ::= #ARRAY{INT}(|0,1,3,4,19,5,6,7,8,9,10,11,12,13,14|);
test("replace", l.str,lres4.str);
l.clear;
lres5 ::= #ARRAY{INT};
test("clear",l.str, lres5.str);
test("is_empty 2", l.is_empty, true);
finish;
end; -- main
list_of_range(l,h: INT): FGAP_LIST{INT} is
-- A gap list containing `l,...,h'.
res ::= #FGAP_LIST{INT};
i:INT := l; loop until!(i>h); res := res.insert(res.size, i);i:=i+1 end;
return res;
end; -- list_of_range
end; -- class GAP_LIST_TEST
--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~