tassign1.pp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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.
  60. {
  61. $Log$
  62. Revision 1.2 2002-09-07 15:40:49 peter
  63. * old logs removed and tabs fixed
  64. Revision 1.1 2002/08/10 08:27:43 carl
  65. + mre tests for cg testuit
  66. }