tadint64.pp 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. { Program to test Code generator secondadd() }
  2. { with int64 values }
  3. { FUNCTIONAL PRE-REQUISITES: }
  4. { - assignments function correctly. }
  5. { - if statements function correctly. }
  6. { - subroutine calls function correctly. }
  7. procedure int64TestAdd;
  8. var
  9. i: int64;
  10. j: int64;
  11. result : boolean;
  12. begin
  13. Write('int64 + int64 test...');
  14. result := true;
  15. i:=0;
  16. j:=0;
  17. i := i + -10000;
  18. if i <> -10000 then
  19. result := false;
  20. j := 32767;
  21. i := i + j;
  22. if i <> 22767 then
  23. result := false;
  24. i := i + j + 50000;
  25. if i <> 105534 then
  26. result := false;
  27. i:=0;
  28. j:=10000;
  29. i:= i + j + j + i + j;
  30. if i <> 30000 then
  31. result := false;
  32. if not result then
  33. WriteLn('Failure.')
  34. else
  35. WriteLn('Success.');
  36. end;
  37. procedure int64TestSub;
  38. var
  39. i, j, k : int64;
  40. result : boolean;
  41. begin
  42. Write('int64 - int64 test...');
  43. result := true;
  44. i:=100000;
  45. j:=54;
  46. k:=56;
  47. i:= i - 100;
  48. if i <> 99900 then
  49. result := false;
  50. i := i - j - k - 100;
  51. if i <> 99690 then
  52. result := false;
  53. i:=100;
  54. j:=1000;
  55. k:=100;
  56. i:= j - i - k;
  57. if i <> 800 then
  58. result := false;
  59. if not result then
  60. WriteLn('Failure.')
  61. else
  62. WriteLn('Success.');
  63. end;
  64. procedure int64TestMul;
  65. var
  66. i : int64;
  67. j : int64;
  68. k: int64;
  69. result: boolean;
  70. begin
  71. Write('int64 * int64 test...');
  72. result := true;
  73. i:=0;
  74. j:=0;
  75. i:=i * 32;
  76. if i <> 0 then
  77. result := false;
  78. i:=10;
  79. i:=i * -16;
  80. if i <> -160 then
  81. result := false;
  82. j:=10000;
  83. i:=-10000;
  84. i:=i * j;
  85. if i <> -100000000 then
  86. result := false;
  87. i:=1;
  88. j:=10;
  89. k:=16;
  90. i := i * j * k;
  91. if i <> 160 then
  92. result := false;
  93. i := 1;
  94. j := 10;
  95. k := 16;
  96. i := i * 10 * j * i * j * 16 * k;
  97. if i <> 256000 then
  98. result := false;
  99. if not result then
  100. WriteLn('Failure.')
  101. else
  102. WriteLn('Success.');
  103. end;
  104. procedure int64TestXor;
  105. var
  106. i, j : int64;
  107. result : boolean;
  108. begin
  109. Write('int64 XOR int64 test...');
  110. result := true;
  111. i := 0;
  112. j := 0;
  113. i := i xor $1000001;
  114. if i <> $1000001 then
  115. result := false;
  116. i:=0;
  117. j:=$10000001;
  118. i:=i xor j;
  119. if i <> $10000001 then
  120. result := false;
  121. i := 0;
  122. j := $55555555;
  123. i := i xor j xor $AAAAAAAA;
  124. if i <> $FFFFFFFF then
  125. result := false;
  126. if not result then
  127. WriteLn('Failure.')
  128. else
  129. WriteLn('Success.');
  130. end;
  131. procedure int64TestOr;
  132. var
  133. i,j : int64;
  134. result : boolean;
  135. Begin
  136. Write('int64 OR int64 test...');
  137. result := true;
  138. i := 0;
  139. j := 0;
  140. i := i or $1000001;
  141. if i <> $1000001 then
  142. result := false;
  143. i:=0;
  144. j:=$10000001;
  145. i:=i or j;
  146. if i <> $10000001 then
  147. result := false;
  148. i := 0;
  149. j := $55555555;
  150. i := i or j or $AAAAAAAA;
  151. if i <> $FFFFFFFF then
  152. result := false;
  153. if not result then
  154. WriteLn('Failure.')
  155. else
  156. WriteLn('Success.');
  157. end;
  158. procedure int64TestAnd;
  159. var
  160. i,j : int64;
  161. result : boolean;
  162. Begin
  163. Write('int64 AND int64 test...');
  164. result := true;
  165. i := $1000001;
  166. j := 0;
  167. i := i and $1000001;
  168. if i <> $1000001 then
  169. result := false;
  170. i:=0;
  171. j:=$10000001;
  172. i:=i and j;
  173. if i <> 0 then
  174. result := false;
  175. i := $FFFFFFFF;
  176. j := $55555555;
  177. i := i and j;
  178. if i <> $55555555 then
  179. result := false;
  180. i := $FFFFFFFF;
  181. i := i and $AAAAAAAA;
  182. if i <> $AAAAAAAA then
  183. result := false;
  184. i := 0;
  185. j := $55555555;
  186. i := i and j and $AAAAAAAA;
  187. if i <> 0 then
  188. result := false;
  189. if not result then
  190. WriteLn('Failure.')
  191. else
  192. WriteLn('Success.');
  193. end;
  194. procedure int64TestEqual;
  195. var
  196. i,j : int64;
  197. result : boolean;
  198. Begin
  199. Write('int64 = int64 test...');
  200. result := true;
  201. i := $1000001;
  202. j := 0;
  203. if i = 0 then
  204. result := false;
  205. if i = j then
  206. result := false;
  207. if j = i then
  208. result := false;
  209. if not result then
  210. WriteLn('Failure.')
  211. else
  212. WriteLn('Success.');
  213. end;
  214. procedure int64TestNotEqual;
  215. var
  216. i,j : int64;
  217. result : boolean;
  218. Begin
  219. Write('int64 <> int64 test...');
  220. result := true;
  221. i := $1000001;
  222. j := $1000001;
  223. if i <> $1000001 then
  224. result := false;
  225. if i <> j then
  226. result := false;
  227. if j <> i then
  228. result := false;
  229. if not result then
  230. WriteLn('Failure.')
  231. else
  232. WriteLn('Success.');
  233. end;
  234. procedure int64TestLE;
  235. var
  236. i, j: int64;
  237. result : boolean;
  238. begin
  239. Write('int64 <= int64 test...');
  240. result := true;
  241. i := -1;
  242. j := -2;
  243. if i <= j then
  244. result := false;
  245. i := -2;
  246. j := $FFFF;
  247. if i >= j then
  248. result := false;
  249. i := $FFFFFFFF;
  250. if i <= $FFFFFFFE then
  251. result := false;
  252. j := $FFFFFFFF;
  253. if i <= j then
  254. begin
  255. if result then
  256. WriteLn('Success.')
  257. else
  258. WriteLn('Failure.');
  259. end
  260. else
  261. WriteLn('Failure.');
  262. end;
  263. procedure int64TestGE;
  264. var
  265. i, j: int64;
  266. result : boolean;
  267. begin
  268. Write('int64 >= int64 test...');
  269. result := true;
  270. i := $FFFFFFFE;
  271. j := $FFFFFFFF;
  272. if i >= j then
  273. result := false;
  274. i := $FFFFFFFE;
  275. j := $FFFFFFFF;
  276. if i > j then
  277. result := false;
  278. i := $FFFFFFFE;
  279. if i > $FFFFFFFE then
  280. result := false;
  281. i := $FFFFFFFF;
  282. j := $FFFFFFFF;
  283. if i >= j then
  284. begin
  285. if result then
  286. WriteLn('Success.')
  287. else
  288. WriteLn('Failure.');
  289. end
  290. else
  291. WriteLn('Failure.');
  292. end;
  293. Begin
  294. { These should be tested first, since if they do not }
  295. { work, they will false all other results. }
  296. Int64TestEqual;
  297. Int64TestNotEqual;
  298. Int64TestAdd;
  299. Int64TestMul;
  300. Int64TestOr;
  301. Int64TestAnd;
  302. Int64TestXor;
  303. Int64TestLe;
  304. Int64TestGe;
  305. Int64TestSub;
  306. end.
  307. {
  308. $Log$
  309. Revision 1.2 2001-06-24 23:58:14 carl
  310. * fixed problem with log
  311. }