tcnvint6.pp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. procedure error(n: longint);
  2. begin
  3. writeln('Test failed: ', n);
  4. Halt(n);
  5. end;
  6. var
  7. b,b2: byte;
  8. w,w2: word;
  9. c,c2: cardinal;
  10. shi,shi2: shortint;
  11. si,si2: smallint;
  12. i64,i642: int64;
  13. begin
  14. b:=$ff;
  15. Inc(b,$ff);
  16. if shortint(b)<>-2 then
  17. error(1);
  18. if smallint(b)<>$fe then
  19. error(2);
  20. if word(b)<>$fe then
  21. error(3);
  22. if longint(b)<>$fe then
  23. error(4);
  24. if cardinal(b)<>$fe then
  25. error(5);
  26. if int64(b)<>$fe then
  27. error(6);
  28. {$ifdef FPC}
  29. if qword(b)<>$fe then
  30. error(7);
  31. {$endif FPC}
  32. b2:=$fe;
  33. if b<>b2 then
  34. error(8);
  35. w:=$8000;
  36. if shortint(w)<>0 then
  37. error(8);
  38. w:=$ffff;
  39. Inc(w,$ffff);
  40. if shortint(w)<>-2 then
  41. error(11);
  42. if byte(w)<>$fe then
  43. error(12);
  44. if smallint(w)<>-2 then
  45. error(13);
  46. if longint(w)<>$fffe then
  47. error(14);
  48. if cardinal(w)<>$fffe then
  49. error(15);
  50. if int64(w)<>$fffe then
  51. error(16);
  52. {$ifdef FPC}
  53. if qword(w)<>$fffe then
  54. error(17);
  55. {$endif FPC}
  56. w2:=$fffe;
  57. if w<>w2 then
  58. error(18);
  59. c:=$ffffffff;
  60. Inc(c,$ffffffff);
  61. if int64(c)<>$fffffffe then
  62. error(21);
  63. {$ifdef FPC}
  64. if qword(c)<>$fffffffe then
  65. error(22);
  66. {$endif FPC}
  67. c2:=$fffffffe;
  68. if c<>c2 then
  69. error(23);
  70. shi:=$7f;
  71. Inc(shi,$7f);
  72. if word(shi)<>$fffe then
  73. error(31);
  74. if cardinal(shi)<>$fffffffe then
  75. error(32);
  76. i64:=cardinal(shi);
  77. if i64<>$fffffffe then
  78. error(33);
  79. {$ifdef FPC}
  80. if qword(shi)<>$fffffffffffffffe then
  81. error(34);
  82. {$endif FPC}
  83. shi2:=-2;
  84. if shi<>shi2 then
  85. error(35);
  86. si:=$7fff;
  87. Inc(si,$7fff);
  88. if word(si)<>$fffe then
  89. error(41);
  90. if cardinal(si)<>$fffffffe then
  91. error(42);
  92. i64:=cardinal(si);
  93. if i64<>$fffffffe then
  94. halt(43);
  95. {$ifdef FPC}
  96. if qword(si)<>$fffffffffffffffe then
  97. error(44);
  98. {$endif FPC}
  99. si2:=-2;
  100. if si<>si2 then
  101. error(45);
  102. writeln('Test OK.');
  103. end.