tcnvint6.pp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. procedure error(n: longint);
  2. begin
  3. writeln('Test failed: ', n);
  4. Halt(n);
  5. end;
  6. var
  7. b: byte;
  8. w: word;
  9. c: cardinal;
  10. shi: shortint;
  11. si: smallint;
  12. begin
  13. b:=$ff;
  14. Inc(b,$ff);
  15. if shortint(b)<>-2 then
  16. error(1);
  17. if smallint(b)<>$fe then
  18. error(2);
  19. if word(b)<>$fe then
  20. error(3);
  21. if longint(b)<>$fe then
  22. error(4);
  23. if cardinal(b)<>$fe then
  24. error(5);
  25. if int64(b)<>$fe then
  26. error(6);
  27. {$ifdef FPC}
  28. if qword(b)<>$fe then
  29. error(7);
  30. {$endif FPC}
  31. w:=$8000;
  32. if shortint(w)<>0 then
  33. error(8);
  34. w:=$ffff;
  35. Inc(w,$ffff);
  36. if shortint(w)<>-2 then
  37. error(11);
  38. if byte(w)<>$fe then
  39. error(12);
  40. if smallint(w)<>-2 then
  41. error(13);
  42. if longint(w)<>$fffe then
  43. error(14);
  44. if cardinal(w)<>$fffe then
  45. error(15);
  46. if int64(w)<>$fffe then
  47. error(16);
  48. {$ifdef FPC}
  49. if qword(w)<>$fffe then
  50. error(17);
  51. {$endif FPC}
  52. c:=$ffffffff;
  53. Inc(c,$ffffffff);
  54. if int64(c)<>$fffffffe then
  55. error(21);
  56. {$ifdef FPC}
  57. if qword(c)<>$fffffffe then
  58. error(22);
  59. {$endif FPC}
  60. shi:=-1;
  61. if word(shi)<>$ffff then
  62. error(31);
  63. if cardinal(shi)<>$ffffffff then
  64. error(32);
  65. {$ifdef FPC}
  66. if qword(shi)<>$ffffffffffffffff then
  67. error(33);
  68. {$endif FPC}
  69. si:=-1;
  70. if word(si)<>$ffff then
  71. error(34);
  72. if cardinal(si)<>$ffffffff then
  73. error(35);
  74. {$ifdef FPC}
  75. if qword(si)<>$ffffffffffffffff then
  76. error(36);
  77. {$endif FPC}
  78. writeln('Test OK.');
  79. end.