tassign1.pp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. {****************************************************************}
  2. { CODE GENERATOR TEST PROGRAM }
  3. { By Carl Eric Codere }
  4. {****************************************************************}
  5. { NODE TESTED : secondassign() }
  6. {****************************************************************}
  7. { DEFINES: }
  8. { FPC = Target is FreePascal compiler }
  9. {****************************************************************}
  10. { REMARKS : Tested with Delphi 3 as reference implementation }
  11. { Tests the sortstring assignment. }
  12. {****************************************************************}
  13. program tassign1;
  14. {$ifdef fpc}
  15. {$mode objfpc}
  16. {$endif}
  17. const
  18. RESULT_STRING = 'Hello world';
  19. procedure fail;
  20. begin
  21. WriteLn('Failure.');
  22. halt(1);
  23. end;
  24. function getc : char;
  25. begin
  26. getc := 'a';
  27. end;
  28. var
  29. failed : boolean;
  30. s: shortstring;
  31. c: char;
  32. Begin
  33. Write('secondassign shortstring node testing...');
  34. failed := false;
  35. { constant string }
  36. s:=RESULT_STRING;
  37. if s<>RESULT_STRING then
  38. failed := true;
  39. { empty constant string, small optim. }
  40. s:='';
  41. if s<>'' then
  42. failed := true;
  43. { constant character }
  44. s:='a';
  45. if s<>'a' then
  46. failed := true;
  47. { non-constant character }
  48. c:='a';
  49. s:=c;
  50. if s<>'a' then
  51. failed := true;
  52. s:=getc;
  53. if s<>'a' then
  54. failed := true;
  55. if failed then
  56. fail
  57. else
  58. WriteLn('Success!');
  59. end.