field.sa


Generated by gen_html_sa_files from ICSI. Contact gomes@icsi.berkeley.edu for details
 

class TEST_FIELD

class TEST_FIELD is -- This class is provided in the library to test all of the operations -- in the FIELD numeric class which are different from the CARD class. Note -- that it is not portable for simplicity in building a local library. -- Version 1.0 March 2001. Copyright K Hopper, U of Waikato -- Development History -- ------------------- -- Date Who By Detail -- ---- ------ ------ -- 22 Mar 01 kh Original from TEST_CARD include TEST ; main is class_name("FIELD") ; first : FIELD := 5 ; second : FIELD := 7 ; -- Test of field nil in decimal. restp3 : STR := FIELD::nil.str(LIBCHARS::default) ; test("nil.str",restp3,FIELD::maxval.str) ; -- Test of basic plus addition routine. val : FIELD := first.plus(second) ; test("plus",val.str,12.field.str) ; test("plus",(first + second).str,12.field.str) ; -- Test of basic subtraction routine. test("minus",(second - first).str,FIELD::two.str) ; -- Test of basic multiplication routine. test("times",(first * second).str,35.field.str) ; -- Test of basic division routine. test("div",(second / first).str,FIELD::one.str) ; -- Test of basic modulus routine. test("mod",(second.mod(first)).str,FIELD::two.str); -- test of conversion routines test("card",val.card.str,12.str) ; test("int",val.int.str,12.int.str) ; test("binstr",val.binstr.text_str,"00 00 00 0C") ; test("inti",val.inti.str,12.inti.str) ; test("flt",val.flt.str(3),(12.0).str(3)) ; test("fltd",val.fltd.str(3),(12.0).str(3)) ; -- Test of equality routine. test("is_eq",(second = first).str,false.str) ; test("is_eq",(first = first).str,true.str) ; -- Test of less than routine. test("is_lt",(first < second).str,true.str) ; test("is_lt",(second < first).str,false.str) ; -- Test of hash function unchecked_test("hash",val.hash.str,"OK?") ; -- Test of prime operations test("prime",first.is_prime.str,true.str) ; test("prime",val.is_prime.str,false.str) ; -- Test of sqrt test("sqrt",val.sqrt.str,3.str) ; -- Test of next_exp2 test("next_exp2",val.next_exp2.str,16.str) ; -- tests of modular arithmetic test("field add",(FIELD::one + FIELD::maxval).str,FIELD::zero.str) ; test("field minus",(FIELD::one - FIELD::maxval).str,FIELD::two.str) ; test("field times",(FIELD::two * FIELD::maxval).str, (FIELD::maxval - FIELD::one).str) ; test("field divide",(FIELD::one / FIELD::maxval).str,FIELD::zero.str) ; test("field modulus",(FIELD::one % FIELD::maxval).str,FIELD::one.str) ; finish end ; end ; -- TEST_FIELD