# set_1 # written by John Dannenhoffer # check number formats ASSERT 0.002 .001*2 ASSERT 0.002 0.001*2 ASSERT 0.002 1e-3*2 ASSERT 0.002 1.0E-3*2 ASSERT 0.002 .001e0*2 ASSERT 0.002 .01e-1*2 ASSERT 0.002 .0001E1*2 ASSERT 0.002 .00001E+2*2 # check for valid string characters SET str $abcdefghijklmnopqrstuvwxyz SET str $ABCDEFGHIJKLMNOPQRSTUVWXYZ SET str $0123456789 SET str $@_:;$.','+-*/^?(')[]{}%=<> # check expression evaluator ASSERT +6.283185 pi(2) ASSERT -4.5 min(-4.5,6.3) ASSERT +6.3 max(-4.5,6.3) ASSERT +2.236068 sqrt(5) ASSERT +3.4 abs(+3.4) ASSERT +3.4 abs(-3.4) ASSERT +3 int(3.4) ASSERT -3 int(-3.4) ASSERT +3 nint(3.4) ASSERT -3 nint(-3.4) ASSERT +4 ceil(3.4) ASSERT -3 ceil(-3.4) ASSERT +3 floor(3.4) ASSERT -4 floor(-3.4) ASSERT +1 mod(7,2) ASSERT -1 mod(-7,2) SET str $abc ASSERT 0 "ifmatch(str ,$?, 1,0)" ASSERT 0 "ifmatch($abc,$?, 1,0)" ASSERT +1 "ifmatch(str ,$'+, 1,0)" ASSERT +1 "ifmatch($abc,$'+, 1,0)" ASSERT +1 "ifmatch(str ,$*, 1,0)" ASSERT +1 "ifmatch($abc,$*, 1,0)" ASSERT +1 "ifmatch(str ,$a?c, 1,0)" ASSERT +1 "ifmatch($abc,$a?c, 1,0)" ASSERT +1 "ifmatch(str ,$a'+c, 1,0)" ASSERT +1 "ifmatch($abc,$a'+c, 1,0)" ASSERT +1 "ifmatch(str ,$a*c, 1,0)" ASSERT +1 "ifmatch($abc,$a*c, 1,0)" ASSERT 0 "ifmatch(str ,$a?c?, 1,0)" ASSERT 0 "ifmatch($abc,$a?c?, 1,0)" ASSERT 0 "ifmatch(str ,$a'+c'+,1,0)" ASSERT 0 "ifmatch($abc,$a'+c'+,1,0)" ASSERT +1 "ifmatch(str ,$a*c*, 1,0)" ASSERT +1 "ifmatch($abc,$a*c*, 1,0)" ASSERT +1 "ifnan(mod(7, 0), 1,0)" ASSERT +1 "ifnan(mod(7,-2), 1,0)" ASSERT +0.600000 mod(7,1.6) ASSERT +29.964100 exp(3.4) ASSERT +1.223775 log(3.4) ASSERT +0.531479 log10(3.4) ASSERT -0.255541 sin(3.4) ASSERT +0.059306 sind(3.4) ASSERT +0.346917 asin(0.34) ASSERT +19.876874 asind(0.34) ASSERT -0.966798 cos(3.4) ASSERT +0.998240 cosd(3.4) ASSERT +1.223879 acos(0.34) ASSERT +70.123126 acosd(0.34) ASSERT +0.264317 tan(3.4) ASSERT +0.059411 tand(3.4) ASSERT +1.284745 atan(3.4) ASSERT +73.610460 atand(3.4) ASSERT +0.643501 atan2(3,4) ASSERT +36.869898 atan2d(3,4) ASSERT +5 hypot(3,4) ASSERT +5 hypot(4,3) ASSERT +13 hypot3(3,4,12) ASSERT +13 hypot3(4,12,3) ASSERT +13 hypot3(12,3,4) ASSERT +1 "ifzero(0, 1,2)" ASSERT +2 "ifzero(3.4, 1,2)" ASSERT +2 "ifzero(-3.4,1,2)" ASSERT +2 "ifpos(0, 1,2)" ASSERT +1 "ifpos(3.4, 1,2)" ASSERT +2 "ifpos(-3.4, 1,2)" ASSERT +2 "ifneg(0, 1,2)" ASSERT +2 "ifneg(3.4, 1,2)" ASSERT +1 "ifneg(-3.4, 1,2)" ASSERT +2 "ifnan(0, 1,2)" ASSERT +1 "ifnan(1/0, 1,2)" ASSERT +1 "ifnan(xyz, 1,2)" # check string evaluations SET a1 10 # a1 = 10 0 ASSERT a1.size 1 ASSERT a1.nrow 1 ASSERT a1.ncol 1 SET b1 20 # b1 = 20 0 ASSERT b1.size 1 SET c1 a1+b1 # c1 = 30 0 ASSERT c1 30 ASSERT c1.size 1 SET a2 $10 # a2 = $10 ASSERT a2.size 2 ASSERT a2.nrow 0 ASSERT a2.ncol 0 SET b2 $20 # b2 = $20 ASSERT b2.size 2 SET c2 a2+b2 # c2 = $1020 ASSERT c2.size 4 SET c2 $10+$20 # c2 = $1020 ASSERT c2.size 4 SET c2 $10'+$20 # c2 = $10$20 ASSERT c2.size 6 SET a3 $pre_ # a3 = $pre_ ASSERT a3.size 4 ASSERT a3.nrow 0 ASSERT a3.ncol 0 SET b3 3.1415926 # b3 = 3.1415926 0 SET c3 $_post # c3 = $_post ASSERT c3.size 5 SET d3 val2str(b3,0) # d3 = $3 ASSERT d3.size 1 SET d3 val2str(b3,2) # d3 = $3.14 ASSERT d3.size 4 SET e3 a3+d3+c3 # e3 = $pre_3.14_post ASSERT e3.size 13 SET e3 a3+val2str(b3,2)+c3 # e3 = $pre_3.14_post ASSERT e3.size 13 SET e3 $pre_+val2str(b3,2)+$_post # e3 = $pre_3.14_post ASSERT e3.size 13 SET e3 $pre_+val2str(3.1415926,2)+$_post # e3 = $pre_3.14_post ASSERT e3.size 13 SET f3 str2val(d3) # f3 = 3.14 0 ASSERT f3 3.14 SET g3 a3+b3 # g3 = $pre_3.141593 ASSERT g3.size 12 SET g3 a3+nint(b3) # g3 = $pre_3 ASSERT g3.size 5 SET h3 str2val($sqrt(81')) # h3 = 9 ASSERT h3 9 SET i3 str2val($sqrt(h3')) # i3 = 3 ASSERT i3 3 SET j3 slice(e3,4,9) # j3 = $_3.14_ ASSERT j3.size 6 SET k3 slice(e3,4,999) # k3 = $_3.14_post ASSERT k3.size 10 SET l3 slice(e3,13,999) ASSERT l3.size 1 SET error 0 SET m3 slice(e3,0,999) # func_arg_out_of_bounds CATBEG $func_arg_out_of_bounds SET error 1 CATEND ASSERT error 1 SET error 0 SET m3 slice(e3,14,999) # func_arg_out_of_bounds CATBEG $func_arg_out_of_bounds SET error 1 CATEND ASSERT error 1 SET error 0 SET m3 slice(e3,4,-1) # func_arg_out_of_bounds CATBEG $func_arg_out_of_bounds SET error 1 CATEND ASSERT error 1 ASSERT 1 ifmatch($a+3,$a3,1,0) 1 ASSERT 1 ifmatch(4+$b,$4b,1,0) 1 ASSERT 1 ifmatch($c+$d+5,$cd5,1,0) 1 ASSERT 1 findstr(e3,a3) 1 ASSERT 1 findstr(e3,$pre_) 1 ASSERT 9 findstr(e3,c3) 9 ASSERT 9 findstr(e3,$_post) 9 ASSERT 0 findstr(e3,a2) 0 ASSERT 0 findstr(e3,$10) 0 # check subscript evaluator DIMENSION r 1 4 DIMENSION s 4 1 DIMENSION t 2 6 DIMENSION u 1 8 DIMENSION v 8 1 DIMENSION x 2 2 DIMENSION y 2 2 DIMENSION z 1 4 SET r[1] 11 SET r[2] 12 SET r[1,3] 13 SET r[1,4] 14 SET s[1] 11 SET s[2] 12 SET s[3,1] 13 SET s[4,1] 14 SET t "11; 12; 13; 14; 15; 16;\ 21; 22; 23; 24; 25; 26;" SET u "11; 12; 13; 14; 15; 16; 17; 18;" SET v "11; 12; 13; 14; 15; 16; 17; 18;" SET w 12345 SET x "1; 2;\ 3; 4;\ 5; 6;" SET y "7; 8;" SET z[1,1] 9 SET z[1,2] 10 SET z[1,3] 11 SET z[1,4] 12 ASSERT 1 ifzero(r[1]-t[1],1,0) ASSERT 1 ifzero(r[2]-t[2],1,0) ASSERT 1 ifzero(r[3]-t[3],1,0) ASSERT 1 ifzero(r[4]-t[4],1,0) ASSERT 1 ifzero(s[1]-t[1],1,0) ASSERT 1 ifzero(s[2]-t[2],1,0) ASSERT 1 ifzero(s[3]-t[3],1,0) ASSERT 1 ifzero(s[4]-t[4],1,0) ASSERT 11 t[1] ASSERT 22 t[2*4] ASSERT 12 t[1,2] ASSERT 26 t[2,2*3] ASSERT 26 t[1+1,2*3] ASSERT 26 t[1+1,6] ASSERT 26 t[(1+1),(2*3)] ASSERT 1 x[1,1] ASSERT 2 x[1,2] ASSERT 3 x[2,1] ASSERT 4 x[2,2] ASSERT 7 y[1,1] ASSERT 8 y[1,2] ASSERT 8 y[2,1] ASSERT 8 y[2,2] ASSERT 9 z[1,1] ASSERT 10 z[1,2] ASSERT 11 z[1,3] ASSERT 12 z[1,4] ASSERT 1 x[1] ASSERT 2 x[2] ASSERT 3 x[3] ASSERT 4 x[4] PATBEG i 4 ASSERT i x[i] PATEND ASSERT 9 z[1] ASSERT 10 z[2] ASSERT 11 z[3] ASSERT 12 z[4] PATBEG i 4 ASSERT i+8 z[i] PATEND # check expressions in subscripts PATBEG i 4 SET ip4 i+4 ASSERT i+14 u[ip4] ASSERT i+14 v[ip4] ASSERT i+14 u[1,ip4] ASSERT i+14 v[ip4,1] ASSERT i+14 u[+ip4] ASSERT i+14 v[+ip4] ASSERT i+14 u[1,+ip4] ASSERT i+14 v[+ip4,1] ASSERT i+14 u[(i+4)] ASSERT i+14 u[i+4] ASSERT i+14 v[i+4] ASSERT i+14 u[1,i+4] ASSERT i+14 v[i+4,1] ASSERT i*2+10 u[i*2] ASSERT i*2+10 v[i*2] ASSERT i*2+10 u[1,i*2] ASSERT i*2+10 v[i*2,1] PATEND # check indexing DIMENSION mat1 2 3 DIMENSION mat2 2 3 DIMENSION mat3 2 3 SET error 0 SET mat1 1;2 # 1;2;2;2;2;2 CATBEG $illegal_pmtr_index SET error 1 CATEND ASSERT error 0 ASSERT mat1.sum 11 SET error 0 SET mat1 1;2;3;4;5;6;7;8 # 1;2;3;4;5;6 CATBEG $illegal_pmtr_index SET error 1 CATEND ASSERT error 0 ASSERT mat1.sum 21 SET error 0 SET mat1[0] 1;2 # 1;2;2;2;2;2 CATBEG $illegal_pmtr_index SET error 1 CATEND ASSERT error 0 ASSERT mat1.sum 11 SET error 0 SET mat1[0,0] 1;2;3;4;5;6 # 1;2;3;4;5;6 CATBEG $illegal_pmtr_index SET error 1 CATEND ASSERT error 0 ASSERT mat1.sum 21 SET error 0 SET mat1[-1] 7 # error CATBEG $illegal_pmtr_index SET error 1 CATEND ASSERT error 1 ASSERT mat1.sum 21 SET error 0 SET mat1[-1] 7;7 # 7;7;7;7;7;7 CATBEG $illegal_pmtr_index SET error 1 CATEND ASSERT error 0 ASSERT mat1.sum 42 SET mat1 1;2;3;4;5;6 # 1;2;3;4;5;6 SET error 0 SET mat1[7] 7 # error CATBEG $illegal_pmtr_index SET error 1 CATEND ASSERT error 1 ASSERT mat1.sum 21 SET error 0 SET mat1[4] 7 # 1;2;3;7;5;6 CATBEG $illegal_pmtr_index SET error 1 CATEND ASSERT error 0 ASSERT mat1.sum 24 SET error 0 SET mat1[0,1] 7 # error CATBEG $illegal_pmtr_index SET error 1 CATEND ASSERT error 1 ASSERT mat1.sum 24 SET error 0 SET mat1[1,0] 7 # 7;2;3;7;5;6 CATBEG $illegal_pmtr_index SET error 1 CATEND ASSERT error 0 ASSERT mat1.sum 30 SET error 0 SET mat1[-1,1] 7 # error CATBEG $illegal_pmtr_index SET error 1 CATEND ASSERT error 1 ASSERT mat1.sum 30 SET error 0 SET mat1[3,1] 7 # error CATBEG $illegal_pmtr_index SET error 1 CATEND ASSERT error 1 ASSERT mat1.sum 30 SET error 0 SET mat1[1,-1] 1 # error CATBEG $illegal_pmtr_index SET error 1 CATEND ASSERT error 1 ASSERT mat1.sum 30 SET error 0 SET mat1[1,4] 1 # error CATBEG $illegal_pmtr_index SET error 1 CATEND ASSERT error 1 ASSERT mat1.sum 30 SET error 0 SET mat1[2,2] 8 # 7;2;3;7;8;6 CATBEG $illegal_pmtr_index SET error 1 CATEND ASSERT error 0 ASSERT mat1.sum 33 SET mat2[2,2] 0 ASSERT mat2[1,1] -99999999 ASSERT mat2[2,2] 0 SET mat3[2,2] 0 ASSERT mat3[1,1] -99999999 ASSERT mat3[2,2] 0 # check ability to change types # scalar->vector->scalar SET test1 11 ASSERT 1 test1.size ASSERT 1 test1.nrow ASSERT 1 test1.ncol ASSERT 11 test1.sum ASSERT 11 test1[1] DIMENSION test1 1 2 SET test1 12 # 12 is repeated ASSERT 2 test1.size ASSERT 1 test1.nrow ASSERT 2 test1.ncol ASSERT 24 test1.sum ASSERT 12 test1[1] ASSERT 12 test1[2] DIMENSION test1 2 1 SET test1 13;23;33 # truncated ASSERT 2 test1.size ASSERT 2 test1.nrow ASSERT 1 test1.ncol ASSERT 36 test1.sum ASSERT 13 test1[1] ASSERT 23 test1[2] DIMENSION test1 1 1 SET test1 14;24;34 # truncated ASSERT 1 test1.size ASSERT 1 test1.nrow ASSERT 1 test1.ncol ASSERT 14 test1.sum ASSERT 14 test1[1] # scalar->string->scalar SET test1 15 ASSERT 1 test1.size ASSERT 1 test1.nrow ASSERT 1 test1.ncol ASSERT 15 test1.sum ASSERT 15 test1[1] SET test1 $test1 ASSERT 5 test1.size ASSERT 0 test1.nrow ASSERT 0 test1.ncol ASSERT 1 ifmatch(test1,$test1,1,0) SET test1 16 ASSERT 1 test1.size ASSERT 1 test1.nrow ASSERT 1 test1.ncol ASSERT 16 test1.sum ASSERT 16 test1[1] # vector->string->vector DIMENSION test1 1 2 SET test1 17 # 17 is repeated ASSERT 2 test1.size ASSERT 1 test1.nrow ASSERT 2 test1.ncol ASSERT 34 test1.sum ASSERT 17 test1[1] ASSERT 17 test1[2] SET test1 $test1 ASSERT 5 test1.size ASSERT 0 test1.nrow ASSERT 0 test1.ncol ASSERT 1 ifmatch(test1,$test1,1,0) DIMENSION test1 2 1 SET test1 18;28;38 # truncated ASSERT 2 test1.size ASSERT 2 test1.nrow ASSERT 1 test1.ncol ASSERT 46 test1.sum ASSERT 18 test1[1] ASSERT 28 test1[2] # check dot-suffix expressions ASSERT 1 w.nrow ASSERT 1 w.ncol ASSERT 1 w.size ASSERT 12345 w.sum ASSERT 12345 w.norm ASSERT 12345 w.min ASSERT 12345 w.max ASSERT 2 x.nrow ASSERT 2 x.ncol ASSERT 4 x.size ASSERT 10 x.sum ASSERT 5.477226 x.norm ASSERT 1 x.min ASSERT 4 x.max ASSERT 2 y.nrow ASSERT 2 y.ncol ASSERT 4 y.size ASSERT 31 y.sum ASSERT 15.524174 y.norm ASSERT 7 y.min ASSERT 8 y.max ASSERT 1 z.nrow ASSERT 4 z.ncol ASSERT 4 z.size ASSERT 42 z.sum ASSERT 21.118712 z.norm ASSERT 9 z.min ASSERT 12 z.max # check arrays inside functions and functions inside arrays ASSERT 10 ifpos(atan2d(y[1,2],abs(x[2,1]+x[2,1])),10,11) ASSERT +69.443955 atan2d(y[1,2],x[2,1]) ASSERT +69.443955 atan2d(y[2],x[3]) ASSERT +69.443955 atan2d(y[min(1,2),max(1,2)],x[max(1,2),min(1,2)]) ASSERT +69.443955 atan2d(y[max(1,2)],x[max(1,3)]) # put point on screen POINT 0 0 0 END