tcnvint1.pp 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. {****************************************************************}
  2. { CODE GENERATOR TEST PROGRAM }
  3. {****************************************************************}
  4. { NODE TESTED : secondtypeconvert() -> second_bool_to_int }
  5. {****************************************************************}
  6. { PRE-REQUISITES: secondload() }
  7. { secondassign() }
  8. { secondcalln() }
  9. { secondinline() }
  10. {****************************************************************}
  11. { DEFINES: }
  12. {****************************************************************}
  13. { REMARKS: }
  14. {****************************************************************}
  15. program tcnvint1;
  16. {$ifdef VER70}
  17. {$define tp}
  18. {$endif}
  19. var
  20. tobyte : byte;
  21. toword : word;
  22. tolong : longint;
  23. {$ifndef tp}
  24. toint64 : int64;
  25. {$endif}
  26. bb1 : bytebool;
  27. wb1 : wordbool;
  28. lb1 : longbool;
  29. bb2 : bytebool;
  30. wb2 : wordbool;
  31. lb2 : longbool;
  32. begin
  33. { left : LOC_REGISTER }
  34. { from : LOC_REFERENCE/LOC_REGISTER }
  35. WriteLn('Testing LOC_REFERENCE...');
  36. bb1 := TRUE;
  37. tobyte := byte(bb1);
  38. WriteLn('boolean->byte : value should be 1...',tobyte);
  39. if tobyte <> 1 then
  40. halt(1);
  41. bb1 := FALSE;
  42. tobyte := byte(bb1);
  43. WriteLn('boolean->byte : value should be 0...',tobyte);
  44. if tobyte <> 0 then
  45. halt(1);
  46. bb1 := TRUE;
  47. toword := word(bb1);
  48. WriteLn('boolean->word : value should be 1...',toword);
  49. if toword <> 1 then
  50. halt(1);
  51. bb1 := FALSE;
  52. toword := word(bb1);
  53. WriteLn('boolean->word : value should be 0...',toword);
  54. if toword <> 0 then
  55. halt(1);
  56. bb1 := TRUE;
  57. tolong := longint(bb1);
  58. WriteLn('boolean->longint : value should be 1...',tolong);
  59. if tolong <> 1 then
  60. halt(1);
  61. bb1 := FALSE;
  62. tolong := longint(bb1);
  63. WriteLn('boolean->longint : value should be 0...',tolong);
  64. if tolong <> 0 then
  65. halt(1);
  66. wb1 := TRUE;
  67. tobyte := byte(wb1);
  68. WriteLn('wordbool->byte : value should be 1...',tobyte);
  69. if tobyte <> 1 then
  70. halt(1);
  71. wb1 := FALSE;
  72. tobyte := byte(wb1);
  73. WriteLn('wordbool->byte : value should be 0...',tobyte);
  74. if tobyte <> 0 then
  75. halt(1);
  76. wb1 := TRUE;
  77. toword := word(wb1);
  78. WriteLn('wordbool->word : value should be 1...',toword);
  79. if toword <> 1 then
  80. halt(1);
  81. wb1 := FALSE;
  82. toword := word(wb1);
  83. WriteLn('wordbool->word : value should be 0...',toword);
  84. if toword <> 0 then
  85. halt(1);
  86. wb1 := TRUE;
  87. tolong := longint(wb1);
  88. WriteLn('wordbool->longint : value should be 1...',tolong);
  89. if tolong <> 1 then
  90. halt(1);
  91. wb1 := FALSE;
  92. tolong := longint(wb1);
  93. WriteLn('wordbool->longint : value should be 0...',tolong);
  94. if tolong <> 0 then
  95. halt(1);
  96. {$ifndef tp}
  97. bb1 := TRUE;
  98. toint64 :=int64(bb1);
  99. WriteLn('boolean->int64 : value should be 1...',toint64);
  100. if toint64 <> 1 then
  101. halt(1);
  102. bb1 := FALSE;
  103. toint64 :=int64(bb1);
  104. WriteLn('boolean->int64 : value should be 0...',toint64);
  105. if toint64 <> 0 then
  106. halt(1);
  107. wb1 := TRUE;
  108. toint64 :=int64(wb1);
  109. WriteLn('wordbool->int64 : value should be 1...',toint64);
  110. if toint64 <> 1 then
  111. halt(1);
  112. wb1 := FALSE;
  113. toint64 :=int64(wb1);
  114. WriteLn('wordbool->int64 : value should be 0...',toint64);
  115. if toint64 <> 0 then
  116. halt(1);
  117. {$endif}
  118. lb1 := TRUE;
  119. tobyte := byte(lb1);
  120. WriteLn('longbool->byte : value should be 1...',tobyte);
  121. if tobyte <> 1 then
  122. halt(1);
  123. lb1 := FALSE;
  124. tobyte := byte(lb1);
  125. WriteLn('longbool->byte : value should be 0...',tobyte);
  126. if tobyte <> 0 then
  127. halt(1);
  128. lb1 := TRUE;
  129. toword := word(lb1);
  130. WriteLn('longbool->word : value should be 1...',toword);
  131. if toword <> 1 then
  132. halt(1);
  133. lb1 := FALSE;
  134. toword := word(lb1);
  135. WriteLn('longbool->word : value should be 0...',toword);
  136. if toword <> 0 then
  137. halt(1);
  138. lb1 := TRUE;
  139. tolong := longint(lb1);
  140. WriteLn('longbool->longint : value should be 1...',tolong);
  141. if tolong <> 1 then
  142. halt(1);
  143. lb1 := FALSE;
  144. tolong := longint(lb1);
  145. WriteLn('longbool->longint : value should be 0...',tolong);
  146. if tolong <> 0 then
  147. halt(1);
  148. { left : LOC_REGISTER }
  149. { from : LOC_REFERENCE }
  150. wb1 := TRUE;
  151. bb2 := wb1;
  152. WriteLn('wordbool->boolean : value should be TRUE...',bb2);
  153. if not bb2 then
  154. halt(1);
  155. wb1 := FALSE;
  156. bb2 := wb1;
  157. WriteLn('wordbool->boolean : value should be FALSE...',bb2);
  158. if bb2 then
  159. halt(1);
  160. lb1 := TRUE;
  161. bb2 := lb1;
  162. WriteLn('longbool->boolean : value should be TRUE...',bb2);
  163. if not bb2 then
  164. halt(1);
  165. lb1 := FALSE;
  166. bb2 := lb1;
  167. WriteLn('longbool->boolean : value should be FALSE...',bb2);
  168. if bb2 then
  169. halt(1);
  170. bb1 := TRUE;
  171. lb2 := bb1;
  172. WriteLn('boolean->longbool : value should be TRUE...',lb2);
  173. if not lb2 then
  174. halt(1);
  175. bb1 := FALSE;
  176. lb2 := bb1;
  177. WriteLn('boolean->longbool : value should be FALSE...',lb2);
  178. if lb2 then
  179. halt(1);
  180. { left : LOC_REGISTER }
  181. { from : LOC_JUMP }
  182. WriteLn('Testing LOC_JUMP...');
  183. toword := 0;
  184. tobyte := 1;
  185. tobyte:=byte(toword > tobyte);
  186. WriteLn('value should be 0...',tobyte);
  187. if tobyte <> 0 then
  188. halt(1);
  189. toword := 2;
  190. tobyte := 1;
  191. tobyte:=byte(toword > tobyte);
  192. WriteLn('value should be 1...',tobyte);
  193. if tobyte <> 1 then
  194. halt(1);
  195. toword := 0;
  196. tobyte := 1;
  197. toword:=word(toword > tobyte);
  198. WriteLn('value should be 0...',toword);
  199. if toword <> 0 then
  200. halt(1);
  201. toword := 2;
  202. tobyte := 1;
  203. toword:=word(toword > tobyte);
  204. WriteLn('value should be 1...',toword);
  205. if toword <> 1 then
  206. halt(1);
  207. toword := 0;
  208. tobyte := 1;
  209. tolong:=longint(toword > tobyte);
  210. WriteLn('value should be 0...',tolong);
  211. if tolong <> 0 then
  212. halt(1);
  213. toword := 2;
  214. tobyte := 1;
  215. tolong:=longint(toword > tobyte);
  216. WriteLn('value should be 1...',tolong);
  217. if tolong <> 1 then
  218. halt(1);
  219. {$ifndef tp}
  220. toword := 0;
  221. tobyte := 1;
  222. toint64:=int64(toword > tobyte);
  223. WriteLn('value should be 0...',toint64);
  224. if toint64 <> 0 then
  225. halt(1);
  226. toword := 2;
  227. tobyte := 1;
  228. toint64:=int64(toword > tobyte);
  229. WriteLn('value should be 1...',toint64);
  230. if toint64 <> 1 then
  231. halt(1);
  232. {$endif}
  233. { left : LOC_REGISTER }
  234. { from : LOC_FLAGS }
  235. WriteLn('Testing LOC_FLAGS...');
  236. wb1 := TRUE;
  237. bb1 := FALSE;
  238. bb1 := (wb1 > bb1);
  239. WriteLn('Value should be TRUE...',bb1);
  240. if not bb1 then
  241. halt(1);
  242. wb1 := FALSE;
  243. bb1 := FALSE;
  244. bb1 := (wb1 > bb1);
  245. WriteLn('Value should be FALSE...',bb1);
  246. if bb1 then
  247. halt(1);
  248. lb1 := TRUE;
  249. bb1 := FALSE;
  250. bb1 := (bb1 > lb1);
  251. WriteLn('Value should be FALSE...',bb1);
  252. if bb1 then
  253. halt(1);
  254. lb1 := FALSE;
  255. bb1 := TRUE;
  256. bb1 := (bb1 > lb1);
  257. WriteLn('Value should be TRUE...',bb1);
  258. if not bb1 then
  259. halt(1);
  260. lb1 := TRUE;
  261. bb1 := FALSE;
  262. wb1 := (bb1 > lb1);
  263. WriteLn('Value should be FALSE...',wb1);
  264. if wb1 then
  265. halt(1);
  266. lb1 := FALSE;
  267. bb1 := TRUE;
  268. wb1 := (bb1 > lb1);
  269. WriteLn('Value should be TRUE...',wb1);
  270. if not wb1 then
  271. halt(1);
  272. lb1 := TRUE;
  273. bb1 := FALSE;
  274. lb1 := (bb1 > lb1);
  275. WriteLn('Value should be FALSE...',lb1);
  276. if lb1 then
  277. halt(1);
  278. lb1 := FALSE;
  279. bb1 := TRUE;
  280. lb1 := (bb1 > lb1);
  281. WriteLn('Value should be TRUE...',lb1);
  282. if not lb1 then
  283. halt(1);
  284. bb1 := TRUE;
  285. bb2 := FALSE;
  286. lb1 := (bb1 > bb2);
  287. WriteLn('Value should be TRUE...',lb1);
  288. if not lb1 then
  289. halt(1);
  290. bb1 := FALSE;
  291. bb2 := TRUE;
  292. lb1 := (bb1 > bb2);
  293. WriteLn('Value should be FALSE...',lb1);
  294. if lb1 then
  295. halt(1);
  296. end.