tparray10.pp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. pacone : packed array[1..4] of char;
  15. pacy : array[1..4] of char;
  16. untwo : array[4..8] of colourtype;
  17. pactwo : packed array[6..7] of colourtype;
  18. i : integer;
  19. colour : colourtype;
  20. s: string;
  21. begin
  22. pacone:='ABCD';
  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. untwo[i]:=colour;
  42. colour:=succ(colour)
  43. end;
  44. pack(untwo,5,pactwo);
  45. if (pactwo[6] <> pink) or
  46. (pactwo[7] <> orange) then
  47. halt(1);
  48. writeln('unone[5] = ''', unone[5], ''' = ', ord(unone[5]));
  49. if unone[5]='A' then
  50. writeln(' PASS...6.6.5.4-1')
  51. else
  52. begin
  53. writeln(' FAIL...6.6.5.4-1');
  54. halt(1);
  55. end;
  56. end.