taddbool.pp 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  1. { Program to test Code generator secondadd() }
  2. { with boolean values. }
  3. { FUNCTIONAL PRE-REQUISITES: }
  4. { - assignments function correctly. }
  5. { - if statements function correctly. }
  6. { - subroutine calls function correctly. }
  7. Program TAddBool;
  8. {$IFDEF VER70}
  9. TYPE
  10. cardinal = longint;
  11. {$ENDIF}
  12. { ---------------------------- BOOLEAN TEST ----------------------------- }
  13. { secondadd() }
  14. { ----------------------------------------------------------------------- }
  15. procedure BoolTestAnd;
  16. var
  17. bb1, bb2: boolean;
  18. wb1, wb2: wordbool;
  19. lb1, lb2: longbool;
  20. result : boolean;
  21. begin
  22. result := true;
  23. { BOOLEAN AND BOOLEAN }
  24. Write('boolean AND boolean test...');
  25. bb1 := true;
  26. bb2 := false;
  27. if bb1 and bb2 then
  28. result := false;
  29. if bb2 then
  30. result := false;
  31. bb1 := false;
  32. bb2 := false;
  33. if bb1 and bb2 then
  34. result := false;
  35. bb1 := bb1 and bb2;
  36. if bb1 then
  37. result := false;
  38. if bb1 and FALSE then
  39. result := false;
  40. bb1 := true;
  41. bb2 := true;
  42. if bb1 and bb2 then
  43. begin
  44. if result then
  45. WriteLn('Success.')
  46. else
  47. WriteLn('Failure.');
  48. end
  49. else
  50. WriteLn('Failure.');
  51. { WORDBOOL AND WORDBOOL }
  52. result := true;
  53. Write('wordbool AND wordbool test...');
  54. wb1 := true;
  55. wb2 := false;
  56. if wb1 and wb2 then
  57. result := false;
  58. if wb2 then
  59. result := false;
  60. wb1 := false;
  61. wb2 := false;
  62. if wb1 and wb2 then
  63. result := false;
  64. wb1 := wb1 and wb2;
  65. if wb1 then
  66. result := false;
  67. if wb1 and FALSE then
  68. result := false;
  69. wb1 := true;
  70. wb2 := true;
  71. if wb1 and wb2 then
  72. begin
  73. if result then
  74. WriteLn('Success.')
  75. else
  76. WriteLn('Failure.');
  77. end
  78. else
  79. WriteLn('Failure.');
  80. { LONGBOOL AND LONGBOOL }
  81. result := true;
  82. Write('longbool AND longbool test...');
  83. lb1 := true;
  84. lb2 := false;
  85. if lb1 and lb2 then
  86. result := false;
  87. if lb2 then
  88. result := false;
  89. lb1 := false;
  90. lb2 := false;
  91. if lb1 and lb2 then
  92. result := false;
  93. lb1 := lb1 and lb2;
  94. if lb1 then
  95. result := false;
  96. if lb1 and FALSE then
  97. result := false;
  98. lb1 := true;
  99. lb2 := true;
  100. if lb1 and lb2 then
  101. begin
  102. if result then
  103. WriteLn('Success.')
  104. else
  105. WriteLn('Failure.');
  106. end
  107. else
  108. WriteLn('Failure.');
  109. end;
  110. procedure BoolTestOr;
  111. var
  112. bb1, bb2: boolean;
  113. wb1, wb2: wordbool;
  114. lb1, lb2: longbool;
  115. result : boolean;
  116. begin
  117. result := false;
  118. { BOOLEAN AND BOOLEAN }
  119. Write('boolean OR boolean test...');
  120. bb1 := true;
  121. bb2 := false;
  122. if bb1 or bb2 then
  123. result := true;
  124. bb1 := false;
  125. bb2 := false;
  126. if bb1 or bb2 then
  127. result := false;
  128. bb1 := bb1 or bb2;
  129. if bb1 then
  130. result := false;
  131. if bb1 or FALSE then
  132. result := false;
  133. bb1 := true;
  134. bb2 := true;
  135. if bb1 or bb2 then
  136. begin
  137. if result then
  138. WriteLn('Success.')
  139. else
  140. WriteLn('Failure.');
  141. end
  142. else
  143. WriteLn('Failure.');
  144. { WORDBOOL AND WORDBOOL }
  145. result := false;
  146. Write('wordbool OR wordbool test...');
  147. wb1 := true;
  148. wb2 := false;
  149. if wb1 or wb2 then
  150. result := true;
  151. wb1 := false;
  152. wb2 := false;
  153. if wb1 or wb2 then
  154. result := false;
  155. wb1 := wb1 or wb2;
  156. if wb1 then
  157. result := false;
  158. if wb1 or FALSE then
  159. result := false;
  160. wb1 := true;
  161. wb2 := true;
  162. if wb1 or wb2 then
  163. begin
  164. if result then
  165. WriteLn('Success.')
  166. else
  167. WriteLn('Failure.');
  168. end
  169. else
  170. WriteLn('Failure.');
  171. { LONGBOOL AND LONGBOOL }
  172. result := false;
  173. Write('longbool OR longbool test...');
  174. lb1 := true;
  175. lb2 := false;
  176. if lb1 or lb2 then
  177. result := true;
  178. if lb2 then
  179. result := false;
  180. lb1 := false;
  181. lb2 := false;
  182. if lb1 or lb2 then
  183. result := false;
  184. lb1 := lb1 or lb2;
  185. if lb1 then
  186. result := false;
  187. if lb1 or FALSE then
  188. result := false;
  189. lb1 := true;
  190. lb2 := true;
  191. if lb1 or lb2 then
  192. begin
  193. if result then
  194. WriteLn('Success.')
  195. else
  196. WriteLn('Failure.');
  197. end
  198. else
  199. WriteLn('Failure.');
  200. end;
  201. Procedure BoolTestXor;
  202. var
  203. bb1, bb2: boolean;
  204. wb1, wb2: wordbool;
  205. lb1, lb2: longbool;
  206. result : boolean;
  207. begin
  208. result := false;
  209. { BOOLEAN XOR BOOLEAN }
  210. Write('boolean XOR boolean test...');
  211. bb1 := true;
  212. bb2 := false;
  213. if bb1 xor bb2 then
  214. result := true;
  215. bb1 := false;
  216. bb2 := false;
  217. if bb1 xor bb2 then
  218. result := false;
  219. bb1 := bb1 xor bb2;
  220. if bb1 then
  221. result := false;
  222. if bb1 xor FALSE then
  223. result := false;
  224. bb1 := true;
  225. bb2 := true;
  226. if bb1 xor bb2 then
  227. begin
  228. WriteLn('Failure.');
  229. end
  230. else
  231. begin
  232. if result then
  233. WriteLn('Success.')
  234. else
  235. WriteLn('Failure.');
  236. end;
  237. { WORDBOOL XOR WORDBOOL }
  238. result := false;
  239. Write('wordbool XOR wordbool test...');
  240. wb1 := true;
  241. wb2 := false;
  242. if wb1 xor wb2 then
  243. result := true;
  244. wb1 := false;
  245. wb2 := false;
  246. if wb1 xor wb2 then
  247. result := false;
  248. wb1 := wb1 xor wb2;
  249. if wb1 then
  250. result := false;
  251. if wb1 xor FALSE then
  252. result := false;
  253. wb1 := true;
  254. wb2 := true;
  255. if wb1 xor wb2 then
  256. begin
  257. WriteLn('Failure.');
  258. end
  259. else
  260. begin
  261. if result then
  262. WriteLn('Success.')
  263. else
  264. WriteLn('Failure.');
  265. end;
  266. { LONGBOOL XOR LONGBOOL }
  267. result := false;
  268. Write('longbool XOR longbool test...');
  269. lb1 := true;
  270. lb2 := false;
  271. if lb1 xor lb2 then
  272. result := true;
  273. if lb2 then
  274. result := false;
  275. lb1 := false;
  276. lb2 := false;
  277. if lb1 xor lb2 then
  278. result := false;
  279. lb1 := lb1 xor lb2;
  280. if lb1 then
  281. result := false;
  282. if lb1 xor FALSE then
  283. result := false;
  284. lb1 := true;
  285. lb2 := true;
  286. if lb1 xor lb2 then
  287. begin
  288. WriteLn('Failure.');
  289. end
  290. else
  291. begin
  292. if result then
  293. WriteLn('Success.')
  294. else
  295. WriteLn('Failure.');
  296. end;
  297. end;
  298. Procedure BoolTestEqual;
  299. var
  300. bb1, bb2, bb3: boolean;
  301. wb1, wb2, wb3: wordbool;
  302. lb1, lb2, lb3: longbool;
  303. result : boolean;
  304. values : longint;
  305. Begin
  306. values := $02020202;
  307. { BOOLEAN = BOOLEAN }
  308. result := true;
  309. Write('boolean = boolean test...');
  310. bb1 := true;
  311. bb2 := true;
  312. bb3 := false;
  313. bb1 := (bb1 = bb2) and (bb2 and false);
  314. if bb1 then
  315. result := false;
  316. bb1 := true;
  317. bb2 := true;
  318. bb3 := false;
  319. bb1 := (bb1 = bb2) and (bb2 and true);
  320. if not bb1 then
  321. result := false;
  322. if bb1 = bb2 then
  323. begin
  324. if result then
  325. WriteLn('Success.')
  326. else
  327. WriteLn('Failure.');
  328. end
  329. else
  330. WriteLn('Failure.');
  331. { WORDBOOL = WORDBOOL }
  332. result := true;
  333. Write('wordbool = wordbool test...');
  334. wb1 := true;
  335. wb2 := true;
  336. wb3 := false;
  337. wb1 := (wb1 = wb2) and (wb2 and false);
  338. if wb1 then
  339. result := false;
  340. wb1 := true;
  341. wb2 := true;
  342. wb3 := false;
  343. wb1 := (wb1 = wb2) and (wb2 and true);
  344. if not wb1 then
  345. result := false;
  346. if wb1 = wb2 then
  347. begin
  348. if result then
  349. WriteLn('Success.')
  350. else
  351. WriteLn('Failure.');
  352. end
  353. else
  354. WriteLn('Failure.');
  355. Write('wordbool conversion to boolean...');
  356. result := TRUE;
  357. move(values,lb1,sizeof(lb1));
  358. if lb1 <> TRUE then
  359. result := false;
  360. if result then
  361. WriteLn('Success.')
  362. else
  363. WriteLn('Failure.');
  364. { LONGBOOL = LONGBOOL }
  365. result := true;
  366. Write('longbool = longbool test...');
  367. lb1 := true;
  368. lb2 := true;
  369. lb3 := false;
  370. lb1 := (lb1 = lb2) and (lb2 and false);
  371. if lb1 then
  372. result := false;
  373. lb1 := true;
  374. lb2 := true;
  375. lb3 := false;
  376. lb1 := (lb1 = lb2) and (lb2 and true);
  377. if not lb1 then
  378. result := false;
  379. if lb1 = lb2 then
  380. begin
  381. if result then
  382. WriteLn('Success.')
  383. else
  384. WriteLn('Failure.');
  385. end
  386. else
  387. WriteLn('Failure.');
  388. Write('longbool conversion to boolean...');
  389. result := TRUE;
  390. move(values,lb1,sizeof(lb1));
  391. if lb1 <> TRUE then
  392. result := false;
  393. if result then
  394. WriteLn('Success.')
  395. else
  396. WriteLn('Failure.');
  397. end;
  398. Procedure BoolTestNotEqual;
  399. var
  400. bb1, bb2, bb3: boolean;
  401. wb1, wb2, wb3: wordbool;
  402. lb1, lb2, lb3: longbool;
  403. result : boolean;
  404. Begin
  405. { BOOLEAN <> BOOLEAN }
  406. result := true;
  407. Write('boolean <> boolean test...');
  408. bb1 := true;
  409. bb2 := true;
  410. bb3 := false;
  411. bb1 := (bb1 <> bb2) and (bb2 <> false);
  412. if bb1 then
  413. result := false;
  414. bb1 := true;
  415. bb2 := true;
  416. bb3 := false;
  417. bb1 := (bb1 <> bb2) and (bb2 <> true);
  418. if bb1 then
  419. result := false;
  420. bb1 := false;
  421. bb2 := false;
  422. if bb1 <> bb2 then
  423. begin
  424. WriteLn('Failure.');
  425. end
  426. else
  427. begin
  428. if result then
  429. WriteLn('Success.')
  430. else
  431. WriteLn('Failure.');
  432. end;
  433. { WORDBOOL <> WORDBOOL }
  434. result := true;
  435. Write('wordbool <> wordbool test...');
  436. wb1 := true;
  437. wb2 := true;
  438. wb3 := false;
  439. wb1 := (wb1 <> wb2) and (wb2 <> false);
  440. if wb1 then
  441. result := false;
  442. wb1 := true;
  443. wb2 := true;
  444. wb3 := false;
  445. wb1 := (wb1 <> wb2) and (wb2 <> true);
  446. if wb1 then
  447. result := false;
  448. wb1 := false;
  449. wb2 := false;
  450. if wb1 <> wb2 then
  451. begin
  452. WriteLn('Failure.');
  453. end
  454. else
  455. begin
  456. if result then
  457. WriteLn('Success.')
  458. else
  459. WriteLn('Failure.');
  460. end;
  461. { LONGBOOL <> LONGBOOL }
  462. result := true;
  463. Write('longbool <> longbool test...');
  464. lb1 := true;
  465. lb2 := true;
  466. lb3 := false;
  467. lb1 := (lb1 <> lb2) and (lb2 <> false);
  468. if lb1 then
  469. result := false;
  470. lb1 := true;
  471. lb2 := true;
  472. lb3 := false;
  473. lb1 := (lb1 <> lb2) and (lb2 <> true);
  474. if lb1 then
  475. result := false;
  476. lb1 := false;
  477. lb2 := false;
  478. if lb1 <> lb2 then
  479. begin
  480. WriteLn('Failure.');
  481. end
  482. else
  483. begin
  484. if result then
  485. WriteLn('Success.')
  486. else
  487. WriteLn('Failure.');
  488. end;
  489. end;
  490. Procedure BoolLessThen;
  491. var
  492. bb1, bb2: boolean;
  493. wb1, wb2: wordbool;
  494. lb1, lb2: longbool;
  495. Begin
  496. {!!!!!!!!!!!}
  497. end;
  498. Procedure BoolGreaterThen;
  499. var
  500. bb1, bb2: boolean;
  501. wb1, wb2: wordbool;
  502. lb1, lb2: longbool;
  503. Begin
  504. {!!!!!!!!!!!!}
  505. End;
  506. Begin
  507. BoolTestAnd;
  508. BoolTestOr;
  509. BoolTestXor;
  510. BoolTestEqual;
  511. BoolTestNotEqual;
  512. end.
  513. {
  514. $Log$
  515. Revision 1.2 2001-07-27 02:55:35 carl
  516. + more complex testing
  517. Revision 1.1 2001/05/19 11:51:50 peter
  518. * renamed to .pp
  519. Revision 1.1 2001/05/09 18:11:21 carl
  520. + boolean secondadd()
  521. }