tloadvmt.pp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. {****************************************************************}
  2. { CODE GENERATOR TEST PROGRAM }
  3. { By Carl Eric Codere }
  4. {****************************************************************}
  5. { NODE TESTED : secondloadvmt() }
  6. {****************************************************************}
  7. { DEFINES: }
  8. { FPC = Target is FreePascal compiler }
  9. {****************************************************************}
  10. { REMARKS : Tested with Delphi 3 as reference implementation }
  11. {****************************************************************}
  12. program tloadvmt;
  13. {$ifdef fpc}
  14. {$mode objfpc}
  15. {$endif}
  16. const
  17. RESULT_STRING = 'Hello world';
  18. Type
  19. TAObject = class(TObject)
  20. a : longint;
  21. end;
  22. TBObject = Class(TAObject)
  23. b : longint;
  24. s : shortstring;
  25. constructor create(c: longint);
  26. function getstring : shortstring;
  27. end;
  28. procedure fail;
  29. begin
  30. WriteLn('Failure.');
  31. halt(1);
  32. end;
  33. constructor tbobject.create(c:longint);
  34. begin
  35. taobject.create;
  36. b:=c;
  37. s:=RESULT_STRING;
  38. end;
  39. function tbobject.getstring : shortstring;
  40. begin
  41. getstring := s;
  42. end;
  43. var
  44. bobj: TBobject;
  45. i: integer;
  46. l : longint;
  47. Begin
  48. i:=$7f;
  49. Write('Secondloadvmt test...');
  50. bobj:=TBobject.create(i);
  51. if bobj.getstring <> RESULT_STRING then
  52. fail
  53. else
  54. WriteLn('Success!');
  55. end.