Ver código fonte

* new test

git-svn-id: trunk@635 -
florian 20 anos atrás
pai
commit
082ff3053e
2 arquivos alterados com 85 adições e 0 exclusões
  1. 1 0
      .gitattributes
  2. 84 0
      tests/webtbs/tw4015.pp

+ 1 - 0
.gitattributes

@@ -6125,6 +6125,7 @@ tests/webtbs/tw3977.txt svneol=native#text/plain
 tests/webtbs/tw4009.pp svneol=native#text/plain
 tests/webtbs/tw4010.pp svneol=native#text/plain
 tests/webtbs/tw4013.pp svneol=native#text/plain
+tests/webtbs/tw4015.pp svneol=native#text/plain
 tests/webtbs/tw4038.pp svneol=native#text/plain
 tests/webtbs/tw4043.pp svneol=native#text/plain
 tests/webtbs/tw4055.pp svneol=native#text/plain

+ 84 - 0
tests/webtbs/tw4015.pp

@@ -0,0 +1,84 @@
+{ Source provided for Free Pascal Bug Report 4015 }
+{ Submitted by "Radoslaw Stachowiak" on  2005-05-25 }
+{ e-mail: [email protected] }
+unit tw4015;
+{$mode objfpc}
+{$inline on}
+{$H+}
+interface
+
+type
+  TComponent = class;
+
+  { TComponentContainer }
+  TComponentContainer = class
+  private
+    acount: integer;
+    components: array of TComponent;
+    function fGet(ind: integer): TComponent; inline;
+  public
+    constructor Create;
+    destructor Destroy; override;
+    property Component[ind: integer]: TComponent read fGet; default;
+    property Count: integer read acount;
+  end;
+
+
+  { TComponent }
+  TComponent = class
+  protected
+    achildren: TComponentContainer;
+  public
+    constructor Create(const parent: TComponent);
+    destructor Destroy; override;
+  end;
+
+implementation
+
+{ TComponentContainer }
+function TComponentContainer.fGet(ind: integer): TComponent; inline;
+begin
+  if (ind>=acount) or (ind<0) then
+    result := nil
+  else
+    result := components[ind];
+end;
+
+
+constructor TComponentContainer.Create;
+begin
+  inherited Create;
+
+  acount:=0;
+  SetLength(components, 10);
+end;
+
+destructor TComponentContainer.Destroy;
+begin
+  inherited Destroy;
+end;
+
+{ TComponent }
+constructor TComponent.Create(const parent: TComponent);
+begin
+  inherited Create;
+  achildren := TComponentContainer.Create;
+end;
+
+destructor TComponent.Destroy;
+var
+  i: integer;
+begin
+  for i:=0 to achildren.Count-1 do
+  begin
+    achildren[i].Free(); //Internal Error 200108231
+    {if above line is changed to (var c: TComponent):
+     c := achildren[i]; //Internal Error 200108231
+     c.Free();
+     }
+  end;
+  achildren.Free;
+  inherited Destroy;
+end;
+
+end.