tcnvint2.pp 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. {****************************************************************}
  2. { CODE GENERATOR TEST PROGRAM }
  3. {****************************************************************}
  4. { NODE TESTED : secondtypeconvert() -> second_int_to_bool }
  5. {****************************************************************}
  6. { PRE-REQUISITES: secondload() }
  7. { secondassign() }
  8. { secondcalln() }
  9. { secondinline() }
  10. {****************************************************************}
  11. { DEFINES: }
  12. {****************************************************************}
  13. { REMARKS: This code is specific to FPC, this testsuite FAILS }
  14. { under Turbo Pascal / Borland Pascal. }
  15. {****************************************************************}
  16. program tcnvint2;
  17. function getbyte: byte;
  18. begin
  19. getbyte := $10;
  20. end;
  21. function getword: word;
  22. begin
  23. getword := $0F00;
  24. end;
  25. function getlongint: longint;
  26. begin
  27. getlongint := $10000000;
  28. end;
  29. {$ifdef fpc}
  30. function getint64: int64;
  31. begin
  32. getint64 := $10000000;
  33. end;
  34. {$endif}
  35. var
  36. frombyte : byte;
  37. fromword : word;
  38. fromlong : longint;
  39. {$ifdef fpc}
  40. fromint64 : int64;
  41. {$endif}
  42. bb1 : bytebool;
  43. wb1 : wordbool;
  44. lb1 : longbool;
  45. bb2 : bytebool;
  46. wb2 : wordbool;
  47. lb2 : longbool;
  48. begin
  49. { left : LOC_REGISTER }
  50. { from : LOC_REFERENCE }
  51. WriteLn('Testing LOC_REFERENCE...');
  52. frombyte := $10;
  53. bb1 := bytebool(frombyte);
  54. WriteLn('byte-> bytebool : Value should be TRUE...',bb1);
  55. frombyte := $10;
  56. wb1 := wordbool(frombyte);
  57. WriteLn('byte -> wordbool : Value should be TRUE...',wb1);
  58. { ------------------------------------------------------------ }
  59. { WARNING : This test fails under Borland Pascal v7, but }
  60. { works under Delphi 3.0 (normally it should give TRUE). }
  61. { ------------------------------------------------------------ }
  62. fromword := $1000;
  63. wb1 := wordbool(fromword);
  64. WriteLn('word -> wordbool : Value should be TRUE...',wb1);
  65. frombyte := $10;
  66. lb1 := longbool(frombyte);
  67. WriteLn('byte -> longbool : Value should be TRUE...',lb1);
  68. { ------------------------------------------------------------ }
  69. { WARNING : This test fails under Borland Pascal v7, but }
  70. { works under Delphi 3.0 (normally it should give TRUE). }
  71. { ------------------------------------------------------------ }
  72. fromword := $1000;
  73. lb1 := longbool(fromword);
  74. WriteLn('word -> longbool : Value should be TRUE...',lb1);
  75. { ------------------------------------------------------------ }
  76. { WARNING : This test fails under Borland Pascal v7, but }
  77. { works under Delphi 3.0 (normally it should give TRUE). }
  78. { ------------------------------------------------------------ }
  79. fromlong := $00000100;
  80. lb1 := longbool(fromlong);
  81. WriteLn('longint -> longbool : Value should be TRUE...',lb1);
  82. {$ifdef fpc}
  83. fromint64 := $10000000;
  84. lb1 := longbool(fromint64);
  85. WriteLn('int64 -> longbool : Value should be TRUE...',lb1);
  86. {$endif}
  87. { left : LOC_REGISTER }
  88. WriteLn('Testing LOC_REGISTER...');
  89. frombyte := $10;
  90. bb1 := bytebool(getbyte);
  91. WriteLn('byte-> bytebool : Value should be TRUE...',bb1);
  92. frombyte := $10;
  93. wb1 := wordbool(getbyte);
  94. WriteLn('byte -> wordbool : Value should be TRUE...',wb1);
  95. { ------------------------------------------------------------ }
  96. { WARNING : This test fails under Borland Pascal v7, but }
  97. { works under Delphi 3.0 (normally it should give TRUE). }
  98. { ------------------------------------------------------------ }
  99. fromword := $1000;
  100. wb1 := wordbool(getword);
  101. WriteLn('word -> wordbool : Value should be TRUE...',wb1);
  102. frombyte := $10;
  103. lb1 := longbool(getbyte);
  104. WriteLn('byte -> longbool : Value should be TRUE...',lb1);
  105. { ------------------------------------------------------------ }
  106. { WARNING : This test fails under Borland Pascal v7, but }
  107. { works under Delphi 3.0 (normally it should give TRUE). }
  108. { ------------------------------------------------------------ }
  109. fromword := $1000;
  110. lb1 := longbool(getword);
  111. WriteLn('word -> longbool : Value should be TRUE...',lb1);
  112. { ------------------------------------------------------------ }
  113. { WARNING : This test fails under Borland Pascal v7, but }
  114. { works under Delphi 3.0 (normally it should give TRUE). }
  115. { ------------------------------------------------------------ }
  116. fromlong := $00000100;
  117. lb1 := longbool(getlongint);
  118. WriteLn('longint -> longbool : Value should be TRUE...',lb1);
  119. {$ifdef fpc}
  120. fromint64 := $10000000;
  121. lb1 := longbool(getint64);
  122. WriteLn('int64 -> longbool : Value should be TRUE...',lb1);
  123. {$endif}
  124. (* CURRENTLY NEVER GOES INTO THE LOC_FLAGS LOCATION!
  125. { left : LOC_FLAGS }
  126. WriteLn('Testing LOC_FLAGS...');
  127. frombyte := 10;
  128. fromword := 2;
  129. bb1 := bytebool(frombyte > fromword);
  130. WriteLn('Value should be TRUE...',bb1);
  131. frombyte := $10;
  132. fromword := 2;
  133. wb1 := wordbool(frombyte > fromword);
  134. WriteLn('Value should be TRUE...',wb1);
  135. fromword := $1000;
  136. fromlong := $4000;
  137. wb1 := wordbool(fromlong > fromword);
  138. WriteLn('Value should be TRUE...',wb1);
  139. frombyte := $10;
  140. fromword := $20;
  141. lb1 := longbool(fromword > frombyte);
  142. WriteLn('Value should be TRUE...',lb1);
  143. fromword := $1000;
  144. fromlong := $0100;
  145. lb1 := longbool(fromlong > fromword);
  146. WriteLn('Value should be FALSE...',lb1);
  147. {$ifdef fpc}
  148. fromint64 := $10000000;
  149. fromlong := $02;
  150. lb1 := longbool(fromint64 > fromlong);
  151. WriteLn('Value should be TRUE...',lb1);
  152. {$endif}
  153. *)
  154. end.
  155. {
  156. $Log$
  157. Revision 1.1 2001-08-31 23:56:45 carl
  158. + first revision (missing LOC_FLAGS location test)
  159. }