array3_test.sa


Generated by gen_html_sa_files from ICSI. Contact gomes@icsi.berkeley.edu for details
 
---------------------------> Sather 1.1 source file <--------------------------
-- test_array3.sa: 
-- Author: Benedict A. Gomes <gomes@samosa.ICSI.Berkeley.EDU>
-- Copyright (C) 1995, International Computer Science Institute
-- $Id: array3_test.sa,v 1.2 1996/04/09 10:04:44 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_ARRAY3

class TEST_ARRAY3 is include TEST; -- INT and its iters should be tested before this class is tested. main is -- Note: Some operations are tested in the matrix class -- (transpose, to_portion_of). -- More convenient to do the tests there?? class_name("ARRAY3"); a ::= #ARRAY3{INT}(3,4,5); test("create1 and size1",a.size1.str,"3"); test("create1 and size2",a.size2.str,"4"); test("create1 and size3",a.size3.str,"5"); test("create1 and nr",a.nr.str,"3"); test("create1 and nc",a.nc.str,"4"); test("create1 and ne",a.ne.str,"5"); ainit: ARRAY{ARRAY{ARRAY{INT}}} := |||0,1,2,3|,|10,11,12,13|,|20,21,22,23||, ||100,101,102,103|,|110,111,112,113|,|120,121,122,123||, ||200,201,202,203|,|210,211,212,213|,|220,221,222,223||, ||300,301,302,303|,|310,311,312,313|,|320,321,322,323|||; a2 ::= #ARRAY3{INT}(ainit); test("create2 and size1",a2.size1.str,"4"); test("create2 and size2",a2.size2.str,"3"); test("create2 and size3",a2.size3.str,"4"); test("create2 and nr",a2.nr.str,"4"); test("create2 and nc",a2.nc.str,"3"); test("create2 and ne",a2.ne.str,"4"); test("aget",a2[0,0,2].str,"2"); test("aget",a2[0,2,0].str,"20"); test("aget",a2[1,2,3].str,"123"); test("aget[3,2,1]",a2[3,2,1].str,"321"); a2[0,0,2] := 3; test("aset",a2[0,0,2].str,"3"); a2[0,0,2] := 2; test("aset",a2[0,0,2].str,"2"); a2[1,1,1] := 99; test("aset",a2[1,1,1].str,"99"); a2[1,1,1] := 11; test("aset",a2[1,1,1].str,"11"); res::=""; loop res := res+" "+a.ind1! end; test("ind1",res," 0 1 2"); res:=""; loop res := res+" "+a.ind2! end; test("ind2",res," 0 1 2 3"); res:=""; loop res := res+" "+a.ind3! end; test("ind3",res," 0 1 2 3 4"); res:=""; loop res := res+" "+a.row_ind! end; test("row",res," 0 1 2"); res:=""; loop res := res+" "+a.col_ind! end; test("col",res," 0 1 2 3"); res:=""; loop res := res+" "+a.elem_ind! end; test("elem",res," 0 1 2 3 4"); res:=""; loop res := res+" "+a.inds!.t1+","+a.inds!.t2+","+a.inds!.t3 end; test("inds",res, " 0,0,0 0,0,1 0,0,2 0,0,3 0,0,4" " 0,1,0 0,1,1 0,1,2 0,1,3 0,1,4" " 0,2,0 0,2,1 0,2,2 0,2,3 0,2,4" " 0,3,0 0,3,1 0,3,2 0,3,3 0,3,4" " 1,0,0 1,0,1 1,0,2 1,0,3 1,0,4" " 1,1,0 1,1,1 1,1,2 1,1,3 1,1,4" " 1,2,0 1,2,1 1,2,2 1,2,3 1,2,4" " 1,3,0 1,3,1 1,3,2 1,3,3 1,3,4" " 2,0,0 2,0,1 2,0,2 2,0,3 2,0,4" " 2,1,0 2,1,1 2,1,2 2,1,3 2,1,4" " 2,2,0 2,2,1 2,2,2 2,2,3 2,2,4" " 2,3,0 2,3,1 2,3,2 2,3,3 2,3,4"); finish; end; end;