tfor.pp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. {****************************************************************}
  2. { CODE GENERATOR TEST PROGRAM }
  3. {****************************************************************}
  4. { NODE TESTED : secondfor() }
  5. {****************************************************************}
  6. { PRE-REQUISITES: secondload() }
  7. { secondassign() }
  8. { secondcalln() }
  9. { secondinline() }
  10. { secondadd() }
  11. {****************************************************************}
  12. { DEFINES: }
  13. {****************************************************************}
  14. { REMARKS: }
  15. {****************************************************************}
  16. program tfor;
  17. const LOOP_NUMS = 100;
  18. {$ifndef fpc}
  19. type cardinal = longint;
  20. {$endif}
  21. procedure fail;
  22. begin
  23. WriteLn('Failure.');
  24. halt(1);
  25. end;
  26. function getupper : longint;
  27. begin
  28. getupper:=LOOP_NUMS;
  29. end;
  30. function getupper0: longint;
  31. begin
  32. getupper0 := 1;
  33. end;
  34. {$ifdef fpc}
  35. function getupper64 : int64;
  36. begin
  37. getupper64:=1;
  38. end;
  39. function getupper64high : int64;
  40. begin
  41. getupper64high:=LOOP_NUMS;
  42. end;
  43. {$endif}
  44. var
  45. index_signed: longint;
  46. index_unsigned : cardinal;
  47. count:longint;
  48. count1 : longint;
  49. loop_count : longint;
  50. failed : boolean;
  51. {$ifdef fpc}
  52. index64 : int64;
  53. count64 : int64;
  54. count642 : int64;
  55. {$endif}
  56. begin
  57. loop_count:=0;
  58. count := LOOP_NUMS;
  59. count1 := LOOP_NUMS;
  60. { SIGNED INDEX }
  61. failed := false;
  62. Write('Signed index for loop testing (forward)...');
  63. { lowerbound : constant }
  64. { upper bound :: LOC_REFERENCE }
  65. for index_signed:=1 to count do
  66. loop_count:=loop_count+1;
  67. if loop_count <> LOOP_NUMS then
  68. failed := true;
  69. { upper bound : LOC_REGISTER }
  70. loop_count:=0;
  71. for index_signed:=1 to getupper do
  72. loop_count:=loop_count+1;
  73. if loop_count <> LOOP_NUMS then
  74. failed := true;
  75. { upper bound : LOC_CONSTANT }
  76. loop_count:=0;
  77. for index_signed:=1 to LOOP_NUMS do
  78. loop_count:=loop_count+1;
  79. if loop_count <> LOOP_NUMS then
  80. failed := true;
  81. { lowerbound : LOC_REFERENCE }
  82. { upper bound : constant }
  83. count:=1;
  84. loop_count:=0;
  85. for index_signed:=count to LOOP_NUMS do
  86. loop_count:=loop_count+1;
  87. if loop_count <> LOOP_NUMS then
  88. failed := true;
  89. { upper bound : LOC_REGISTER }
  90. loop_count:=0;
  91. for index_signed:=count to getupper do
  92. loop_count:=loop_count+1;
  93. if loop_count <> LOOP_NUMS then
  94. failed := true;
  95. { upper bound : LOC_REFERENCE }
  96. loop_count:=0;
  97. for index_signed:=count to count1 do
  98. loop_count:=loop_count+1;
  99. if loop_count <> LOOP_NUMS then
  100. failed := true;
  101. { lowerbound : LOC_REGISTER }
  102. { upper bound : constant }
  103. count:=0;
  104. loop_count:=0;
  105. for index_signed:=getupper0 to LOOP_NUMS do
  106. loop_count:=loop_count+1;
  107. if loop_count <> LOOP_NUMS then
  108. failed := true;
  109. { upper bound : LOC_REGISTER }
  110. loop_count:=0;
  111. for index_signed:=getupper0 to getupper do
  112. loop_count:=loop_count+1;
  113. if loop_count <> LOOP_NUMS then
  114. failed := true;
  115. { upper bound : LOC_REFERENCE }
  116. loop_count:=0;
  117. for index_signed:=getupper0 to count1 do
  118. loop_count:=loop_count+1;
  119. if loop_count <> LOOP_NUMS then
  120. failed := true;
  121. if failed then
  122. fail
  123. else
  124. WriteLn('Passed!');
  125. { UNSIGNED INDEX }
  126. Write('Unsigned index for loop testing (forward)...');
  127. loop_count:=0;
  128. failed := false;
  129. count := LOOP_NUMS;
  130. count1 := LOOP_NUMS;
  131. { lowerbound : constant }
  132. { upper bound :: LOC_REFERENCE }
  133. for index_unsigned:=1 to count do
  134. loop_count:=loop_count+1;
  135. if loop_count <> LOOP_NUMS then
  136. failed := true;
  137. { upper bound : LOC_REGISTER }
  138. loop_count:=0;
  139. for index_unsigned:=1 to getupper do
  140. loop_count:=loop_count+1;
  141. if loop_count <> LOOP_NUMS then
  142. failed := true;
  143. { upper bound : LOC_CONSTANT }
  144. loop_count:=0;
  145. for index_unsigned:=1 to LOOP_NUMS do
  146. loop_count:=loop_count+1;
  147. if loop_count <> LOOP_NUMS then
  148. failed := true;
  149. { lowerbound : LOC_REFERENCE }
  150. { upper bound : constant }
  151. count:=1;
  152. loop_count:=0;
  153. for index_unsigned:=count to LOOP_NUMS do
  154. loop_count:=loop_count+1;
  155. if loop_count <> LOOP_NUMS then
  156. failed := true;
  157. { upper bound : LOC_REGISTER }
  158. loop_count:=0;
  159. for index_unsigned:=count to getupper do
  160. loop_count:=loop_count+1;
  161. if loop_count <> LOOP_NUMS then
  162. failed := true;
  163. { upper bound : LOC_REFERENCE }
  164. loop_count:=0;
  165. for index_unsigned:=count to count1 do
  166. loop_count:=loop_count+1;
  167. if loop_count <> LOOP_NUMS then
  168. failed := true;
  169. { lowerbound : LOC_REGISTER }
  170. { upper bound : constant }
  171. count:=0;
  172. loop_count:=0;
  173. for index_unsigned:=getupper0 to LOOP_NUMS do
  174. loop_count:=loop_count+1;
  175. if loop_count <> LOOP_NUMS then
  176. failed := true;
  177. { upper bound : LOC_REGISTER }
  178. loop_count:=0;
  179. for index_unsigned:=getupper0 to getupper do
  180. loop_count:=loop_count+1;
  181. if loop_count <> LOOP_NUMS then
  182. failed := true;
  183. { upper bound : LOC_REFERENCE }
  184. loop_count:=0;
  185. for index_unsigned:=getupper0 to count1 do
  186. loop_count:=loop_count+1;
  187. if loop_count <> LOOP_NUMS then
  188. failed := true;
  189. if failed then
  190. fail
  191. else
  192. WriteLn('Passed!');
  193. (* UNSUPPORTED IN FPC VERSION 1.0.x (CEC)
  194. { --------------------- int64 testing!------------------- }
  195. WriteLn('int64 testing...');
  196. loop_count:=0;
  197. count64 := LOOP_NUMS;
  198. count1 := LOOP_NUMS;
  199. { SIGNED INDEX }
  200. failed := false;
  201. { lowerbound : constant }
  202. { upper bound :: LOC_REFERENCE }
  203. for index64:=1 to count64 do
  204. loop_count:=loop_count+1;
  205. if loop_count <> LOOP_NUMS then
  206. failed := true;
  207. { upper bound : LOC_REGISTER }
  208. loop_count:=0;
  209. for index64:=1 to getupper64high do
  210. loop_count:=loop_count+1;
  211. if loop_count <> LOOP_NUMS then
  212. failed := true;
  213. { upper bound : LOC_CONSTANT }
  214. loop_count:=0;
  215. for index64:=1 to LOOP_NUMS do
  216. loop_count:=loop_count+1;
  217. if loop_count <> LOOP_NUMS then
  218. failed := true;
  219. { lowerbound : LOC_REFERENCE }
  220. { upper bound : constant }
  221. count64:=1;
  222. count642:=LOOP_NUMS;
  223. loop_count:=0;
  224. for index64:=count64 to LOOP_NUMS do
  225. loop_count:=loop_count+1;
  226. if loop_count <> LOOP_NUMS then
  227. failed := true;
  228. { upper bound : LOC_REGISTER }
  229. loop_count:=0;
  230. for index64:=count64 to getupper64high do
  231. loop_count:=loop_count+1;
  232. if loop_count <> LOOP_NUMS then
  233. failed := true;
  234. { upper bound : LOC_REFERENCE }
  235. loop_count:=0;
  236. for index64:=count64 to count642 do
  237. loop_count:=loop_count+1;
  238. if loop_count <> LOOP_NUMS then
  239. failed := true;
  240. { lowerbound : LOC_REGISTER }
  241. { upper bound : constant }
  242. count64:=LOOP_NUMS;
  243. loop_count:=0;
  244. for index64:=getupper64 to LOOP_NUMS do
  245. loop_count:=loop_count+1;
  246. if loop_count <> LOOP_NUMS then
  247. failed := true;
  248. { upper bound : LOC_REGISTER }
  249. loop_count:=0;
  250. for index64:=getupper64 to getupper64high do
  251. loop_count:=loop_count+1;
  252. if loop_count <> LOOP_NUMS then
  253. failed := true;
  254. { upper bound : LOC_REFERENCE }
  255. loop_count:=0;
  256. for index64:=getupper64 to count64 do
  257. loop_count:=loop_count+1;
  258. if loop_count <> LOOP_NUMS then
  259. failed := true;
  260. if failed then
  261. fail
  262. else
  263. WriteLn('Passed!');
  264. *)
  265. loop_count:=0;
  266. count := LOOP_NUMS;
  267. count1 := LOOP_NUMS;
  268. { SIGNED INDEX }
  269. failed := false;
  270. Write('Signed index for loop testing (backward)...');
  271. { lowerbound : constant }
  272. { upper bound :: LOC_REFERENCE }
  273. for index_signed:=count downto 1 do
  274. loop_count:=loop_count+1;
  275. if loop_count <> LOOP_NUMS then
  276. failed := true;
  277. { upper bound : LOC_REGISTER }
  278. loop_count:=0;
  279. for index_signed:=getupper downto 1 do
  280. loop_count:=loop_count+1;
  281. if loop_count <> LOOP_NUMS then
  282. failed := true;
  283. { upper bound : LOC_CONSTANT }
  284. loop_count:=0;
  285. for index_signed:=LOOP_NUMS downto 1 do
  286. loop_count:=loop_count+1;
  287. if loop_count <> LOOP_NUMS then
  288. failed := true;
  289. { lowerbound : LOC_REFERENCE }
  290. { upper bound : constant }
  291. count:=1;
  292. loop_count:=0;
  293. for index_signed:=LOOP_NUMS downto count do
  294. loop_count:=loop_count+1;
  295. if loop_count <> LOOP_NUMS then
  296. failed := true;
  297. { upper bound : LOC_REGISTER }
  298. loop_count:=0;
  299. for index_signed:=getupper downto count do
  300. loop_count:=loop_count+1;
  301. if loop_count <> LOOP_NUMS then
  302. failed := true;
  303. { upper bound : LOC_REFERENCE }
  304. loop_count:=0;
  305. for index_signed:=count1 downto count do
  306. loop_count:=loop_count+1;
  307. if loop_count <> LOOP_NUMS then
  308. failed := true;
  309. { lowerbound : LOC_REGISTER }
  310. { upper bound : constant }
  311. count:=0;
  312. loop_count:=0;
  313. for index_signed:=LOOP_NUMS downto getupper0 do
  314. loop_count:=loop_count+1;
  315. if loop_count <> LOOP_NUMS then
  316. failed := true;
  317. { upper bound : LOC_REGISTER }
  318. loop_count:=0;
  319. for index_signed:=getupper downto getupper0 do
  320. loop_count:=loop_count+1;
  321. if loop_count <> LOOP_NUMS then
  322. failed := true;
  323. { upper bound : LOC_REFERENCE }
  324. loop_count:=0;
  325. for index_signed:=count1 downto getupper0 do
  326. loop_count:=loop_count+1;
  327. if loop_count <> LOOP_NUMS then
  328. failed := true;
  329. if failed then
  330. fail
  331. else
  332. WriteLn('Passed!');
  333. { UNSIGNED INDEX }
  334. Write('Unsigned index for loop testing (backward)...');
  335. loop_count:=0;
  336. failed := false;
  337. count := LOOP_NUMS;
  338. count1 := LOOP_NUMS;
  339. { lowerbound : constant }
  340. { upper bound :: LOC_REFERENCE }
  341. for index_unsigned:=count downto 1 do
  342. loop_count:=loop_count+1;
  343. if loop_count <> LOOP_NUMS then
  344. failed := true;
  345. { upper bound : LOC_REGISTER }
  346. loop_count:=0;
  347. for index_unsigned:=getupper downto 1 do
  348. loop_count:=loop_count+1;
  349. if loop_count <> LOOP_NUMS then
  350. failed := true;
  351. { upper bound : LOC_CONSTANT }
  352. loop_count:=0;
  353. for index_unsigned:=LOOP_NUMS downto 1 do
  354. loop_count:=loop_count+1;
  355. if loop_count <> LOOP_NUMS then
  356. failed := true;
  357. { lowerbound : LOC_REFERENCE }
  358. { upper bound : constant }
  359. count:=1;
  360. loop_count:=0;
  361. for index_unsigned:=LOOP_NUMS downto count do
  362. loop_count:=loop_count+1;
  363. if loop_count <> LOOP_NUMS then
  364. failed := true;
  365. { upper bound : LOC_REGISTER }
  366. loop_count:=0;
  367. for index_unsigned:=getupper downto count do
  368. loop_count:=loop_count+1;
  369. if loop_count <> LOOP_NUMS then
  370. failed := true;
  371. { upper bound : LOC_REFERENCE }
  372. loop_count:=0;
  373. for index_unsigned:=count1 downto count do
  374. loop_count:=loop_count+1;
  375. if loop_count <> LOOP_NUMS then
  376. failed := true;
  377. { lowerbound : LOC_REGISTER }
  378. { upper bound : constant }
  379. count:=0;
  380. loop_count:=0;
  381. for index_unsigned:=LOOP_NUMS downto getupper0 do
  382. loop_count:=loop_count+1;
  383. if loop_count <> LOOP_NUMS then
  384. failed := true;
  385. { upper bound : LOC_REGISTER }
  386. loop_count:=0;
  387. for index_unsigned:=getupper downto getupper0 do
  388. loop_count:=loop_count+1;
  389. if loop_count <> LOOP_NUMS then
  390. failed := true;
  391. { upper bound : LOC_REFERENCE }
  392. loop_count:=0;
  393. for index_unsigned:=count1 downto getupper0 do
  394. loop_count:=loop_count+1;
  395. if loop_count <> LOOP_NUMS then
  396. failed := true;
  397. if failed then
  398. fail
  399. else
  400. WriteLn('Passed!');
  401. end.