tset2.pp 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. (*********************************************************************)
  2. (* Copyright (C) 1998, Carl Eric Codere *)
  3. (*********************************************************************)
  4. (* FPC (Free Pascal compiler) testsuite: SETS *)
  5. (* Tests the following: in, +, -, *, assignments. *)
  6. (* for small sets amd large sets, both with constants *)
  7. (* and variables. *)
  8. (*********************************************************************)
  9. type
  10. myenum = (dA,dB,dC,dd,dedf,dg,dh,di,dj,dk,dl,dm,dn);
  11. tasmop = (A_ABCD,
  12. A_ADD,A_ADDA,A_ADDI,A_ADDQ,A_ADDX,A_AND,A_ANDI,
  13. A_ASL,A_ASR,A_BCC,A_BCS,A_BEQ,A_BGE,A_BGT,A_BHI,
  14. A_BLE,A_BLS,A_BLT,A_BMI,A_BNE,A_BPL,A_BVC,A_BVS,
  15. A_BCHG,A_BCLR,A_BRA,A_BSET,A_BSR,A_BTST,A_CHK,
  16. A_CLR,A_CMP,A_CMPA,A_CMPI,A_CMPM,A_DBCC,A_DBCS,A_DBEQ,A_DBGE,
  17. A_DBGT,A_DBHI,A_DBLE,A_DBLS,A_DBLT,A_DBMI,A_DBNE,A_DBRA,
  18. A_DBPL,A_DBT,A_DBVC,A_DBVS,A_DBF,A_DIVS,A_DIVU,
  19. A_EOR,A_EORI,A_EXG,A_ILLEGAL,A_EXT,A_JMP,A_JSR,
  20. A_LEA,A_LINK,A_LSL,A_LSR,A_MOVE,A_MOVEA,A_MOVEI,A_MOVEQ,
  21. A_MOVEM,A_MOVEP,A_MULS,A_MULU,A_NBCD,A_NEG,A_NEGX,
  22. A_NOP,A_NOT,A_OR,A_ORI,A_PEA,A_ROL,A_ROR,A_ROXL,
  23. A_ROXR,A_RTR,A_RTS,A_SBCD,A_SCC,A_SCS,A_SEQ,A_SGE,
  24. A_SGT,A_SHI,A_SLE,A_SLS,A_SLT,A_SMI,A_SNE,
  25. A_SPL,A_ST,A_SVC,A_SVS,A_SF,A_SUB,A_SUBA,A_SUBI,A_SUBQ,
  26. A_SUBX,A_SWAP,A_TAS,A_TRAP,A_TRAPV,A_TST,A_UNLK,
  27. A_RTE,A_RESET,A_STOP,
  28. { MC68010 instructions }
  29. A_BKPT,A_MOVEC,A_MOVES,A_RTD,
  30. { MC68020 instructions }
  31. A_BFCHG,A_BFCLR,A_BFEXTS,A_BFEXTU,A_BFFFO,
  32. A_BFINS,A_BFSET,A_BFTST,A_CALLM,A_CAS,A_CAS2,
  33. A_CHK2,A_CMP2,A_DIVSL,A_DIVUL,A_EXTB,A_PACK,A_RTM,
  34. A_TRAPCC,A_TRACS,A_TRAPEQ,A_TRAPF,A_TRAPGE,A_TRAPGT,
  35. A_TRAPHI,A_TRAPLE,A_TRAPLS,A_TRAPLT,A_TRAPMI,A_TRAPNE,
  36. A_TRAPPL,A_TRAPT,A_TRAPVC,A_TRAPVS,A_UNPK,
  37. { FPU Processor instructions - directly supported only. }
  38. { IEEE aware and misc. condition codes not supported }
  39. A_FABS,A_FADD,
  40. A_FBEQ,A_FBNE,A_FBNGT,A_FBGT,A_FBGE,A_FBNGE,
  41. A_FBLT,A_FBNLT,A_FBLE,A_FBGL,A_FBNGL,A_FBGLE,A_FBNGLE,
  42. A_FDBEQ,A_FDBNE,A_FDBGT,A_FDBNGT,A_FDBGE,A_FDBNGE,
  43. A_FDBLT,A_FDBNLT,A_FDBLE,A_FDBGL,A_FDBNGL,A_FDBGLE,A_FBDNGLE,
  44. A_FSEQ,A_FSNE,A_FSGT,A_FSNGT,A_FSGE,A_FSNGE,
  45. A_FSLT,A_FSNLT,A_FSLE,A_FSGL,A_FSNGL,A_FSGLE,A_FSNGLE,
  46. A_FCMP,A_FDIV,A_FMOVE,A_FMOVEM,
  47. A_FMUL,A_FNEG,A_FNOP,A_FSQRT,A_FSUB,A_FSGLDIV,
  48. A_FSFLMUL,A_FTST,
  49. A_FTRAPEQ,A_FTRAPNE,A_FTRAPGT,A_FTRAPNGT,A_FTRAPGE,A_FTRAPNGE,
  50. A_FTRAPLT,A_FTRAPNLT,A_FTRAPLE,A_FTRAPGL,A_FTRAPNGL,A_FTRAPGLE,A_FTRAPNGLE,
  51. { Protected instructions }
  52. A_CPRESTORE,A_CPSAVE,
  53. { FPU Unit protected instructions }
  54. { and 68030/68851 common MMU instructions }
  55. { (this may include 68040 MMU instructions) }
  56. A_FRESTORE,A_FSAVE,A_PFLUSH,A_PFLUSHA,A_PLOAD,A_PMOVE,A_PTEST,
  57. { Useful for assembly langage output }
  58. A_LABEL,A_NONE);
  59. Function X(y:myenum): myenum;
  60. Begin
  61. x:=y;
  62. end;
  63. Procedure SecondInSets;
  64. { SET_IN_BYTE TESTS }
  65. var
  66. op : tasmop;
  67. oplist: set of tasmop;
  68. Begin
  69. Write('TESTING SET_IN_BYTE:');
  70. oplist:=[];
  71. op:=A_JSR;
  72. if op in oplist then
  73. WriteLn(' FAILED.');
  74. op:=A_MOVE;
  75. oplist:=oplist+[A_MOVE];
  76. if op in oplist then
  77. WriteLn(' PASSED.');
  78. end;
  79. Procedure SetSetByte;
  80. { SET_SET_BYTE }
  81. var
  82. op : tasmop;
  83. oplist: set of tasmop;
  84. Begin
  85. Write('TESTING SET_SET_BYTE(1):');
  86. op:=A_LABEL;
  87. oplist:=[];
  88. oplist:=oplist+[op];
  89. if op in oplist then
  90. Begin
  91. WriteLn(' PASSED.');
  92. end
  93. else
  94. Begin
  95. WriteLn(' FAILED.');
  96. end;
  97. Write('TESTING INCLUDE:');
  98. op:=A_RTE;
  99. include(oplist,op);
  100. if op in oplist then
  101. Begin
  102. WriteLn(' PASSED.');
  103. end
  104. else
  105. Begin
  106. WriteLn(' FAILED.');
  107. end;
  108. end;
  109. Procedure SetAddSets;
  110. { SET_ADD_SETS }
  111. var
  112. op2list :set of tasmop;
  113. oplist: set of tasmop;
  114. Begin
  115. op2list:=[];
  116. oplist:=[];
  117. oplist:=[A_MOVE]+[A_JSR];
  118. op2list:=[A_LABEL];
  119. oplist:=op2list+oplist;
  120. if A_MOVE in oplist then
  121. if A_LABEL in oplist then
  122. if A_JSR in oplist then
  123. WriteLn('TESTING SET_ADD_SETS: PASSED.')
  124. else
  125. WriteLn('TESTING SET_ADD_SETS: FAILED.')
  126. else
  127. WriteLn('TESTING SET_ADD_SETS: FAILED.')
  128. else
  129. WriteLn('TESTING SET_ADD_SETS: FAILED.')
  130. end;
  131. Procedure SetSubsets;
  132. { SET_SUB_SETS }
  133. var
  134. op2list :set of tasmop;
  135. oplist: set of tasmop;
  136. Begin
  137. op2list:=[];
  138. oplist:=[];
  139. oplist:=[A_MOVE]+[A_JSR];
  140. op2list:=[A_MOVE]+[A_JSR];
  141. oplist:=op2list-oplist;
  142. if (A_MOVE in oplist) or (A_LABEL in oplist) or (A_JSR in oplist) then
  143. WriteLn('TESTING SET_SUB_SETS: FAILED.')
  144. else
  145. WriteLn('TESTING SET_SUB_SETS: PASSED.');
  146. oplist := [A_MOVE,A_RTE];
  147. exclude(oplist,A_MOVE);
  148. if (A_MOVE in oplist) then
  149. WriteLn('TESTING EXCLUDE: FAILED.')
  150. else
  151. WriteLn('TESTING EXCLUDE: PASSED.')
  152. end;
  153. Procedure SetCompSets;
  154. { SET_COMP_SETS }
  155. var
  156. op2list :set of tasmop;
  157. oplist: set of tasmop;
  158. Begin
  159. op2list:=[];
  160. oplist:=[];
  161. oplist:=[A_MOVE]+[A_JSR];
  162. op2list:=[A_MOVE]+[A_JSR];
  163. if oplist=op2list then
  164. WriteLn('TESTING SET_COMP_SETS(1): PASSED.')
  165. else
  166. WriteLn('TESTING SET_COMP_SETS(1): FAILED.');
  167. oplist:=[A_MOVE];
  168. if oplist=op2list then
  169. WriteLn('TESTING SET_COMP_SETS(2): FAILED.')
  170. else
  171. WriteLn('TESTING SET_COMP_SETS(2): PASSED.');
  172. end;
  173. Procedure SetMulSets;
  174. { SET_COMP_SETS }
  175. var
  176. op2list :set of tasmop;
  177. oplist: set of tasmop;
  178. Begin
  179. op2list:=[];
  180. oplist:=[];
  181. oplist:=[A_MOVE]+[A_JSR];
  182. op2list:=[A_MOVE];
  183. oplist:=oplist*op2list;
  184. if A_JSR in oplist then
  185. WriteLn('TESTING SET_MUL_SETS(1): FAILED.')
  186. else
  187. WriteLn('TESTING SET_MUL_SETS(1): PASSED.');
  188. if A_MOVE in oplist then
  189. WriteLn('TESTING SET_MUL_SETS(2): PASSED.')
  190. else
  191. WriteLn('TESTING SET_MUL_SETS(2): FAILED.')
  192. end;
  193. {------------------------------ TESTS FOR SMALL VALUES ---------------------}
  194. Procedure SmallInSets;
  195. { SET_IN_BYTE TESTS }
  196. var
  197. op : myenum;
  198. oplist: set of myenum;
  199. Begin
  200. Write('TESTING IN_BYTE:');
  201. oplist:=[];
  202. op:=Dn;
  203. if op in oplist then
  204. WriteLn(' FAILED.');
  205. op:=dm;
  206. oplist:=oplist+[Dm];
  207. if op in oplist then
  208. WriteLn(' PASSED.');
  209. end;
  210. Procedure SmallSetByte;
  211. { SET_SET_BYTE }
  212. var
  213. op : myenum;
  214. oplist: set of myenum;
  215. Begin
  216. Write('TESTING SET_BYTE(1):');
  217. op:=DA;
  218. oplist:=[];
  219. oplist:=oplist+[op];
  220. if op in oplist then
  221. Begin
  222. WriteLn(' PASSED.');
  223. end
  224. else
  225. Begin
  226. WriteLn(' FAILED.');
  227. end;
  228. end;
  229. Procedure SmallAddSets;
  230. { SET_ADD_SETS }
  231. var
  232. op2list :set of myenum;
  233. oplist: set of myenum;
  234. Begin
  235. op2list:=[];
  236. oplist:=[];
  237. oplist:=[DA]+[DC];
  238. op2list:=[DB];
  239. oplist:=op2list+oplist;
  240. if DA in oplist then
  241. if DC in oplist then
  242. if DB in oplist then
  243. WriteLn('TESTING SET_ADD_SETS: PASSED.')
  244. else
  245. WriteLn('TESTING ADD_SETS: FAILED.')
  246. else
  247. WriteLn('TESTING ADD_SETS: FAILED.')
  248. else
  249. WriteLn('TESTING ADD_SETS: FAILED.')
  250. end;
  251. Procedure SmallSubsets;
  252. { SET_SUB_SETS }
  253. var
  254. op2list :set of myenum;
  255. oplist: set of myenum;
  256. Begin
  257. op2list:=[];
  258. oplist:=[];
  259. oplist:=[DA]+[DC];
  260. op2list:=[DA]+[DC];
  261. oplist:=op2list-oplist;
  262. if (DA in oplist) or (DB in oplist) or (DC in oplist) then
  263. WriteLn('TESTING SUB_SETS: FAILED.')
  264. else
  265. WriteLn('TESTING SUB_SETS: PASSED.')
  266. end;
  267. Procedure SmallCompSets;
  268. { SET_COMP_SETS }
  269. var
  270. op2list :set of myenum;
  271. oplist: set of myenum;
  272. Begin
  273. op2list:=[];
  274. oplist:=[];
  275. oplist:=[DA]+[DC];
  276. op2list:=[DA]+[DC];
  277. if oplist=op2list then
  278. WriteLn('TESTING COMP_SETS(1): PASSED.')
  279. else
  280. WriteLn('TESTING COMP_SETS(1): FAILED.');
  281. oplist:=[DA];
  282. if oplist=op2list then
  283. WriteLn('TESTING COMP_SETS(2): FAILED.')
  284. else
  285. WriteLn('TESTING COMP_SETS(2): PASSED.');
  286. end;
  287. Procedure SmallMulSets;
  288. { SET_COMP_SETS }
  289. var
  290. op2list :set of myenum;
  291. oplist: set of myenum;
  292. Begin
  293. op2list:=[];
  294. oplist:=[];
  295. oplist:=[DA]+[DC];
  296. op2list:=[DA];
  297. oplist:=oplist*op2list;
  298. if DC in oplist then
  299. WriteLn('TESTING MUL_SETS(1): FAILED.')
  300. else
  301. WriteLn('TESTING MUL_SETS(1): PASSED.');
  302. if DA in oplist then
  303. WriteLn('TESTING MUL_SETS(2): PASSED.')
  304. else
  305. WriteLn('TESTING MUL_SETS(2): FAILED.')
  306. end;
  307. const
  308. b: myenum = (dA);
  309. var
  310. enum: set of myenum;
  311. oplist: set of tasmop;
  312. l : word;
  313. Begin
  314. { small sets }
  315. enum:=[];
  316. { add }
  317. enum:=enum+[da];
  318. { subtract }
  319. enum:=enum-[da];
  320. if DA in enum then
  321. WriteLn('Found A_LABEL');
  322. { very large sets }
  323. { copy loop test }
  324. WRITELN('LARGE SETS:');
  325. oplist := [A_LABEL];
  326. { secondin test }
  327. if A_LABEL in oplist then
  328. WriteLn('TESTING SIMPLE SECOND_IN: PASSED.');
  329. { }
  330. oplist:=[];
  331. if A_LABEL in oplist then
  332. WriteLn('SECOND IN FAILED.');
  333. SecondinSets;
  334. SetSetByte;
  335. SetAddSets;
  336. SetSubSets;
  337. SetCompSets;
  338. SetMulSets;
  339. WRITELN('SMALL SETS:');
  340. SmallInSets;
  341. SmallAddSets;
  342. SmallSubSets;
  343. SmallCompSets;
  344. SmallMulSets;
  345. l:=word(A_CPRESTORE);
  346. if l = word(A_CPRESTORE) then
  347. Begin
  348. end;
  349. end.