|
@@ -1,21 +1,34 @@
|
|
|
|
+{ $OPT=-Cr }
|
|
program test;
|
|
program test;
|
|
|
|
|
|
|
|
+{$ifdef go32v2}
|
|
|
|
+ uses dpmiexcp;
|
|
|
|
+{$endif go32v2}
|
|
|
|
+
|
|
type
|
|
type
|
|
Tbaseclass = object
|
|
Tbaseclass = object
|
|
|
|
+ base_arg : longint;
|
|
|
|
+ st_count : longint;static;
|
|
constructor Init;
|
|
constructor Init;
|
|
destructor Done;
|
|
destructor Done;
|
|
procedure Run; virtual;
|
|
procedure Run; virtual;
|
|
|
|
|
|
end;
|
|
end;
|
|
Totherclass = object(Tbaseclass)
|
|
Totherclass = object(Tbaseclass)
|
|
|
|
+ other_arg : longint;
|
|
procedure Run; virtual;
|
|
procedure Run; virtual;
|
|
|
|
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+const
|
|
|
|
+ BaseRunCount : integer = 0;
|
|
|
|
+ OtherRunCount : integer = 0;
|
|
|
|
+
|
|
constructor Tbaseclass.Init;
|
|
constructor Tbaseclass.Init;
|
|
|
|
|
|
begin
|
|
begin
|
|
writeln('Init');
|
|
writeln('Init');
|
|
|
|
+ Inc(st_count);
|
|
Run;
|
|
Run;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -23,12 +36,14 @@ destructor Tbaseclass.Done;
|
|
|
|
|
|
begin
|
|
begin
|
|
writeln('Done');
|
|
writeln('Done');
|
|
|
|
+ dec(st_count);
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure Tbaseclass.Run;
|
|
procedure Tbaseclass.Run;
|
|
|
|
|
|
begin
|
|
begin
|
|
writeln('Base method');
|
|
writeln('Base method');
|
|
|
|
+ inc(BaseRunCount);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -36,11 +51,41 @@ procedure Totherclass.Run;
|
|
|
|
|
|
begin
|
|
begin
|
|
writeln('Inherited method');
|
|
writeln('Inherited method');
|
|
|
|
+ inc(OtherRunCount);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+ { try this as local vars }
|
|
|
|
+
|
|
|
|
+ procedure test_local_class_init;
|
|
|
|
+ var base1 : TbaseClass;
|
|
|
|
+ var other1 : TOtherClass;
|
|
|
|
+ begin
|
|
|
|
+ with other1 do
|
|
|
|
+ Init;
|
|
|
|
+ with base1 do
|
|
|
|
+ Init;
|
|
|
|
+ with other1 do
|
|
|
|
+ begin
|
|
|
|
+ Writeln('number of objects = ',st_count);
|
|
|
|
+ base_arg:=2;
|
|
|
|
+ other_arg:=6;
|
|
|
|
+ Run;
|
|
|
|
+ end;
|
|
|
|
+ { test if changed !! }
|
|
|
|
+
|
|
|
|
+ if (other1.base_arg<>2) or (other1.other_arg<>6) then
|
|
|
|
+ Halt(1);
|
|
|
|
+
|
|
|
|
+ with base1 do
|
|
|
|
+ begin
|
|
|
|
+ Run;
|
|
|
|
+ Done;
|
|
|
|
+ end;
|
|
|
|
+ other1.done;
|
|
|
|
+ end;
|
|
|
|
+
|
|
var base : Tbaseclass;
|
|
var base : Tbaseclass;
|
|
other : Totherclass;
|
|
other : Totherclass;
|
|
-// asmrec : Tasmrec;
|
|
|
|
testfield : longint;
|
|
testfield : longint;
|
|
|
|
|
|
begin
|
|
begin
|
|
@@ -61,6 +106,11 @@ begin
|
|
Done;
|
|
Done;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+ test_local_class_init;
|
|
{ Calls Tbaseclass.Run when it should call Totherclass.Run }
|
|
{ Calls Tbaseclass.Run when it should call Totherclass.Run }
|
|
-
|
|
|
|
|
|
+ If (BaseRunCount<>4) or (OtherRunCount<>4) then
|
|
|
|
+ Begin
|
|
|
|
+ Writeln('Error in tbs0187');
|
|
|
|
+ Halt(1);
|
|
|
|
+ End;
|
|
end.
|
|
end.
|