Einzelnen Beitrag anzeigen

Benutzerbild von Stevie
Stevie

Registriert seit: 12. Aug 2003
Ort: Soest
4.010 Beiträge
 
Delphi 10.1 Berlin Enterprise
 
#44

AW: Properties haben nach Zuweisung falsche Werte

  Alt 31. Okt 2014, 08:17
Nicht ins QC, sondern ins JIRA bitte.

Minimalcode zum Nachstellen ist wohl sowas hier:

Delphi-Quellcode:
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

type
  TPerson = class
  private
    FFirstname: string;
    FLastname: string;
  public
    property Firstname: string read FFirstname write FFirstname;
    property Lastname: string read FLastname write FLastname;
  end;

var
  person: TPerson;

function GetPerson: TPerson;
begin
  person.Firstname := 'Joe';
  person.Lastname := 'Doe';
  Result := person;
end;

var
  s: string;
begin
  person := TPerson.Create;
  try
    s := GetPerson.Firstname + ' ' + GetPerson.Lastname;
    Assert(s = 'Joe Doe');
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.
Stefan
“Simplicity, carried to the extreme, becomes elegance.” Jon Franklin

Delphi Sorcery - DSharp - Spring4D - TestInsight
  Mit Zitat antworten Zitat