tparray14.pp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. { based on gpc test pvs1 }
  2. { FLAG --extended-pascal }
  3. {TEST 6.6.5.4-1, CLASS=CONFORMANCE}
  4. { This program tests that pack and unpack are
  5. implemented in this compiler as according to the
  6. Standard.
  7. The compiler fails if the program does not compile. }
  8. program t6p6p5p4d1(output);
  9. {$mode macpas}
  10. type
  11. colourtype = (red,pink,orange,yellow,green,blue);
  12. var
  13. unone : array[3..24] of char;
  14. pacy : array[1..4] of char;
  15. pactwo : packed array[6..7] of colourtype;
  16. i : integer;
  17. colour : colourtype;
  18. s: string;
  19. const
  20. pacone : packed array[1..4] of char = 'ABCD';
  21. untwo : array[4..8] of colourtype = (red,pink,orange,yellow,green);
  22. begin
  23. pacy:=pacone;
  24. if pacy <> 'ABCD' then
  25. halt(1);
  26. s := pacone;
  27. unpack(pacone,unone,5);
  28. if (unone[3] <> #0) or
  29. (unone[4] <> #0) or
  30. (unone[5] <> 'A') or
  31. (unone[6] <> 'B') or
  32. (unone[7] <> 'C') or
  33. (unone[8] <> 'D') or
  34. (unone[9] <> #0) or
  35. (unone[10] <> #0) or
  36. (unone[11] <> #0) then
  37. halt(1);
  38. colour:=red;
  39. for i:=4 to 8 do
  40. begin
  41. if (untwo[i]<>colour) then
  42. halt(2);
  43. colour:=succ(colour)
  44. end;
  45. pack(untwo,5,pactwo);
  46. if (pactwo[6] <> pink) or
  47. (pactwo[7] <> orange) then
  48. halt(1);
  49. writeln('unone[5] = ''', unone[5], ''' = ', ord(unone[5]));
  50. if unone[5]='A' then
  51. writeln(' PASS...6.6.5.4-1')
  52. else
  53. begin
  54. writeln(' FAIL...6.6.5.4-1');
  55. halt(1);
  56. end;
  57. end.